Make a purchase

Request

Executes a purchase.

A purchase can be completed both with and without authentication. Purchases that use a pre-created payment instrument must use authentication.

To preview the purchase before completing it, use the Purchase preview operation.

Security
CustomerJWT or PublishableApiKey
Bodyapplication/json
websiteIdstring, <= 50 characters(WebsiteId)write-onlyrequired

ID of the website. A website is where an organization obtains a customer. For more information, see Obtain an organization ID and website ID.

Example:"web_0YV7DE4Z26DQSA1AC92FBJ7SEG"
itemsArray of objects, non-emptywrite-onlyrequired
billingAddressContactObject (object) or nullwrite-only
One of:

Contact's information.

deliveryAddressContactObject (object) or nullwrite-only
One of:

Contact's information.

shippingRateIdstring, <= 50 characters(ResourceId)write-only

ID of the shipping rate. If this value is not set, the cheapest applicable shipping rate is chosen.

Example:"4f6cf35x-2c4y-483z-a0a9-158621f77a21"
paymentInstructionPayment token (object) or Payment instrument (object) or Payment Methods (object) or Payment card (object) or Bank account (object)(PaymentInstruction)write-onlyrequired
One of:

Payment instruction for the purchase.

couponIdsArray of stringswrite-only

List of coupons that are applied to the order.

passwordstring or nullwrite-only

Customer account password. If this value is set, it is used to create a customer account.

redirectUrlstring or null, (uri), <= 2083 characterswrite-only

URL to redirect the end-user when an offsite transaction is completed. If website.url is https://example.com, then the redirectUrl can be set to one the following:

  • https://example.com

  • https://example.com/some/path

  • https://example.com/some/path?and=query

  • https://example.com/some/path?and=query#and-fragment

This field defaults to the configured website URL. You may use {id} or {result} as placeholders in the URL. These placeholders are replaced with the transaction ID and result.

poNumberstring or null

Purchase order number that is displayed on the invoice.

Example:"PO123456"
customFieldsobjectwrite-only

Custom fields copied to resources.

curl -i -X POST \
  https://www.rebilly.com/_mock/catalog/all/storefront/purchase \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "orderId": "4f6cf35x-2c4y-483z-a0a9-158621f77a21",
    "websiteId": "web_0YV7DE4Z26DQSA1AC92FBJ7SEG",
    "items": [
      {
        "planId": "plan_0YV7DENSVGDBW9S71XZNNYYQ0X",
        "quantity": 0
      }
    ],
    "billingAddress": {
      "firstName": "Benjamin",
      "lastName": "Franklin",
      "organization": "Rebilly",
      "address": "36 Craven St",
      "address2": "string",
      "city": "Austin",
      "region": "Texas",
      "country": "GB",
      "postalCode": "WC2N 5NF",
      "phoneNumbers": [
        {
          "label": "main",
          "value": "1-512-777-0269",
          "primary": true
        }
      ],
      "emails": [
        {
          "label": "main",
          "value": "rebilly@example.com",
          "primary": true
        }
      ],
      "dob": "1980-04-01",
      "jobTitle": "CEO"
    },
    "deliveryAddress": {
      "firstName": "Benjamin",
      "lastName": "Franklin",
      "organization": "Rebilly",
      "address": "36 Craven St",
      "address2": "string",
      "city": "Austin",
      "region": "Texas",
      "country": "GB",
      "postalCode": "WC2N 5NF",
      "phoneNumbers": [
        {
          "label": "main",
          "value": "1-512-777-0269",
          "primary": true
        }
      ],
      "emails": [
        {
          "label": "main",
          "value": "rebilly@example.com",
          "primary": true
        }
      ],
      "dob": "1980-04-01",
      "jobTitle": "CEO"
    },
    "shippingRateId": "4f6cf35x-2c4y-483z-a0a9-158621f77a21",
    "paymentInstruction": {
      "token": "string"
    },
    "couponIds": [
      "string"
    ],
    "password": "string",
    "redirectUrl": "http://example.com",
    "poNumber": "PO123456",
    "customFields": {
      "customers": {
        "foo": "bar"
      },
      "subscriptions": {
        "foo": "bar"
      },
      "transactions": {
        "foo": "bar"
      }
    }
  }'

Responses

Order created.

Headers
Locationstring, (uri)

Location of the related resource.

Example:"https://api.rebilly.com/example"
X-RateLimit-Limitinteger

Total number of rate limit tokens for this request within a rate limit period. For more information, see Rate limits.

Example:3600
X-RateLimit-Remaininginteger

