我的网站上有一个小型单品购买商店,它使用 PayPal Express Checkout API 来完成付款。除了最后的 API 调用外,我的一切都正常工作DoExpressCheckoutPayment()
。我尝试了几种不同的方式来实现这一点,但是它们似乎都没有奏效。
这是我的success.php页面,api调用GetExpressCheckoutDetails()
在顶部进行,然后DoExpressCheckoutPayment()
应该在底部进行:
<script language="Javascript">
function showFBWindow(s1, s2, s3, s4, s5)
{
url = "purchase-thankyou.php?name="+s1+"&email="+s2+"&code="+s3+"&id="+s4+"&token="+s5;
newwindow=window.open(url,'name');
if (window.focus) {newwindow.focus();}
}
</script>
<?php
require_once("PayPal_API.php");
$Token = $_GET["token"];
$PayerID = $_GET["PayerID"];
$nvps = array();
$nvps["VERSION"] = "65.1";
// get details of transaction
$nvps["METHOD"] = "GetExpressCheckoutDetails";
$nvps["TOKEN"] = $Token;
$response = RunAPICall($nvps); // Send the API call to PayPal.
?>
<html>
<head>
<title>Order Processed</title>
</head>
<body bgcolor="#ffffff">
<h1>THANK YOU!</h1>
<p>
<h1>Your order has been processed. Please follow the link below to complete your payment</h1>
</p>
<p>
<?php
//outputArrayValues($response);
$id = $_GET['PayerID'];
$token = $response['TOKEN'];
$checkoutstatus = $response['CHECKOUTSTATUS'];
$timestamp = $response['TIMESTAMP'];
$correlation_id = $response['CORRELATIONID'];
$acknowledgement = $response['ACK'];
$version = $response['VERSION'];
$build = $response['BUILD'];
$e_mail_id = $response['EMAIL'];
$payer_id = $response['PAYERID'];
$payer_status = $response['PAYERSTATUS'];
$first_name = $response['FIRSTNAME'];
$last_name = $response['LASTNAME'];
$cust_name = $first_name." ".$last_name;
$country_code = $response['COUNTRYCODE'];
$currency_code = $response['CURRENCYCODE'];
$amount = $response['AMT'];
$item_amt = $response['ITEMAMT'];
$shipping_amt = $response['SHIPPINGAMT'];
$handling_amt = $response['HANDLINGAMT'];
$tax_amt = $response['TAXAMT'];
// complete purchase by sending DoExpressCheckoutPayment
$nvps["METHOD"] = "DoExpressCheckoutPayment";
$nvps["TOKEN"] = $token;
$nvps["PAYMENTACTION"] = "Sale";
$nvps["PAYERID"] = $payer_id;
// Send the API call to PayPal.
$response = RunAPICall($nvps);
?>
<a href="#"
onclick="showFBWindow('<?php echo $cust_name;?>','<?php echo $e_mail_id;?>','<?php echo $currency_code; ?>','<?php echo $id;?>', '<?php echo $token;?>')">
Click to Continue</a>
</body>
</html>
我通过 URL 将客户姓名和电子邮件传递到感谢页面,以将信息保存到我的数据库中。我应该DoExpressCheckoutPayment()
在感谢页面上打电话吗?
编辑:我在SetExpressCheckout()
URL 调用的末尾添加了“&useraction=commit”,这应该使“继续”按钮更改为“立即付款”,但它仍然没有完成付款?