Payments/
Paying for an Order/
Braintree

Braintree Payments

The Braintree integration supports the following payment methods:

  • authorize
  • capture
  • purchase
  • refund

POST Pay by Customer ID

https://api.moltin.com/v2/orders/:orderId/payments

This method allows you to bill a specific Braintree customer. Braintree is the default billing method in the customer’s account.

Parameters

Path parameters

NameRequiredTypeDescription
order_idRequiredstringThe UUID of the order you want to pay for.

Headers

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

Body

NameRequiredTypeDescription
options.custom_fieldsOptionalstringAvailable for preconfigured custom fields in Braintree.
paymentRequiredstringThe Braintree Customer ID that you want to bill.
methodRequiredstringpurchase is the only payment method for Braintree.
gatewayRequiredstringYou use braintree in this case.

Request Examples

Curl

curl -X POST https://api.moltin.com/v2/orders/:order_id/payments \
     -H "Authorization: Bearer XXXX" \
     -d $'{
  "data": {
    "gateway": "braintree",
    "method": "purchase",
    "payment": BRAINTREE_CUSTOMER_ID
  }
}'

JavaScript SDK

Moltin.Orders.Payment('orderId', {
  gateway: "braintree",
  method: "purchase",
  payment: BRAINTREE_CUSTOMER_ID
}).then(() => {
  // Do something
});

Response example

200 OK

Returns the updated transaction if the payment is successful

{
    "data": {
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "type": "transaction",
        "reference": "braintree",
        "gateway": "braintree",
        "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"
            },
            "created_at": "2019-01-31T17:20:39.378Z"
        }
    }
}

POST Pay by Token

https://api.moltin.com/v2/orders/:orderId/payments

This endpoint allows you to pay for an order with a specific Braintree Payment Method Token. This is similar to the Customer ID payment type, but you can define a specific payment source to charge.

Parameters

Path parameters

NameRequiredTypeDescription
order_idRequiredstringThe UUID of the order you want to pay for.

Headers

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

Body

NameRequiredTypeDescription
gatewayRequiredstringYou use braintree in this case.
methodRequiredstringpurchase is the only payment method for Braintree.
paymentRequiredstringThe payment method token to charge.
options.payment_method_tokenRequiredstringYou use true in this case.
options.custom_fieldsOptionalstringAvailable for preconfigured custom fields in Braintree.

Request example

Curl

curl -X POST https://api.moltin.com/v2/orders/:order_id/payments \
     -H "Authorization: Bearer XXXX" \
     -d $'{
  "data": {
    "gateway": "braintree",
    "method": "purchase",
    "payment": BRAINTREE_PAYMENT_METHOD_TOKEN,
    "options": {
        "payment_method_token": true
    }
  }
}'

JavaScript SDK

Moltin.Orders.Payment('orderId', {
  gateway: "braintree",
  method: "purchase",
  payment: BRAINTREE_CUSTOMER_ID,
  options: {
      payment_method_token: BRAINTREE_PAYMENT_METHOD_TOKEN
  }
}).then(() => {
  // Do something
});

Response example

200 OK

Returns the updated transaction if the payment is successful.

{
  "data": {
    "id": "5c3eeef0-a5f4-4d04-b990-822521e8604d",
    "type": "transaction",
    "reference": "cz7dekqq",
    "gateway": "braintree",
    "amount": 10000,
    "currency": "GBP",
    "transaction-type": "purchase",
    "status": "complete",
    "relationships": {
      "order": {
        "data": {
          "type": "order",
          "id": "551ba7c2-7658-4abe-a530-6de0f6095010"
        }
      }
    },
    "meta": {
      "display_price": {
        "amount": 10000,
        "currency": "GBP",
        "formatted": "£100.00"
      },
      "created_at": "2019-07-02T10:05:42.11Z"
    }
  }
}

POST Pay by Nonce

https://api.moltin.com/v2/orders/:orderId/payments

This endpoint allows you to pay for an order with a previously created Braintree Payment Method Nonce.

Parameters

Path parameters

NameRequiredTypeDescription
order_idRequiredstringThe UUID of the order you want to pay for.

Headers

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

Body

NameRequiredTypeDescription
gatewayRequiredstringYou use braintree in this case.
methodRequiredstringpurchase is the only payment method for Braintree.
paymentRequiredstringThe Braintree Payment Nonce ID.
options.payment_method_nonceRequiredbooleanSet this to true.
options.custom_fieldsOptionalstringAvailable for preconfigured custom fields in Braintree.

Request example

curl -X POST https://api.moltin.com/v2/orders/:order_id/payments \
     -H "Authorization: Bearer XXXX" \
     -d $'{
  "data": {
    "gateway": "braintree",
    "method": "purchase",
    "payment": BRAINTREE_PAYMENT_NONCE,
    "options": {
        "payment_method_nonce": true
    }
  }
}'

Response example

200 OK

Returns the updated transaction if the payment is successful.

{
    "data": {
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "type": "transaction",
        "reference": "braintree",
        "gateway": "braintree",
        "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"
            },
            "created_at": "2019-01-31T17:20:39.378Z"
        }
    }
}

Was this helpful?

Previous
Authorize.net

Learn

Docs