Remaining number of rate limit tokens for this request within the rate limit period. For example, in the sandbox environment, rate limits for non-GET endpoints are set at 3000 requests per 10 minutes.

Example:3600
Bodyapplication/json
orderIdstring, <= 50 characters(ResourceId)read-only

ID of the order.

Example:"4f6cf35x-2c4y-483z-a0a9-158621f77a21"
invoiceobject(StorefrontInvoice)read-only

Initial invoice.

transactionobject(StorefrontTransaction)read-only

Initial transaction.

tokenstringread-only

Session token that is used for authentication. This token can be used to view the created order, invoice, and transaction.

poNumberstring or null

Purchase order number that is displayed on the invoice.

Example:"PO123456"
Response
{ "orderId": "4f6cf35x-2c4y-483z-a0a9-158621f77a21", "invoice": { "id": "in_0YVF9605RKC62BP14NE2R7V2XT", "websiteId": "web_0YV7DE4Z26DQSA1AC92FBJ7SEG", "invoiceNumber": 0, "orderId": "ord_01HVKA5975PJBSQ1SX72G3MSZC", "subscriptionId": "sub_01HRF27SATGE4Z6PBJE6PD8328", "currency": "USD", "amount": 0.1, "amountDue": 0.1, "subtotalAmount": 0.1, "discountAmount": 0.1, "shipping": {}, "tax": {}, "billingAddress": {}, "deliveryAddress": {}, "poNumber": "PO123456", "notes": "string", "items": [], "discounts": [], "autopayScheduledTime": "2019-08-24T14:15:22Z", "autopayRetryNumber": 0, "status": "draft", "delinquentCollectionPeriod": 0, "collectionPeriod": 0, "abandonedTime": "2019-08-24T14:15:22Z", "voidedTime": "2019-08-24T14:15:22Z", "paidTime": "2019-08-24T14:15:22Z", "dueTime": "2019-08-24T14:15:22Z", "issuedTime": "2019-08-24T14:15:22Z", "createdTime": "2019-08-24T14:15:22Z", "updatedTime": "2019-08-24T14:15:22Z", "paymentFormUrl": "http://example.com", "transactions": [], "_links": [] }, "transaction": { "id": "txn_0YVDTQJ8YWDGQACV2N2N5SPWQ0", "websiteId": "web_0YV7DE4Z26DQSA1AC92FBJ7SEG", "type": "3ds-authentication", "status": "completed", "result": "abandoned", "amount": 0.1, "currency": "USD", "purchaseAmount": 0.1, "purchaseCurrency": "USD", "requestAmount": 0.1, "requestCurrency": "USD", "parentTransactionId": "txn_0YVDTQJ8YWDGQACV2N2N5SPWQ0", "childTransactions": [], "invoiceIds": [], "orderIds": [], "planIds": [], "isRebill": true, "rebillNumber": 0, "billingAddress": {}, "redirectUrl": "http://example.com", "retryNumber": 0, "isRetry": true, "billingDescriptor": "string", "description": "string", "requestId": "string", "hasAmountAdjustment": true, "gatewayName": "A1Gateway", "gateway": {}, "customFields": {}, "processedTime": "2019-08-24T14:15:22Z", "createdTime": "2019-08-24T14:15:22Z", "updatedTime": "2019-08-24T14:15:22Z", "paymentInstrument": {}, "approvalUrl": "http://example.com", "hasDcc": true, "dcc": {}, "token": "string", "depositRequestId": "dep_req_0YVJ65BSGYC3EAT58SEX8KY6J7", "_links": [] }, "token": "string", "billingAddress": { "firstName": "Benjamin", "lastName": "Franklin", "organization": "Rebilly", "address": "36 Craven St", "address2": "string", "city": "Austin", "region": "Texas", "country": "GB", "postalCode": "WC2N 5NF", "phoneNumbers": [], "emails": [], "dob": "1980-04-01", "jobTitle": "CEO", "hash": "056ae6d97c788b9e98b049ebafd7b229bf852221" }, "deliveryAddress": { "firstName": "Benjamin", "lastName": "Franklin", "organization": "Rebilly", "address": "36 Craven St", "address2": "string", "city": "Austin", "region": "Texas", "country": "GB", "postalCode": "WC2N 5NF", "phoneNumbers": [], "emails": [], "dob": "1980-04-01", "jobTitle": "CEO", "hash": "056ae6d97c788b9e98b049ebafd7b229bf852221" }, "shippingRateId": "4f6cf35x-2c4y-483z-a0a9-158621f77a21", "poNumber": "PO123456" }