取消Paypal自动付款

3

我目前正在将PayPal定期付款流程集成到我的网站中。在我的网站上,用户有取消他的PayPal定期付款的选项。我拥有每个用户的payer_id和payer_email。是否可能使用这些详细信息取消定期付款?如果不行,当某个用户从我的网站点击取消定期付款时,我该如何取消定期付款选项。

谢谢。

2个回答

6
您可以使用PROFILE_ID取消您的PayPal自动付款配置文件,并使用您的自动付款配置文件ID执行此代码。希望这可以帮助您。
<?php
$curl = curl_init();

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array(
    'USER' => 'XXXXXXXXXXX',  //Your API User
    'PWD' => 'XXXXXXXXXXXXX',  //Your API Password
    'SIGNATURE' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',   //Your API Signature

    'VERSION' => '108',
    'METHOD' => 'ManageRecurringPaymentsProfileStatus',
    'PROFILEID' => 'I-315LHdijsju',         //here add your profile id                      
    'ACTION'    => 'Cancel' //this can be selected in these default paypal variables (Suspend, Cancel, Reactivate)
)));

$response =    curl_exec($curl);

curl_close($curl);

$nvp = array();

if (preg_match_all('/(?<name>[^\=]+)\=(?<value>[^&]+)&?/', $response, $matches)) {
    foreach ($matches['name'] as $offset => $name) {
        $nvp[$name] = urldecode($matches['value'][$offset]);
    }
}

printf("<pre>%s</pre>",print_r($nvp, true));

这段代码在第一次运行时对我有效。只需更改参数即可。 - Shakir Blouch

-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接