如何整合PayPal快速结账?

Ome*_*mer 4 php wordpress paypal wordpress-plugin paypal-sandbox

我正在开发一个需要PayPal Express结账功能的wordpress插件.

我在paypal网站上关注如何整合上下文结账功能的这篇文章(https://developer.paypal.com/webapps/developer/docs/classic/express-checkout/integration-guide/ECGettingStarted/#id53620a28- e357-4744-9979-66ed5c592183)在1步给了我以下表格.

<form method=post action=https://api-3t.sandbox.paypal.com/nvp>
    <input type=hidden name=USER value=API_username>
    <input type=hidden name=PWD value=API_password>
    <input type=hidden name=SIGNATURE value=API_signature>
    <input type=hidden name=VERSION value=XX.0>
    <input type=hidden name=PAYMENTREQUEST_0_PAYMENTACTION value=Sale>
    <input name=PAYMENTREQUEST_0_AMT value=19.95>
    <input type=hidden name=RETURNURL value=https://www.YourReturnURL.com>
    <input type=hidden name=CANCELURL value=https://www.YourCancelURL.com>
    <input type=submit name=METHOD value=SetExpressCheckout>
</form>
Run Code Online (Sandbox Code Playgroud)

我已经从PayPal添加了我自己的API_username,API_password和API_Signature但是在提交时显示了ACK=Failure.

以下是来自PayPal的消息:

TIMESTAMP=2015%2d10%2d30T05%3a27%3a09Z&CORRELATIONID=24cb45b8dd36b&ACK=Failure&VERSION=0%2e000000&BUILD=18308778&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Security%20error&L_LONGMESSAGE0=Security%20header%20is%20not%20valid&L_SEVERITYCODE0=Error
Run Code Online (Sandbox Code Playgroud)

因此,我无法转到PayPal文档的第2步,因此需要帮助.我究竟做错了什么?

小智 9

试试我在我的项目中使用的代码,它的工作原理.

PHP:

$paypal_url='https://www.paypal.com/cgi-bin/webscr'; 
$paypal_id='example@example.com';
Run Code Online (Sandbox Code Playgroud)

HTML:

<form action='<?php echo $paypal_url; ?>' method='post' name='frmPayPal1'>
    <input type='hidden' name='business' value='<?php echo $paypal_id;?>'>
    <input type='hidden' name='cmd' value='_xclick'>
    <input type='hidden' name='item_name' value='Products Total'>
    <input type='hidden' name='amount' value='<?php echo $tot;?>'>
    <input type='hidden' name='no_shipping' value='1'>
    <input type='hidden' name='currency_code' value='USD'>
    <input type='hidden' name='handling' value='0'>
    <input type='hidden' name='cancel_return' value='http://localhost/paypal/cancel.php'>
    <input type='hidden' name='return' value='http://localhost/paypal/success.php'>
    <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Run Code Online (Sandbox Code Playgroud)