简体   繁体   中英

How to update credit card information on braintree server php iOS?

I am using braintree SDK for payments. I have successfully integrated payment methods and transactions. But now I am stuck in updating the credit information if user decides to use their other card instead of the old one.

To achieve this I have made a web service which gets cardholder name, cc no, expiration month and year and cvv.

You can create the credit card by submitting all the details like this:

result = Braintree_CreditCard::create([
    'cardholder_name' => 'John Doe',
    'cvv' => '123',
    'expiration_date' => '12/2019,
    'number' => '4111111111111111',
    'options' => [
        'verify_card' => True
    ]
])
# use this credit card token(5mk3f2).
print(result.credit_card.token)

We this credit card token to update the credit card by as follows:

$result = Braintree_PaymentMethod::update(
  '5mk3f2',
  [
      'cardholder_name' => 'Doe Jhon',
      'cvv' => 'XXX',
      'expiration_date' => '8/2020,
      'number' => '4111111111111118',
      'billingAddress' => [
          'streetAddress' => '100 Maple Lane',
          'options' => [
            'updateExisting' => true
          ]
     ]
 ]);

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