本文整理汇总了PHP中PayPal::complete方法的典型用法代码示例。如果您正苦于以下问题:PHP PayPal::complete方法的具体用法?PHP PayPal::complete怎么用?PHP PayPal::complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal
的用法示例。
在下文中一共展示了PayPal::complete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public static function execute($payerID, $localTrxID)
{
$trxid = Session::instance()->get_once(self::SESSION_TOKEN);
$impl = new PayPal();
$response = $impl->complete($trxid, $payerID);
$localTrxID = $impl->retrieveLocalTrx($localTrxID);
self::debug("Paypal response for " . serialize($localTrxID), $response);
$target = $impl->approved($localTrxID, $response->id, $response->payer->payer_info, $impl->extractSales($response->transactions));
HTTP::redirect($target);
}
示例2: die
// Reroute buyer to PayPal with resulting transaction token
if ($result['ACK'] != 'Success') {
// Handle API error code
die('Error with API call - ' . $result["L_ERRORCODE0"]);
} else {
// Redirect Buyer to PayPal
$f3->reroute($result['redirect'] . '&useraction=commit');
}
});
$f3->route('GET /complete', function ($f3) {
// grab token & PayerID from URL
$token = $f3->get('GET.token');
$payerid = $f3->get('GET.PayerID');
// complete the transaction
$paypal = new PayPal();
$result = $paypal->complete($token, $payerid);
if ($result['ACK'] != 'Success' && $result['ACK'] != 'SuccessWithWarning') {
// Handle API error code
die('Error with API call - ' . $result["L_ERRORCODE0"]);
} else {
// Update back office - save transaction id, payment status etc
// Display thank you/receipt to the buyer.
$f3->set('itemcount', 0);
$f3->set('txnid', $result['PAYMENTINFO_0_TRANSACTIONID']);
echo \Template::instance()->render('receipt.html');
}
});
$f3->route('GET /refund', function ($f3) {
// Get transaction id from URL
$txnid = $f3->get('GET.txnid');
// Refund the transaction