Custom Platform and Headless Subscription Implementation
When using Ordergroove’s offers in a headless environment, you’ll need to read the subscription selections the customer is making throughout their purchase journey and set those selections within the cart the customer will be completing checkout through.
Requirements
Follow the standard tagging instructions for your e-commerce site as outlined in the integration guide. Be sure to tag your cart platform as well.
Examples
When a customer opts in to a subscription on a page and they then add that item to the cart, you can read the frequency and subscription opt in state by using the following JavaScript:
When you write the items from your headless page to where your cart is hosted, you’ll want to be sure to create a local storage object called OG_STATE on your cart page. Make sure to make updates to this object any time a customer makes changes between the headless platform and the cart platform.
OG STATE Object
Object Structure
Sample with Data
Frequency Mapping
- Frequency Every: ex: 1, 2, 3, etc.
- Frequency Period: ex: 1 = days, 2 = weeks, 3 = months
Purchase POST (with Subscription Verification)
The Purchase POST will include an additional field (processed) to mark the subscription as pending verification. This will hold the subscription in a pending state until you have the final notification that it is complete.
- A value of
trueindicates that the subscription should be created right away, and should also be used for non-subscription checkouts. - A value of
falseindicates that the verification is pending and the subscription will not be created until the subscription has been verified. To verify a subscription — and thereby allow its creation — theprocessedfield must be set totruethrough the use of this API.
The Purchase POST requires the use of the Content-type and Authorization headers.
Subscription Verification
This API should be used when the field processed is included in the subscription creation POST with a value of false. A value of true indicates that the subscription should be created right away, or that there were no subscription items in the customer’s cart. A value of false indicates verification is pending — the subscription will not be created until it has been verified by setting processed to true.
Destination
- Staging:
https://staging.sc.ordergroove.com/subscription/verify - Production:
https://sc.ordergroove.com/subscription/verify
Request Type: GET or POST
Request Structure (HMAC)
Possible HTTP Responses
Response Code 200:
SUCCESS<Merchant> subscription request with merchant_order_id <merchant order id> does not exist<Merchant> subscription request with merchant_order_id <merchant order id> has already been transmittedInvalid Merchant— The merchant id provided does not exist
Response Code 400:
order id is required— a merchant order id was not passed inAuthentication failedInvalid Merchant <MERCHANT_ID>Merchant ID must be stringInvalid action— an action other thanprocessordeclinewas supplied
Order Verification
If you need more time to receive order notification and a final status when Ordergroove submits future orders via API, you can implement Order Verification as described below.
This API should be used in conjunction with the 010 error response code returned during order placement. The 010 code indicates the order has been created and is currently processing. While you verify the order, Ordergroove will hold it in the processing state. Once the order has been processed via this API, the order will enter a final status in the Ordergroove system and a notification will be sent to the customer if configured.
Your initial response when we place an order via API should look like the following:
Destination
- Staging:
https://staging.v2.ordergroove.com/order/verify - Production:
https://api.ordergroove.com/order/verify
Request Type: POST
Request Variables
merchant_id— string — public ID of the merchantorders— array of objects:order_id— string — the order ID originally provided to Ordergroove at order placementstatus— string — updated status of the order:000— success010— created and processing020— invalid, order not created030— canceled100— invalid credit card type110— invalid credit card number120— invalid credit card expiration date130— invalid billing address140— payment declined999— order processing issue – retry later
message— string — optional message supporting/describing the provided status
Example Request
Response
The response is a JSON object consisting of:
status— string — defines the overall result:000— complete success001— partial success002— fatal error
orders— array of objects:order_id— string — the order ID originally provided at order placementresult— string —"success"or"error"message— string — optional message describing the result
Example Response
In the event of a 002 (fatal error) response, there will be no orders key — instead an error_object key will provide more details about the system failure. This error will be emailed to Ordergroove administrators at the time it occurs.
Error Messages
Order does not existUnknown status code providedOrder not in 'Processing' status