XM

Add Payment To Cart

Path:

POST https://{baseurl}/api-payment/payment

Enables you to add payment to the cart.

Headers

Content-Type : application/json

x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

Parameters

Type: Body

Name: The cart ID (from the Add Items to Cart or Retrieve Cart by userAuthToken API) and the payment details.

Required: true

Sample Request

Path:

POST https://{baseurl}/api-payment/payment

Request Body:

{
"cartId": "60b90dd7308ded0008ee3c5d",
"paymentDetails": {
"transactionDetails": {
"paymentType": "CARD_STRIPE",
"paymentToken": "pi_1IyMGc2YBvYaVyBQNkOiCE3E"
},
"amount": 999,
"currency": "USD"
},
"billToAddress": {
"name": {
"first": "John",
"middle": "Bob",
"last": "Demo"
},
"email": "[email protected]",
"phone": {
"number": "07780811973",
"kind": "mobile"
},
"street1": "600 Congress Ave",
"street2": "suite 219",
"city": "Austin",
"state": "Tx",
"country": "US",
"zipCode": "10033"
}
}

Response

Success Code: 200

Message: OK

Description: You'll see this message when the stripe payment is successfully added to the cart.

{
"paymentDetails": {
"transactionDetails": {
"paymentType": "CARD_STRIPE",
"paymentToken": "pi_1IyMGc2YBvYaVyBQNkOiCE3E"
},
"paymentStatus": {
"cardHolderFullName": "First Last",
"paymentMethod": "visa",
"last4": "4242",
"amountCapturable": 99900,
"status": "succeeded"
},
"amount": 999,
"currency": "USD"
},
"billToAddress": {
"name": {
"first": "John",
"last": "Smith"
},
"phone": {
"number": "07780811973",
"kind": "mobile"
},
"email": "[email protected]",
"street1": "600 Congress Ave",
"street2": "suite 219",
"city": "Austin",
"state": "Tx",
"country": "US",
"zipCode": "10033"
},
"version": 0,
"isValid": true,
"_id": "60b92e823de01200093818cb",
"cartId": "60b90dd7308ded0008ee3c5d",
"createdAt": "2021-06-03T19:33:22.876Z",
"updatedAt": "2021-06-03T19:33:22.876Z"
}

Error Code: 404

Message: Not found

Description: You will see this error when the cart ID doesn't exist in the system.

{
"code": "CART_NOT_FOUND",
"message": "Cart not found."
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the cart ID is lesser or greater than 24 characters.

{
"code": "REQUEST_VALIDATION",
"message": "Invalid data in path: /cartId should NOT be shorter than 24 characters"
}

Error Code: 400

Message: Bad Request

Description: You will see this error when the payment is already added to the cart ID.

{
"code": "PAYMENT_CREATE_ERROR",
"message": "Unable to create payment. Payment Token already exists"
}

Error Code: 500

Message: Internal Server Error

Description: You will see this error when the payment intent is not valid.

{
"message": "No such payment_intent: 'pi_1Ij6W0Jxr7zyIFb9LGIDj1Y1'"
}

Error Code: 500

Message: Internal Server Error

Description: You will see this error when the payment intent doesn't exist.

{
"message": "payment_method does not exist"
}

Error Code: 500

Message: Internal Server Error

Description: You will see this error when the account number is incorrect in the x-site-context (for a multi-tenent client).

Change Log

  • June - 2021