gpt4 book ai didi

php - 如何集成 Paypal IPN 以进行定期付款?

转载 作者:太空宇宙 更新时间:2023-11-03 15:38:56 27 4
gpt4 key购买 nike

到目前为止,我一直在使用 Micah Carrick 的 PAYPAL IPN 类(class)

web_accept

但现在其中一个客户想要将 Recurring 方法集成到其中。我尝试使用相同的东西但不幸的是这次不太成功。我正在尝试连接到 Paypal 循环方法。以下是我尝试访问它的代码;

$paypalObj = new paypal_class();

$itemName = "My Product";
$itemNumber = $itemName . " - Premium ($amount$)";

$paypalObj->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';// testing paypal url
//$paypalObj->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';// Live paypal url

$paypalObj->add_field('cmd','_xclick-subscriptions');
$paypalObj->add_field('txn_type', "recurring_payment");
$paypalObj->add_field('product_name', "My Product Subscription - Monthly( $$amount )");
$paypalObj->add_field('desc', "My Product Subscription - Monthly( $$amount )");

$paypalObj->add_field('business', "test@yahoo.com");

$paypalObj->add_field('return', "http://".$serverName . "/buy-now.php");
$paypalObj->add_field('cancel_return', "http://".$serverName. "/return.php?action=cancel");
$paypalObj->add_field('notify_url', "http://" . $serverName . "/return.php?action=ipn");

$paypalObj->add_field('src', "1");
$paypalObj->add_field('sra', "1");
$paypalObj->add_field('a3', "$amount");
$paypalObj->add_field('t3', "M");
$paypalObj->add_field('p3', "1");
//$paypalObj->add_field('no_note', "1");
$paypalObj->add_field('currency_code', "USD");

$paypalObj->add_field('first_name', $firstName);
$paypalObj->add_field('last_name', $lastName);

$paypalObj->submit_paypal_post();

代码让我重定向到 Paypal 沙箱(因为我还在测试),但是当我登录到 Paypal 沙箱时,它抛出了这个错误:

您用于进入Pay​​Pal系统的链接无效。请查看链接并重试。

最佳答案

我刚刚弄清楚我的代码背后的问题是什么。我只是用其他一些变量重写了代码,它运行良好。

$paypalObj = new paypal_class();


$customData = $firstName . ":";
$customData .= $lastName . ":";
$customData .= $emailId ;
$itemName = "MY_PRODUCT";
$itemNumber = $itemName . " - Premium ($amount$)";

$paypalObj->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';// testing paypal url


$paypalObj->add_field('cmd','_xclick-subscriptions');
$paypalObj->add_field('business','MY_MECHANT_ACCOUNT');
$paypalObj->add_field('item_name',$itemName);
$paypalObj->add_field('item_number',$itemNumber);
$paypalObj->add_field('return', "http://" . $serverName . "/buy-now.php");
$paypalObj->add_field('cancel_return', "http://".$serverName. "/buy-now.php?action=cancel");
$paypalObj->add_field('notify_url', "http://" . $serverName . "/buy-now.php?action=ipn");
$paypalObj->add_field('no_note','1');
$paypalObj->add_field('currency_code','USD');
$paypalObj->add_field('custom',$customData);
$paypalObj->add_field('a3', "$amount");
$paypalObj->add_field('t3', "M");
$paypalObj->add_field('p3', "1");
$paypalObj->add_field('src', "1");
$paypalObj->add_field('sra', "1");

$paypalObj->submit_paypal_post();

关于php - 如何集成 Paypal IPN 以进行定期付款?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4045596/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com