【发布时间】: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