Composable Frontend 2.0 Learn more 

  • Payments/
    Paying for an Order/
    Stripe

    Stripe Payments

    The Stripe integration supports the following payment methods:

    • authorize
    • capture
    • purchase
    • refund

    POST Pay by token or source

    https://useast.api.elasticpath.com/v2/orders/:orderId/payments
    

    If you are passing a source instead of a token, you must also include the Stripe customer ID in the request.

    We recommend that you use the token or source with Stripe payments. For more information about generating a token on the client-side, see the Stripe Elements documentation.

    Parameters

    Path parameters

    NameRequiredTypeDescription
    orderIdRequiredstringThe Universally Unique Identifier (UUID) of the order that you want to pay for.

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Body

    NameRequiredTypeDescription
    options.idempotency_keyOptionalstringThe option to send a Stripe Idempotency Key.
    options.receipt_emailOptionalstringThe option to provide an email for Stripe receipts. Specify live mode to access this feature.
    paymentRequiredstringThe Stripe token or source.
    options.customerOptionalstringThe Stripe customer ID. This is required if you are sending a source.
    methodRequiredstringThe required method, such as purchase or authorize.
    amountOptionalintegerSpecifies the amount to be paid for the transaction.
    gatewayRequiredstringSpecify stripe for the required gateway.

    Request examples

    Curl

    curl -X POST https://useast.api.elasticpath.com/v2/orders/:orderId/payments \
         -H "Authorization: Bearer XXXX" \
         -H "Content-Type: application/json" \
         -d $'{
            "data": {
              "gateway": "stripe",
              "method": "purchase",
              "amount": 100,
              "payment": "tok_visa",
              "options": {
                "receipt_email": "john@example.com"
              }
            }
          }
    

    JavaScript SDK

    const MoltinGateway = require('@moltin/sdk').gateway
    const Moltin = MoltinGateway({
      client_id: 'X'
    })
    const id = 'XXXX'
    const payment = {
      gateway: 'stripe',
      method: 'purchase',
      payment: 'tok_visa'
    }
    Moltin.Orders.Payment(id, payment).then(() => {
      // Do something
    })
    

    Response example

    200 OK

    {
        "data": {
            "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "type": "transaction",
            "reference": "stripe",
            "gateway": "stripe",
            "amount": 100,
            "refunded_amount": 0,
            "currency": "USD",
            "transaction-type": "purchase",
            "status": "complete",
            "relationships": {
                "order": {
                    "data": {
                        "type": "order",
                        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    }
                }
            },
            "meta": {
                "display_price": {
                    "amount": 100,
                    "currency": "USD",
                    "formatted": "$100.00"
                },
                "display_refunded_amount": {
                    "total": {
                        "amount": 0,
                        "currency": "USD",
                        "formatted": "$0.00"
                    }
                 },
                "created_at": "2019-01-31T17:20:39.378Z"
            }
        }
    }
    

    If you are passing a source instead of a token, you must also include the Stripe customer ID in the request.

    POST Pay by Stripe Connect

    https://useast.api.elasticpath.com/v2/orders/:orderId/payments
    

    Commerce also supports Stripe Connect. To access Stripe Connect, pass a destination through the options object.

    Parameters

    Path parameters

    NameRequiredTypeDescription
    orderIdRequiredstringThe UUID of the order that you want to pay for.

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Body

    NameRequiredTypeDescription
    options.destinationOptionalstringThe Stripe Connect Account ID.
    options.receipt_emailOptionalstringThe option to provide an email for Stripe receipts. Specify live mode to access this feature.
    paymentRequiredstringThe Stripe token or source.
    methodRequiredstringThe required method, such as, purchase, authorize or capture.
    amountOptionalintegerSpecifies the amount to be paid for the transaction.
    gatewayRequiredstringSpecify stripe for the required gateway.

    Request examples

    Curl

    curl -X POST https://useast.api.elasticpath.com/v2/orders/:orderId/payments \
         -H "Authorization: Bearer XXXX" \
         -d $'{
            "data": {
              "gateway": "stripe",
              "method": "purchase",
              "amount": 100,
              "payment": "tok_visa",
              "options": {
                "destination": "acct_XXX",
                "receipt_email": "john@example.com"
              }
            }
          }'
    

    JavaScript SDK

    const MoltinGateway = require('@moltin/sdk').gateway
    const Moltin = MoltinGateway({
      client_id: 'X'
    })
    const id = 'XXXX'
    const payment = {
      gateway: 'stripe',
      method: 'purchase',
      payment: 'tok_visa',
      options: {
        destination: 'acct_XXX'
      }
    }
    Moltin.Orders.Payment(id, payment).then(() => {
      // Do something
    })
    

    Response example

    200 OK

    {
        "data": {
            "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "type": "transaction",
            "reference": "stripe",
            "gateway": "stripe",
            "amount": 100,
            "currency": "USD",
            "transaction-type": "purchase",
            "status": "complete",
            "relationships": {
                "order": {
                    "data": {
                        "type": "order",
                        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    }
                }
            },
            "meta": {
                "display_price": {
                    "amount": 100,
                    "currency": "USD",
                    "formatted": "$100.00"
                },
            },
            "meta": {
                "display_price": {
                    "amount": 10000,
                    "currency": "USD",
                    "formatted": "$100.00"
                },
                "display_refunded_amount": {
                    "total": {
                        "amount": 0,
                        "currency": "USD",
                        "formatted": "$0.00"
                    }
                },
                "created_at": "2019-01-31T17:20:39.378Z"
            }
        }
    }
    
    Previous
    PayPal Express Checkout