我有一个使用Paypal Rest API SDK的网站,并在交易后成功捕获paymentId。
我使用PHP从return_url的$ _SERVER ['QUERY_STRING']中捕获它。
我希望我的客户能够进入他们的Paypal帐户并使用这些PaymentID搜索记录。情况似乎并非如此。有一个TransactionID但它与PaymentID不匹配。
任何想法如何:
答案 0 :(得分:0)
我意识到我需要使用PaymentID并使用SDK来检索更详细的付款信息。
$ apiContext = $ this-> getApiContext();
$payment = new Payment();
$payment = $payment->get( $paymentId, $apiContext );
$execution = new PaymentExecution();
$execution->setPayerId( $_GET['PayerID'] );
// ### Retrieve payment
// Retrieve the payment object by calling the
// static `get` method
// on the Payment class by passing a valid
// Payment ID
// (See bootstrap.php for more on `ApiContext`)
try {
$payment->execute( $execution, $apiContext );
if ( $payment ) {
$obj = json_decode( $payment );
//GET SOME STUFF
$paypal_payment_id = $obj->{'id'};
$status = $obj->{'state'};
//DO SOMETHING WITH IT
}
} catch ( Exception $ex ) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
//ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
log_message( 'error', 'error=' . $ex );
//exit(1);
}