简体   繁体   中英

Paypal PHP API integration

Recently I'm playing with paypal API PHP.

I have downloaded a code from this url.

https://github.com/paypal/rest-api-curlsamples/blob/master/execute_all_calls.php

The code really works good with test creditcard(type:mastercard). The code looks like this

  $url = $host.'/v1/payments/payment';
  $payment = array(
  'intent' => 'sale',
  'payer' => array(
  'payment_method' => 'credit_card',
  'funding_instruments' => array ( array(
  'credit_card' => array (
  'number' => '540xxxxxxxxxxxx6',
  'type'   => 'mastercard',
  'expire_month' => 12,
  'expire_year' => 2018,
  'cvv2' => 111,
  'first_name' => 'First Name',
  'last_name' => 'Last Name'
  )
  ))
  ),
  'transactions' => array (array(
  'amount' => array(
  'total' => '2',
  'currency' => 'USD'
  ),
  'description' => 'payment by a credit card using a test script'
  ))
  );

Now if i try to use the same code to make the payment using my VISA(American Express) with test card number 37xxxxxxxxxx005, how shall i obtain this? What are the parameters to be altered?

In other words I would like to make the payment using Diner's Club,Discover and JCB. How shall I achieve this?

Edit: I have got two comments from Stack Overflow users, and you can check it at the bottom of my question. I'm not clear with the comments. Do they tell that I don't need to think about the parameters and paypal will take care of the card details and make the transaction?

Got reply from Paypal Tech Team for my above question

{snip}

You need to alter the code for 'type'. Below shows the code for the credit card type :l

- Visa
- MasterCard
- Discover
- Amex

And also make sure you need to input correct credit card number based on the type if you not you will receive an error message.

{/snip}

In other words, it is more than enough if I change the 'type' => 'mastercard' to 'type' => 'visa' (or) 'type' => 'amex' (or) 'type' => 'discover'

And also please make sure you give the correct test card numbers. You can view the dummy credit card numbers here. http://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm

Hope this will help someone if they are struck with the paypal PHP API integration.

Thanks for all the tech support & SOF-Users.

Thanks again, Haan

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