php - Paypal REST API: Retrieve invoice numbers for further processing after payment approved -
i use paypal php sdk shopping app, after executed , approved of buyer's payment, want return payment details can continues further action such update database.
i hit url http://example.com/shopping/payment?success=true&paymentid=pay-1tk25581j9941930mk2h3odr&token=ec-9jk21383ks5324308&payerid=reluja6bn3mne
, in source code, have $info = $payment->gettransactions();
view payment's details after payment approved, print 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 ) ) )
`
how can each individual elements, let says want [invoice_number]
database process in app?
i have tried echo $info[0]['invoice_number']
error shown up, best way decode above arrays?
looking @ php sdk documentation gettransactions() returns array of objects. should able access array of objects this.
[pseudo code]
$transactions = $result->gettransactions(); $transaction = $transactions[0]; $transaction->invoice_number;
Comments
Post a Comment