cancel
Showing results for 
Search instead for 
Did you mean: 

How new SDK API V2 can make direct payment using card

New Community Member

How new SDK API V2 can make direct payment using card

I have to migrate from legacy API V1. The work-flow there was:

1. Get Paypal access token which is used to call the API.

2. Create payment using https://api.sandbox.paypal.com/v1/payments/payment

    * Pass this request into the body:

{
  "intent": "sale",
  "payer": {
    "payment_method": "credit_card", //"paypal" for Live environment
    "funding_instruments": [{
      "credit_card": {
        "number": "4137354345874043",
        "type": "visa",
        "expire_month": 11,
        "expire_year": 2020,
        "cvv2": "332",
        "first_name": "Yordan",
        "last_name": "Dimov",
        "billing_address": {
          "line1": "111 First Street",
          "city": "Saratoga",
          "state": "CA",
          "postal_code": "95070",
          "country_code": "US"
        }
      }
    }]
  },
  "transactions": [{
    "amount": {
      "total": "7.47",
      "currency": "USD",
      "details": {
        "subtotal": "7.41",
        "tax": "0.03",
        "shipping": "0.03"
      }
    },
    "description": "The payment transaction description."
  }]
}

3. This using card and payment transaction is completed

 

Actually this create and complete payment just in one call to the API V1.

 

How I can do the same in new API using CreateOrder? Can you someone send me example request? I have my own textboxes which collect the card info and send it to the server.

 

PS. I tried to create new order and Capture after then using this body:

{
	"payment_source": {
		"card": {
			"name": "Yordan Dimov",
			"number": "4137354345874043",
			"expiry": "2020-11",
			"security_code": "332",
			"card_type": "VISA"
		}
	}
}

It's return:

{
    "name": "INVALID_REQUEST",
    "message": "Request is not well-formed, syntactically incorrect, or violates schema.",
    "debug_id": "b50c683131782",
    "details": [
        {
            "field": "/payment_source/card/card_type",
            "value": "VISA",
            "location": "body",
            "issue": "INVALID_PARAMETER_SYNTAX",
            "description": "The value of a field does not conform to the expected format."
        }
    ],
    "links": [
        {
            "href": "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_SYNTAX",
            "rel": "information_link",
            "encType": "application/json"
        }
    ]
}

Without card_type which is not required the message is: 

{
    "name": "RESOURCE_NOT_FOUND",
    "details": [
        {
            "location": "path",
            "issue": "INVALID_RESOURCE_ID",
            "description": "Specified resource ID does not exist. Please check the resource ID and try again."
        }
    ],
    "message": "The specified resource does not exist.",
    "debug_id": "abd5925810d9f",
    "links": [
        {
            "href": "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_RESOURCE_ID",
            "rel": "information_link",
            "method": "GET"
        }
    ]
}

 

What I'm doing wrong? Where I can find documentation for this flow for new SDK API V2? I just have all card details and want to complete the payment server side.