Created with Sketch.
Created with Sketch.
Checkout 2.0

Confirmation

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

NameData TypeDefault valueDescription
PurchaseIdStringNone. Must be specifiedThe 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.

NameData TypeDescriptionInvoiceLoanCard paymentDirect payment
AccountNumberStringThe bank account number associated with the payment.  
InvoicingFirstNameStringThe first name of the customer on the invoicing address.
InvoicingLastNameStringThe last name of the customer on the invoicing address.
InvoicingAddressLine1StringThe first line of the invoicing address.
InvoicingAddressLine2StringThe second line of the invoicing address.
InvoicingZipStringThe ZIP code on the invoicing address.
InvoicingCityStringThe city on the invoicing address.
AccountClassCodeStringCode of account class for this purchase.
PurchaseIdStringThe same Purchase ID that was passed as an input parameter.
StateEnumeration CheckOutPurchaseStateThe current state of the purchase.
DescriptionStringThe description provided by partner’s site.
PriceDecimalThe total amount to pay.
CreatedDateTimeThe local date and time at which the purchase has been negotiated.
BeingProcessedNullable DateTimeThe local date and time at which the form was first rendered. Null if the form hasn’t been shown yet.
CompletedNullable DateTimeThe local date and time at which the purchase has been completed. Null if the purchase hasn’t been completed yet.
CancelledNullable DateTimeThe local date and time at which the purchase has been canceled. Null it the purchase hasn’t been cancelled (yet).
SiteCodeStringThe code of the partner’s site at which the purchase has been made.
CountryCodeStringA three-letter ISO country code (see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) associated with the partner’s site at which the purchase has been made.
CurrencyCodeStringThe three-letter code of the currency in which the purchase has been made. For Example “SEK” or EUR
PhoneStringThe phone number that the customer typed-in into the form.
MailStringThe e-mail address that the customer typed-in into the form.
DeliveryFirstNameStringThe first name of the customer on the delivery address.
DeliveryLastNameStringThe last name of the customer on the delivery address.
DeliveryAddressLine1StringThe first line of the delivery address.
DeliveryAddressLine2StringThe second line of the delivery address.
DeliveryCityStringThe city of the delivery address.
DeliveryCountryStringThe country of the delivery address.
OrderReferenceStringMerchant custom ID reference.
AuthenticationTypeEnumeration CheckOutAuthenticationTypeType of authentication for this purchase.
PaymentMethodEnumeration PaymentMethodType of payment.
IsRecurringPaymentBooleanDiffers if payment is recurring.
RecPmtTokenStringRecurring payment token.
CardExpirationDateStringCard expiration date stored in this format “YYMM”.   
MaskedCardNumberStringMasked card number for security purpose.   
CardBrandStringBrand cards.   
CustomerTokenStringBrand cards.
CustomerTokenStringBrand cards.
IsOrganizationBooleanDifferantiate B2B and B2C.
ReferenceNameStringReference name for better handling.
CompanyNameStringName of the company.
NewsLetterValueBooleanServes for displaying the newsletter.
OfferedNewsLetterSettingsBooleanIf the value is true, newsletter is checked.
OrganizationNumberStringReturns organization number if there is any value.
CustomerTypeEnumIf 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.