简体   繁体   中英

Add a new credit card to paypal recurring payment profile

I have a feature in my website that a user can change/update/add a credit card in his/her Paypal recurring payment profile. But while updating the profile nothing happens. Please help. Code is as below:

require_once("paypal_pro.inc.php");
$paypalPro = new paypal_pro('xxxxxxxxxxxxxxxxxxxxx.gmail.com', 'xxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxx', '', '', FALSE, FALSE );
$paymentAction = urlencode("Sale");
$methodToCall = 'UpdateRecurringPaymentsProfile';
$padDateMonth = str_pad(4, 2, '0', STR_PAD_LEFT);
$expDateYear =urlencode( 2018);      
$expDate = $padDateMonth.$expDateYear;
$nvpstr='&PAYMENTACTION='.$paymentAction.'&METHOD=UpdateRecurringPaymentsProfile&PROFILEID=I-NGYJW5L1TLNV&CREDITCARDTYPE=VISA&ACCT=4111111111111111&CVV2=123&EXPDATE='.$expDate;
$resArray = $paypalPro->hash_call($methodToCall,$nvpstr);
echo '<pre>';
print_r($resArray);

I am trying this with a sandbox account.

First of all you need to tell where are you writing this code. Don't mind but your code looks like not as it should be: 1- Which version are you using (Yii1 | Yii2)? I guess Yii1

if you are using yii1 and you want to perform this stuff under profile update Action.

so lets consider "profile/update" Action. so there will be some thing like below under "ProfileController".

public function actionUpdate(){
//some thing will be placed here....
}

There are 2 ways to do it. one just do it along with the controller or user Hooks (recommended) so it will be under "Model afterSave" hook. some thing like that. you can use any extension / component / widget.

Paypal Extension can tell you how you can do it .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM