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 generates a unique voucher code. After the expiration date has passed, the code is no longer valid.
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.
secretKey as a request parameter.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 shows the details of your voucher program. This includes terms & conditions, an array of products, and some top level details about the offer.
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.
To execute this operation, there are two requirements:
secretKey as a request parameter.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 will process an order. If there are any problems during validation, the order will be rejected with notes on what to correct.
After a user has selected a product, it's time to submit their order!
To execute this operation, there are several requirements:
Ocp-Apim-Subscription-Key in the request header.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
}
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
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'."]
}
}
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.
If a VoucherCode is expired, has already been redeemed, or doesn't exist, then you will run into this error.
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."
}
Make sure you use the GetCode operation to generate a unique VoucherCode for all valid users.
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.
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."
}
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!