【问题标题】:paypal php rest api. response codes?贝宝 php 休息 api。响应码?
【发布时间】:2014-11-02 04:12:51
【问题描述】:

整个贝宝流程一直是一场接一场的噩梦。除了一个小问题,我已经成功完成了申请。来自 paypal Payment::execute() 的响应对象没有文档。我的前端是客户端,所以我真的不知道这个响应数组包含什么。

这是我目前得到的:

    $paymentId = $this->ppconf; //stores paymentId

    if(empty($paymentId)){Throw New \Exception('missing payment id'); }

    $payment = Payment::get($paymentId, $apiContext);
    $execution = new PaymentExecution();
    $execution->setPayerId($z);
    $response = $payment->execute($execution, $apiContext); // i need to know what this response array looks like and what the response codes are, so i can generate my $result array for my application.

    $state = $response->getState();
    $failures = ['failed','canceled','expired'];
    if(in_array($state,$failures)){
        $result = ['type'=>'error'];
    }else{
        $result = ['type'=>'success'];
        $this->finished = true;
    }

    return $result;

【问题讨论】:

标签: php rest paypal


【解决方案1】:

根据文档:https://developer.paypal.com/webapps/developer/docs/api/#execute-an-approved-paypal-payment

为已完成的 PayPal 付款返回一个付款对象。

所以大概是PayPal\Api\Payment Object 的一个实例。

您应该能够使用以下方法获取付款的状态属性:

$response->getState();

返回下列字符串之一:

创建、批准、失败、取消、过期

【讨论】:

    猜你喜欢
    • 2017-02-01
    • 2014-02-15
    • 2016-04-25
    • 2013-10-18
    • 2018-10-05
    • 2015-10-16
    • 2020-04-09
    • 1970-01-01
    • 2017-03-01
    相关资源
    最近更新 更多