On this page you will find information about how to Process the result and the different Purchase states through out the CheckOut session.
Processing the Result
The last step occurs when the customer finishes working with the form and there’s a result available. The client script signals this by calling the done callback function (see Showing the Check-Out Form).
The done callback doesn’t contain any information about whether the payment succeeded or not. It only signals that the customer is done working with the form. The partner site back-end must check what the actual result was. We have designed it this way as a security measure, so that the partner integrators aren’t tempted to trust the client script. Unfortunately, there’s no way to prevent malicious customers from modifying the script since it runs in their browsers.
The implementation of the done function is up to partners. However, a common scenario (unless the site is a single-page application) would be to perform a redirect to a page that verifies the result, passing the Purchase ID is a parameter in the URL:
//example of done function passed as part of the options for AvardaCheckOutClient.init function
var options = {
done: function (purchaseId) {
window.location.href = '/done.php?purchaseId=' + purchaseId;
},
};
The done.php page would then make a call to the GetPaymentStatus API function in order to check the actual result. If the payment was successful, the partner site might want e.g. to mark the order in its own database as paid and show a confirmation message to the user. If the payment wasn’t successful, the partners site should display an error message at least.
When the checkout process is completed a call to defined done method will be performed. This function normally redirects the user back to order confirmation page, before showing confirmation merchant should verify purchase details by calling GetPaymentStatus.
GetPaymentStatus
Returns information about a single purchase identified by a Purchase ID.
POST /CheckOut2Api/GetPaymentStatus
Input parameters
Name | Data Type | Default value | Description |
---|---|---|---|
PurchaseId | String | None. Must be specified | The ID obtained during the negotiation phase that identified the purchase. |
Example request
{
"PurchaseId": "19ac0d1ee909c302d212b4324d9194b5"
}
Output parameters
The method returns an object that differs if the purchase was loan, invoice, direct payment or card payment.
Name | Data Type | Description | Invoice | Loan | Card payment | Direct payment |
---|---|---|---|---|---|---|
AccountNumber | String | The bank account number associated with the payment. | ||||
InvoicingFirstName | String | The first name of the customer on the invoicing address. | ||||
InvoicingLastName | String | The last name of the customer on the invoicing address. | ||||
InvoicingAddressLine1 | String | The first line of the invoicing address. | ||||
InvoicingAddressLine2 | String | The second line of the invoicing address. | ||||
InvoicingZip | String | The ZIP code on the invoicing address. | ||||
InvoicingCity | String | The city on the invoicing address. | ||||
AccountClassCode | String | Code of account class for this purchase. | ||||
PurchaseId | String | The same Purchase ID that was passed as an input parameter. | ||||
State | Enumeration CheckOutPurchaseState | The current state of the purchase. | ||||
Description | String | The description provided by partner’s site. | ||||
Price | Decimal | The total amount to pay. | ||||
Created | DateTime | The local date and time at which the purchase has been negotiated. | ||||
BeingProcessed | Nullable DateTime | The local date and time at which the form was first rendered. Null if the form hasn’t been shown yet. | ||||
Completed | Nullable DateTime | The local date and time at which the purchase has been completed. Null if the purchase hasn’t been completed yet. | ||||
Cancelled | Nullable DateTime | The local date and time at which the purchase has been canceled. Null it the purchase hasn’t been cancelled (yet). | ||||
SiteCode | String | The code of the partner’s site at which the purchase has been made. | ||||
CountryCode | String | A three-letter ISO country code (see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3 (opens in a new tab)) associated with the partner’s site at which the purchase has been made. | ||||
CurrencyCode | String | The three-letter code of the currency in which the purchase has been made. For Example “SEK” or EUR | ||||
Phone | String | The phone number that the customer typed-in into the form. | ||||
String | The e-mail address that the customer typed-in into the form. | |||||
DeliveryFirstName | String | The first name of the customer on the delivery address. | ||||
DeliveryLastName | String | The last name of the customer on the delivery address. | ||||
DeliveryAddressLine1 | String | The first line of the delivery address. | ||||
DeliveryAddressLine2 | String | The second line of the delivery address. | ||||
DeliveryCity | String | The city of the delivery address. | ||||
DeliveryCountry | String | The country of the delivery address. | ||||
OrderReference | String | Merchant custom ID reference. | ||||
AuthenticationType | Enumeration CheckOutAuthenticationType | Type of authentication for this purchase. | ||||
PaymentMethod | Enumeration PaymentMethod | Type of payment. | ||||
IsRecurringPayment | Boolean | Differs if payment is recurring. | ||||
RecPmtToken | String | Recurring payment token. | ||||
CardExpirationDate | String | Card expiration date stored in this format “YYMM”. | ||||
MaskedCardNumber | String | Masked card number for security purpose. | ||||
CardBrand | String | Brand cards. | ||||
CustomerToken | String | Brand cards. | ||||
CustomerToken | String | Brand cards. | ||||
IsOrganization | Boolean | Differantiate B2B and B2C. | ||||
ReferenceName | String | Reference name for better handling. | ||||
CompanyName | String | Name of the company. | ||||
NewsLetterValue | Boolean | Serves for displaying the newsletter. | ||||
OfferedNewsLetterSettings | Boolean | If the value is true, newsletter is checked. | ||||
OrganizationNumber | String | Returns organization number if there is any value. | ||||
CustomerType | Enum | If CustomerType = null or 0 load both options for Private/Company. If CustomerType = 1 load only Private alternative. If CustomerType = 2 load only Company alternative. |
Purchase States
Each individual Purchase changes its state during a Check-Out session. The following diagram shows valid transitions between the states:
The states shown in green are intermediate, meaning that the purchase cannot stay in neither of them for a long time. States of all other colors are terminal. Once a purchase makes a transition into one of such states, it stays in it forever.
Enumeration States
The enumeration describes the state of a single Purchase. Please refer to the diagram in Purchase States chapter to see possible transitions between states.