2013-03-15 153 views
1

我目前在我的網站中整合了paypal定期付款流程。我的網站用戶可以選擇取消他的paypal定期付款。我有每個用戶的payer_id和payer_email。是否有可能取消這些細節的定期付款。如果不是,如果特定用戶點擊取消我的網站的定期付款,我如何取消定期選項。取消Paypal定期付款

謝謝。

回答

2

你可以取消所有你的PayPal經常性配置文件與PROFILE_ID。並使用您的定期付款資料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));