How to update customer's recurring payment credit card?

frankni
Contributor
Contributor

I had been using merchant-sdk-php to power my subscription website, where users can choose to sign up using their existing paypal account, or using their credit card. We offer 14 days free trial. Users can update their credit card when the old card expires, users can change subscription plan, etc.. These are all good for many years by simply updating the existing subscription profile (no need to cancel and re-create a new one).

 

Now I try to switch to paypal rest api (php). (It apears rest is newer and better?) I found there are several problems:

1. I can't do free trial. I must charge at least $0.01, otherwise it got denied.

2. I can't update anything, not credit card, not subscription plan, etc. I can suspend, reactivate, or cancel a subscription though.

 

Here is my test code to change only description and it doesn't work. Please help if I do anything wrong? Many thanks

 

[code]

// $subscr_id ( = $agreement->getId() ) is saved in my database when it was created. It is the lookup key for all later transactions

$agreement = Agreement::get( $subscr_id, $apiContext );

 

$patch = new Patch;
$patch->setOp( "replace" )
    ->setPath( '/' )
    ->setValue( json_decode( '{ "description": "New Description", }' ) );

 

$pathRequest = new PatchRequest;

$pathRequest->addPatch( $patch );


$agreement->update( $pathRequest, $apiContext );

[/code]

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.