Generating the Customer Link for E-Commerce
Step 1: Setup JSON
JSON - Structure
{
"payment_setup":
{
"email": {EMAIL},
"company_name": {COMPANYNAME},
"title": {TITLE},
"first_name": {FIRSTNAME},
"last_name": {LASTNAME},
"address_line1": {ADDRESSLINE1},
"address_line2": {ADDRESSLINE2},
"city": {CITY},
"postal_code": {POSTALCODE},
"country_code": {COUNTRYCODE},
"custom_reference": {CUSTOMREFERENCE},
"amount": {AMOUNT},
"description": {DESCRIPTION},
"auddis": {AUDDIS},
"start_date": {STARTDATE},
"end_date": {ENDDATE},
"first_collection_amount": {FIRSTCOLLECTIONAMOUNT},
"first_collection_date": {FIRSTCOLLECTIONDATE},
"APIKey": {APIKEY},
"Branding": {BRANDING},
"CustomerAccountID": {CUSTOMERACCOUNTID}
}
}
JSON - Parameters
| Property | Variable | Required | Description | Format | Example |
|---|---|---|---|---|---|
| {EMAIL} | No | Used if Customer details already known/collected. | String | “james@email.com” | |
| company_name | {COMPANYNAME} | No | Used if Customer details already known/collected. | String | “SmarterPay” |
| title | {TITLE} | No | Used if Customer details already known/collected. | String | “Mr” |
| first_name | {FIRSTNAME} | No | Used if Customer details already known/collected. | String | “James” |
| last_name | {LASTNAME} | No | Used if Customer details already known/collected. | String | “Hetfield” |
| address_line1 | {ADDRESSLINE1} | No | Used if Customer details already known/collected. | String | “Utility House” |
| address_line2 | {ADDRESSLINE2} | No | Used if Customer details already known/collected. | String | “32 36 Prospect Street” |
| city | {CITY} | No | Used if Customer details already known/collected. | String | “Hull” |
| postal_code | {POSTALCODE} | No | Used if Customer details already known/collected. | String | “HU2 8PX” |
| country_code | {COUNTRYCODE} | No | Used if Customer details already known/collected. | String | "GB" |
| custom_reference | {CUSTOMREFERENCE} | No | Used if Customer details already known/collected. | String | “CustomRef” |
| amount | {AMOUNT} | Yes | Amount in pence. | Integer | 100 |
| description | {DESCRIPTION} | No | Used to add a description to the new Schedule. | String | “Monthly Subscription” |
| auddis | {AUDDIS} | No | Used to specify an Auddis reference for the Mandate. If not provided will be generated by the system. | String | “AUD0000123” |
| start_date | {STARTDATE} | No | Used to specify a start date. If not provided will be started ASAP. | String | “2021-07-05” |
| end_date | {ENDDATE} | No | Used to specify an end date. For Payment plans and end date is calculated automatically. | String | null |
| first_collection_amount | {FIRSTCOLLECTIONAMOUNT} | No | Amount in pence. Only needed if the first payment should be for a different. | Integer | 100 |
| first_collection_date | {FIRSTCOLLECTIONDATE} | No | only needed if the first payment date should be set later than the start date. | String | “2021-07-05” |
| APIKey | {APIKEY} | Yes | Used to identify your customer as belonging to you. | string | “TEST_123456ABCDEF” |
| Branding | {BRANDING} | Yes | Used to tell the system what settings to use for the sign up process. See E-Commerce Page Setup. | string | “EP-00000010” |
| CustomerAccountID | {CUSTOMERACCOUNTID} | No | Used to lnk to an existing Customer record in the system. If provided will display the saved Name and Address for the customer. | String | “CUST001” |
Step 2: Encypt the JSON
The JSON needs to be encrypted using a key and an initialisation vector (also known as an IV )
- Create a unicode byte array from the above JSON.
- Create an AES encryption key by using a base64 decoded cart encryption key.
- Use a symmetric encryptor to create an initialisation vector (IV).
- Ecrypt the JSON byte array using the AES encryption key and the initialisation vector (IV).
Additional resource for help on this: “https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.symmetricalgorithm.createencryptor?view=net-5.0”
Step 3: Construct the URL link
- The Encrypted JSON is base64 encoded then URL encoded
- The IV is base64 encoded then URL encoded
- The encoded and encrypted parameters are then substituted in the URL placeholders: "https://ecom.smarterpaycloud.com/PaymentSetupPage.aspx?cart={JSON}&iv={IV}"
- This link can then be passed onto the customer, Usually in an email, to be clicked on etc.