【问题标题】:PayPal Express Checkout API贝宝快速结账 API
【发布时间】:2012-10-13 18:48:27
【问题描述】:

我的网站上有一个小型单品购买商店,它使用 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”,这应该使“继续”按钮更改为“立即付款”,这确实是,但还是没有完成支付?

【问题讨论】:

    标签: php api paypal


    【解决方案1】:

    使用“useraction=commmit”并没有消除调用 DoExpressCheckoutPayment() 调用的需要。正如您所注意到的 - 它只会改变体验,但不会缩短 API 调用。更多信息在这里:https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing

    回到你原来的问题 - 不 - 你应该在显示“感谢页面”之前调用 DoExpresscheckout,直到你调用 DoExpresscheckout - 你的资金没有得到保证。

    【讨论】:

      猜你喜欢
      • 2017-07-01
      • 2014-09-06
      • 2012-07-01
      • 1970-01-01
      • 2015-11-18
      • 2016-11-24
      • 2015-12-28
      • 2013-09-04
      • 2014-01-02
      相关资源
      最近更新 更多