1

I'm a newbie into PayPal integration, and I'm trying to create first payment, I send following request to PayPal Rest API, via their simulator(https://devtools-paypal.com/apiexplorer/PayPalRestAPIs):

{
"intent": "sale",
"payer": {
    "payment_method": "paypal",
    "funding_instruments": [
        {
            "credit_card": {
                "number": "5277726581534042",
                "type": "mastercard",
                "expire_month": "9",
                "expire_year": "2018",
                "links": [
                    {
                        "targetSchema": {
                            "readonly": "true"
                        },
                        "schema": {
                            "readonly": "true"
                        }
                    }
                ]
            }
        }
    ],
    "payer_info": {
        "email": "ostan.marc.buyer@gmail.com"
    }
},
"transactions": [
    {
        "amount": {
            "currency": "USD",
            "total": "10"
        },
        "payee": {
            "email": "ostan.marc-faciliator@gmail.com"
        }
    }
],
"redirect_urls": {
    "return_url": "yandex.ru",
    "cancel_url": "google.com"
},
"links": [
    {
        "href": "http://google.com",
        "rel": "http://yandex.ru",
        "targetSchema": {
            "readonly": "true"
        },
        "schema": {
            "readonly": "true"
        }
    }
]
}

The reasponse i get is:

{
"name": "VALIDATION_ERROR",
"details": [
    {
        "field": "transactions",
        "issue": "Only single payment transaction currently supported"
    }
],
"message": "Invalid request - see details",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR",
"debug_id": "08c2dc7a41f64"

}
i just don't know how to make it work..

PayPal just says that im sending 2 payments..

Any help will be highly appreciated

Marc Ostan
  • 79
  • 4

1 Answers1

0

Are you trying to make a card or PayPal wallet payment?
That is, are you planning to charge a card directly, or redirect the user to PayPal?
In your current request you're including data from both options. This might be an issue with the API Explorer if that's what it's giving you.

Try this instead:

curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H 'Content-Type:application/json' \
-H 'Authorization:Bearer EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG' \
-d '{
  "intent":"sale",
  "redirect_urls":{
    "return_url":"http://example.com/your_redirect_url/",
    "cancel_url":"http://example.com/your_cancel_url/"
  },
  "payer":{
    "payment_method":"paypal"
  },
  "transactions":[
    {
      "amount":{
        "total":"7.47",
        "currency":"USD"
      }
    }
  ]
}'

Or for a card payment:

curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H "Content-Type:application/json" \
-H "Authorization:Bearer EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG" \
-d '{
  "intent": "sale",
  "payer": {
    "payment_method": "credit_card",
    "funding_instruments": [
      {
        "credit_card": {
          "number": "5500005555555559",
          "type": "mastercard",
          "expire_month": 12,
          "expire_year": 2018,
          "cvv2": 111,
          "first_name": "Joe",
          "last_name": "Shopper"
        }
      }
    ]
  },
  "transactions": [
    {
      "amount": {
        "total": "7.47",
        "currency": "USD"
      },
      "description": "This is the payment transaction description."
    }
  ]
}'

(Substitute the Authorization header with your own access token).

Robert
  • 19,326
  • 3
  • 58
  • 59