Anooj P
Anooj P

Reputation: 346

Cancel Paypal Recurring payments

I'm currently integrating the paypal recurring payment process in my website.in my website users have the option to cancel his paypal recurring payment.i have the payer_id and payer_email of each users. is it possible to cancel the recurring payment with these details. if no ,how can i cancel the recurring option if a perticular user click cancel recurring payment from my site.

thank you.

Upvotes: 3

Views: 5140

Answers (2)

Vishal
Vishal

Reputation: 109

You can cancels all your paypal recurring profile with PROFILE_ID. and execute this code with your Recurring Payment Profile ID. Hope This Will help you.

<?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));

Upvotes: 6

Devin Young
Devin Young

Reputation: 841

You can suspend or cancel a profile by using the ManageRecurringPaymentsProfileStatus API.

Note this reference. This is specifically for express checkout but it will work for other paypal integrations.

This has also been answered here, for future reference: Can you cancel a PayPal automatic payment via API? (Subscription created via Hosted button)

Upvotes: -1

Related Questions