API OPERATIONS

GetOffer


When do I use this operation?

GetOffer is being deprecated!

GetCode and GetProducts should be used in its place.

We are still supporting this operation currently, but it won't be active forever. If you are already using the API, please update your code to use GetCode and GetProducts instead.

GetCode


What does it do?

GetCode generates a unique voucher code. After the expiration date has passed, the code is no longer valid.

When do I use this operation?

When a consumer opts in to the BPerx offer, they need to receive a unique voucher code. The voucher code should always be visible wherever the Terms & Conditions are visible.

Please be sure to only generate one voucher code per consumer. We recommend storing the data from this operation in the browser session to prevent voucher code waste.

When the time comes, you will need the VoucherCode in order to submit the order.

How do I use this operation?

To execute the request, there are two requirement:
  1. secretKey as a request parameter.
  2. Ocp-Apim-Subscription-Key in the request header.

Here is an example of the response when all inputs are satisfied:


        {
        "VoucherCode": "XXXXXXXXXXXXXXXXXXXXXXXXX",
        "ExpireDateUTC": "2019-07-11T23:51:21.3889905Z"
        }
        

GetProducts


What does it do?

GetProducts shows the details of your voucher program. This includes terms & conditions, an array of products, and some top level details about the offer.

When do I use this operation?

When a user has opted in to the BPerx promotion, this operation is used to show product offerings and details.

Make sure to present a voucher code whenever the Terms & Conditions are shown. If a voucher code is not already stored for a user who has opted in, it can be generated from the GetCode operation.

When a user select the product for redemption, you will need the ProductCode in order to submit the order. This can be found within the Products array, as a property of the user's selection.

How do I use this operation?

To execute this operation, there are two requirements:

  1. secretKey as a request parameter.
  2. Ocp-Apim-Subscription-Key in the request header.

Here is an example of the response when all inputs are satisfied:


        {
        "Description": "X",
        "TermsAndConditions": "X",
        "VoucherDollarValue": 15,
        "Products": [{
        "ProductCode": "12SQ-BP10",
        "Title": "COSMOPOLITAN DIGITAL",
        "Term": 2,
        "Issues": 22,
        "Description": "Cosmo dishes on the latest celebrity trends and entertainment.",
        "CoverImageURL": "//d2we4410owmhbo.cloudfront.net/covers/12SQ.jpg"
        }]
        }
        

PostOrder


What does it do?

PostOrder will process an order. If there are any problems during validation, the order will be rejected with notes on what to correct.

When do I use this operation?

After a user has selected a product, it's time to submit their order!

How do I use this operation?

To execute this operation, there are several requirements:

  1. Ocp-Apim-Subscription-Key in the request header.
  2. An object in the request body comprised of customer data, a SelectedProductCode chosen from one of the products in the response body of GetProducts, and a VoucherCode from the response body of GetCode.

Here is an example of the request object.


        {
        "VoucherCode": "string",
        "FullName": "string",
        "AddressLineOne": "string",
        "AddressLineTwo": "string",
        "City": "string",
        "State": "string",
        "ZipCode": "string",
        "EmailAddress": "string",
        "SelectedProductCode": "string",
        "SendConfirmationEmail": true
        }
        

From the test panel, you can see the complete schema for the request object, with all of the optional fields.

If you are sending a TrustedForm Certificate with your order, that can be included in the request body, like so:
"TrustedFormCert": "your.certificate.url"

Here is an example of the response when all inputs are satisfied:


        {
        "OrderNumber": "XXXXXXXXXX-ABC",
        "Status": "OK",
        "Message": "string",
        "ErrorMessage": "string",
        "ChargeAmount": 0.0
        }
        

COMMON ERRORS WHEN USING POSTORDER

The request is invalid


What causes this error?

This error occurs when required fields are missing, or if any of the supplied fields are not in the correct format.

The API doesn't know how to interpret something about your request

How can it be identified?

You will see a response status of 400 Bad Request.

The response body will have a Message, and in some cases a ModelState that describe the problem.

See the example below:


        {
        "Message": "The request is invalid.",
        "ModelState": {
        "orderModel.BirthMonth": ["The field BirthMonth must be a string or array type with a maximum length of '2'."],
        "orderModel.BirthDayOfMonth": ["The field BirthDayOfMonth must be a string or array type with a maximum length of '2'."],
        "orderModel.BirthYear": ["The field BirthYear must be a string or array type with a maximum length of '4'."]
        }
        }
        

How can it be fixed?

In the example above, our response body's ModelState property has identified three problematic fields.

These fields happen to be optional for the PostOrder operation, so a quick fix would be to remove these fields from the request body.

If you are determined to provide data for these fields, then make sure they adhere to the proper form. BirthMonth and BirthDayOfMonth should both be two-digit fields, while BirthYear is a four-digit field.

Supplied voucher is invalid


What causes this error?

If a VoucherCode is expired, has already been redeemed, or doesn't exist, then you will run into this error.

How can it be identified?

You will see a response status of 400 Bad Request.

The response body will have a Message letting you know you goofed up.


        {
        "Message": "Supplied voucher is invalid."
        }
        

How can it be fixed?

Make sure you use the GetCode operation to generate a unique VoucherCode for all valid users.

The selected product is not available


What causes this error?

Subdirect will occasionally update the available product sets for BPerx offers. If you have an out-dated list of products, and try to submit an order, this error can happen.

In these cases, the order will be rejected up-front.

How can it be identified?

You will see a response status of 400 Bad Request

The response body will have a Message alluding to the fact that your product list needs to be updated.


        {
        "Message": "The selected product is not available."
        }
        

How can it be fixed?

To fix this problem, you need to obtain the list of active products for your BPerx voucher program.

Using the GetProducts operation will always return the currently active, most up-to-date version of your product list! If you are hard coding the offer details, or using a cache, make sure you refresh on a regular basis!