【问题标题】:Paypal REST API: Retrieve invoice numbers for further processing after payment approvedPaypal REST API:在付款批准后检索发票编号以进行进一步处理
【发布时间】:2016-01-07 16:15:05
【问题描述】:

我在我的购物应用程序中使用了这个Paypal PHP SDK,在执行并获得买家付款后,我想返回付款详细信息,以便我可以继续进行进一步的操作,例如更新数据库。

我得到这个回击 URL http://example.com/shopping/payment?success=true&paymentId=PAY-1TK25581J9941930MK2H3ODR&token=EC-9JK21383KS5324308&PayerID=RELUJA6BN3MNE,在我的源代码中,我有 $info = $payment->getTransactions(); 在付款批准后查看付款的详细信息,打印为 print_r($info)

Array ( [0] => PayPal\Api\Transaction Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [amount] => PayPal\Api\Amount Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [total] => 56.00 [currency] => GBP [details] => PayPal\Api\Details Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [subtotal] => 46.00 [shipping] => 10.00 ) ) ) ) [payee] => PayPal\Api\Payee Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [email] => myshop@example.com ) ) [description] => Payment description [invoice_number] => 0AGIRVBYCOLK [item_list] => PayPal\Api\ItemList Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [items] => Array ( [0] => PayPal\Api\Item Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [name] => Blossom Cherry [price] => 20.00 [currency] => GBP [quantity] => 1 [description] => Tanks / Womens - M ) ) [1] => PayPal\Api\Item Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [name] => Space Sheep [price] => 26.00 [currency] => GBP [quantity] => 1 [description] => Roundnecks / Mens - L ) ) ) [shipping_address] => PayPal\Api\ShippingAddress Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [recipient_name] => test buyer [line1] => Level 01, Wall Street [city] => ABC City [state] => Manchester [postal_code] => 12345 [country_code] => UK ) ) ) ) [related_resources] => Array ( ) [notify_url] => http://example.com/paypal/pp-ipn.php ) ) ) `

如何获取每个单独的元素,假设我想为应用程序中的数据库进程获取 [invoice_number]

我试过echo $info[0]['invoice_number'] 但出现错误,解码上述数组的最佳方法是什么?

【问题讨论】:

    标签: php paypal-rest-sdk


    【解决方案1】:

    查看 PHP SDK 文档 getTransactions() 返回一个对象数组。所以你应该能够像这样访问对象数组。

    [伪代码]

    $transactions = $result->getTransactions();
    $transaction = $transactions[0];
    $transaction->invoice_number;
    

    【讨论】:

    • 它对我不起作用...发票在结帐时设置但在 $result = $payment->execute($execute, $paypal); $transactions = $result->getTransactions();
    猜你喜欢
    • 2013-09-03
    • 2021-11-11
    • 2014-11-16
    • 2018-03-22
    • 2021-10-11
    • 2017-10-04
    • 2016-02-21
    • 2014-06-20
    • 2017-05-13
    相关资源
    最近更新 更多