Subscription Creation via Purchase POST
When any user completes checkout, Ordergroove needs to be notified about this event. You will send a secure HTTP POST that provides Ordergroove with the necessary information to create one or more subscriptions on our servers. Ordergroove expects a purchase POST regardless of whether or not the customer is checking out with a subscription item. If there is a subscription item, Ordergroove will create a new subscription and allow the customer to begin managing it. If there is no subscription item, Ordergroove will log the OG cart session as a non-subscription checkout and clear the cart session.
Required for All Checkouts
Ordergroove requires that every checkout from your store results in a purchase POST, whether or not it contains a subscription. Critical analytics data for subscription conversion and program efficacy depend on this data to provide a complete picture of your subscription program’s performance. Please test and confirm that all checkouts are sending purchase POSTs to Ordergroove.
Request Structure
Destination
- Staging:
https://staging.sc.ordergroove.com/subscription/create - Production:
https://sc.ordergroove.com/subscription/create
API Keys
-
Staging:
https://rc3.stg.ordergroove.com/keys/ -
Production:
https://rc3.ordergroove.com/keys/ -
All fields in the request are required for Ordergroove’s subscription creation validation unless noted as optional.
-
If you choose not to send
cc_exp_dateandcc_type(which are optional), you will not be able to use Ordergroove’s credit card expiring soon email notifications. -
Any requests made to the Ordergroove servers from your application should be accompanied with a 5-second timeout. In the event that Ordergroove is unavailable, your application should be able to continue to run seamlessly.
-
Each string in the body of the POST must be URL encoded. Do not URL encode the entire POST, and do not URL encode the authorization headers.
Building the Products Array
If you are using Ordergroove’s JavaScript-injected offers, you can call OG.getOptins() which will return everything you need to place within the products array. If you are hosting your own enrollment experience, you will need to construct the products array as shown in the example above.
Additional Purchase POST Objects
subscription_info
first_order_place_date— Defines when the first recurring order will be placed for this subscription.extra_data— Any information you want stored at the subscription level and passed back at the time of order placement.components— Sets components within a legacy bundle subscription.multi_item_bundle_components— Creates a new bundle subscription. Multiple bundle items will be linked to this subscription. The subscription product should be a bundleproduct_typewhile the products in the array should be standard products.subscription_type— If set toprepaid, creates a prepaid subscription. Also requiresprepaid_orders_per_billingto define how many orders were paid for:
tracking_override
product— Allows you to define a different product for the subscription to be created against (use case: buy X, subscribe to Y).
Example
This example highlights all of the additional objects above and where they live within the products array:
Additional Information
See the Purchase POST API Endpoint for more information about request body parameters.
Purchase POST Responses
If a successful connection is made, the request will always result in a secure HTTP response with code 200, 201, or 206 and a JSON payload.
Success — Request Received
Error Responses
Given the amount of data provided and the order in which the payload is validated and created, there will be instances where a 207, 400, 401, or 409 status is returned. In these cases, the customer, shipping, and payment Ordergroove IDs will be provided as they were created, even if there was an issue with some or all products in the request.
207— Request contained multiple subscriptions and some were successfully created while others were not.400— Invalid request. No subscriptions were created. Provides details about what was missing or invalid.401/403— Authentication failed.409— Conflict: a request with the givenmerchant_order_idwas already received and processed.
If there are errors, they will appear in the errors object of the response. Some examples:
Error Logging and Retry Logic
It is recommended that you set up email notifications for 400, 401, 403, and 409 error responses. If an issue can be identified and corrected within 24 hours, the POST should be resent to Ordergroove. If multiple POSTs are returning the same response, it likely points to a larger integration issue that should be investigated. Any retries of 409 responses will need the merchant_order_id field modified.
For 500-level errors, re-send the POST up to 3 times within the next 10 minutes. If there is still no successful connection, retry again after 24 hours. After 24 hours, no further retries should be attempted as the contents of the customer’s cart are no longer reliable.