Checkout API POST request to payments.json returns 422 credit_card invalid

Checkout API POST request to payments.json returns 422 credit_card invalid

Scarce
Visitor
1 0 0

Context: Using default shopify payment gateway. All requests leading up to the checkout completion have been made.

 

I start by sending a request to the Shopify credit card vault:

POST: https://elb.deposit.shopifycs.com

Body:

{
  "credit_card": {
    "number": "{credit-card}",
    "first_name": "Bob",
    "last_name": "Joe",
    "month": "5",
    "year": "2020",
    "verification_value": "123"
  }
}

I receive a normal response from this.

 

However, when I send a request to complete the checkout, I receive a 422 error.

Request to complete checkout:

POST: https://shopify.myshopify.com/admin/checkouts/{token}/payments.json

Body:

{
  "payment": {
    "request_details": {
      "ip_address": "123.1.1.1",
      "accept_language": "en-US,en;q=0.8,fr;q=0.6",
      "user_agent": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/54.0.2840.98 Safari\/537.36"
    },
    "amount": "100.00",
    "session_id": "{session-id}",
    "unique_token": "vaRS23"
  }
}

Response is a 422 error:

{
    "errors": {
        "credit_card": [
            {
                "code": "invalid",
                "message": "is invalid",
                "options": {}
            }
        ]
    }
}

 Any help is appreciated!

Reply 1 (1)

Alex
Shopify Staff
1561 81 342

Payment processing logs are a bit of a black box but I'll see what I can dig up first of all. If you can replicate this reliably, capture an x-request-id response header from your POST to /payments.json and I'll take a look.

 

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog