Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Getting 500 Internal Server Error, Php Api #648

Closed
malik-umair opened this issue Sep 19, 2016 · 10 comments
Closed

Getting 500 Internal Server Error, Php Api #648

malik-umair opened this issue Sep 19, 2016 · 10 comments
Labels

Comments

@malik-umair
Copy link

Required Information

  • PHP Version: 5.6.11
  • PayPal-PHP-SDK Version:
  • Debug ID(s): 8c0ed6fcbd68d

Issue Description

I'm getting 500 internal server error on all API calls from last 6-7 days. It's occurring on direct payments with credit card while recurring payments with credit card are working fine. Following is the php code I'm using for payments:

    $addr = new Address();
    $addr->setLine1($dataPaypal['addressLineOne']);
    $addr->setCity($dataPaypal['city']);
    $addr->setCountryCode('US');
    $addr->setPostalCode($dataPaypal['postalCode']);
    $addr->setState($dataPaypal['state_']);
    $card = new CreditCard();
    $card->setNumber($dataPaypal['ccNumber']);
    $card->setType($dataPaypal['ccType']);
    $card->setExpireMonth($dataPaypal['ccExpMonth']);
    $card->setExpireYear($dataPaypal['ccExpYear']);
    $card->setCvv2($dataPaypal['ccCode']);
    $card->setFirstName($dataPaypal['firstName']);
    $card->setLastName($dataPaypal['lastName']);
    $card->setBillingAddress($addr);

    $fi = new FundingInstrument();
    $fi->setCreditCard($card);

    $payer = new Payer();
    $payer->setPaymentMethod('credit_card');
    $payer->setFundingInstruments(array($fi));

    $amount = new Amount();
    $amount->setCurrency('USD');
    $amount->setTotal($dataPaypal['transactionAmount']);
    //can send custom data from this class
    $transaction = new Transaction();
    $transaction->setAmount($amount);
    $transaction->setDescription('This is the payment transaction description for payment id - ' . $paymentId);

    $payment = new Payment();
    $payment->setIntent('sale');
    $payment->setPayer($payer);
    $payment->setTransactions(array($transaction));
    $payment->create($this->_api_context);

Below is my Test JSON request:

{"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4012888888881881","type":"mastercard","expire_month":"12","expire_year":"2018","cvv2":"111","first_name":"Betsy","last_name":"Buyer"}}]},"transactions":[{"amount":{"currency":"USD","total":"299.25"},"description":"This is the payment transaction description for payment id - 43398"}]}
@randstraw
Copy link

Closing as a duplicate of #639

@randstraw
Copy link

@malik-umair #112 (comment)

What does your request JSON look like with the payment_card object being used?

@randstraw randstraw reopened this Sep 19, 2016
@malik-umair
Copy link
Author

Below is the response. Debug-id: e77c21ffb5281

{"intent":"sale","payer":{"payment_method":"payment_card","funding_instruments":[{"credit_card":{"number":"6011864721113929","type":"discover","expire_month":"2","expire_year":"2022","cvv2":"874","first_name":"umair","last_name":"malik","billing_address":{"line1":"111 First Street","city":"Columbus","country_code":"US","postal_code":"43210","state":"OH"}}}]},"transactions":[{"amount":{"currency":"USD","total":"299.25"},"description":"This is the payment transaction description for payment id - 43400"}]}

@randstraw
Copy link

randstraw commented Sep 19, 2016

Payment_method should be like this:

{"payment_method":"credit_card","funding_instruments":[{"payment_card"

payment_card also requires "billing_country"; this comment has an example #639 (comment)

@malik-umair
Copy link
Author

How can I set payment_card to funding instruction? I didn't found this method in API. My code is as below for funding_instruction:

$card = new CreditCard();
    $card->setNumber($dataPaypal['ccNumber']);
    $card->setType($dataPaypal['ccType']);
    $card->setExpireMonth($dataPaypal['ccExpMonth']);
    $card->setExpireYear($dataPaypal['ccExpYear']);
    $card->setCvv2($dataPaypal['ccCode']);
    $card->setFirstName($dataPaypal['firstName']);
    $card->setLastName($dataPaypal['lastName']);
    $card->setBillingAddress($addr);

    $fi = new FundingInstrument();
    $fi->setCreditCard($card);

@randstraw
Copy link

@malik-umair let me know if this helps.

Use PaymentCard instead of CreditCard
https://github.com/paypal/PayPal-PHP-SDK/blob/master/lib/PayPal/Api/PaymentCard.php

$card = new PaymentCard();

This does have the extra required field of billing country though https://github.com/paypal/PayPal-PHP-SDK/blob/master/lib/PayPal/Api/PaymentCard.php#L272

Then set it as the funding instrument.
https://github.com/paypal/PayPal-PHP-SDK/blob/master/lib/PayPal/Api/FundingInstrument.php#L74

Keep your payment_method as setPaymentMethod("credit_card")

@malik-umair
Copy link
Author

@pp-randy I've tried your suggestion and it worked. Thanks!

Is this PayPal change or API change, due to which this issue occur? And are there any upcoming changes for recurring payment method with credit card?

Thanks!

@randstraw
Copy link

@malik-umair this was an issue isolated to the sandbox but since PayPal documentation shows credit_card as deprecated using payment_card should be good to use going forward. However, to be clear credit_card should be supported for some time now the issue is isolated to the sandbox, and we are still working to resolve it.

Using credit_card is still showing as current here for billing-agreement (recurring payment): https://developer.paypal.com/docs/api/payments.billing-agreements#definition-credit_card

I will ask around and follow up on payment_card for billing agreements and see if something comes up.

@avptechnocrats
Copy link

@pp-randy I had looked at the https://github.com/paypal/PayPal-PHP-SDK/blob/master/lib/PayPal/Api/FundingInstrument.php#L74 and the function setPaymentCard also marked as deprecated and Not publicly available. So how can we confirm which one is actually deprecated.

@jaypatel512
Copy link
Contributor

Hey @avptechnocrats !

You are correct. We have deprecated credit_card and are moving to use payment_card. The SDKs needs to remove deprecation on that object. We will make the fix soon on this. Feel free to use the setPaymentCard method for now. It should be undeprecated. Feel free to send us a PR if you are excited 👍

jaypatel512 pushed a commit that referenced this issue Oct 17, 2016
- Fixed deprecation messages.
- Fixes #639.
- Fixes #648.
- Updated Samples.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants