Skip to content

JS SDK Documentation

Classes

IAltaPay

This is the entry point to interact with AltaPay Checkout API.

AltaPayFactory

AltaPayFactory is an object that provides helper functions to create AltaPay SDK objects

CustomerBuilder

Provides helper functions to create Customer objects

OrganisationBuilder

Provides helper functions to create Organisation objects

CallbacksBuilder

Provides helper functions to create Callbacks objects

ConfigurationBuilder

Provides helper functions to create Configuration objects.

AgreementBuilder

Provides helper functions to create Agreement objects.

AltaPayPaymentMethodFactory

Provides helper functions to create payment specific JS handlers

IAltaPayMethodHandler

Provides wrapper for JS based payment methods.

IAltaPay

AltaPay checkout session object that orchestrates checkout and payment process. This is the entry point to interact with AltaPay Checkout API. For more details and examples please check out Checkout API Docs

Kind: global class

init(token, sessionId) ⇒ IAltaPay

Initialize the AltaPay Object that will manage the checkout session for the customer.

AltaPay object works as a builder pattern allowing merchant to configure all the details of the customer's checkout session. It can be configured with order details and payment processing callbacks.

Once setup is completed, payment methods available for given checkout session will be loaded asynchronously when injectPaymentMethods is called.

Kind: instance method of IAltaPay

Param Type Description
token string JWT token that corresponds to merchant account used to authenticate current checkout session
sessionId string (optional) ID of the existing session that is meant to be loaded, if omitted new checkout session will be created

reset() ⇒ IAltaPay

Resets the state of AltaPay object, cancelling all the background processing and clearing the configuration.

This method would be useful for handling customer stepping back from checkout on one-page web application where you don't reload the page and our checkout session is still open.

Kind: instance method of IAltaPay

closePayment() ⇒ IAltaPay

Stops processing of the current payment by AltaPay SDK and closes opened payment window.

Please note that it is not cancelling nor reverting any payment action already taken by the customer!

Kind: instance method of IAltaPay

initFromQR(qrCodeData) ⇒ IAltaPay

Initialize the AltaPay Object that will manage the checkout session for the customer using a QR code.

AltaPay object works as a builder pattern allowing a merchant to configure all the details of the customer's checkout session. It can be configured with order details and payment processing callbacks.

Once setup is completed, payment methods available for a given checkout session will be loaded asynchronously when injectPaymentMethods is called.

Kind: instance method of IAltaPay

Param Type Description
qrCodeData string base64 encoded data extracted from QR code

setOrder(order) ⇒ IAltaPay

Saves customer order into checkout session.

Before we can proceed with the payment, customer's order details need to saved to the checkout session.

Kind: instance method of IAltaPay
Returns: IAltaPay - AltaPay checkout session object with order assigned.

Param Type Description
order Order that should be processed within this checkout session. Please use AltaPayFactory#getOrder in order to create and customize your order. See AltaPayFactory for more details on how to construct valid order objects.

setCallbacks(callbacks) ⇒ IAltaPay

Saves callbacks to be executed for the payment processing results.

Kind: instance method of IAltaPay
Returns: IAltaPay - AltaPay checkout session object with callbacks assigned.

Param Type Description
callbacks Callbacks defines callback operations on payment processing results. Please use AltaPayFactory#getCallbacksBuilder in order to create and customize your callbacks.

setConfiguration(configuration) ⇒ IAltaPay

Saves configuration to the checkout session.

Kind: instance method of IAltaPay
Returns: IAltaPay - AltaPay checkout session object with configuration assigned.

Param Type Description
configuration Configuration Defines configuration for the checkout session used when initiate the payment. Please use AltaPayFactory#getConfigurationBuilder in order to create and customize your configuration.

onRenderPaymentMethodCallback(callback) ⇒ IAltaPay

Save the callback function to customize the Payment Method rendering.

After the customer is redirected to your page, and you initiated the AltaPay session and inject payment methods, the AltaPay checkout SDK solution will trigger the handler function provided in onRenderPaymentMethodCallback for every Payment Method. The handler function have to return the customized HTMLElement

Kind: instance method of IAltaPay
Returns: IAltaPay - AltaPay checkout session object with on render callback assigned.

Param Type Description
callback RenderPaymentMethodCallbackFunction defines handling function which will be called by AltaPay SDK to get the custom rendering of Payment Method.

injectPaymentMethods(parentHtmlElement) ⇒ Promise<IAltaPay>

Inject available payment methods into provided parentHtmlElement.

This is a terminal method that finishes configuration of the IAltaPay session object. In order to load proper set of payment methods, all the configuration jobs that happen asynchronously must be finished. Once session is fully configured, it loads, validates payment methods available and render them under parentHtmlElement provided.

Warning: calling this method clears the child elements of parentHtmlElement, so make sure that HTML element provided is meant to contain only payment methods.

Merchants can use JavaScript Promise to control user experience by introducing loading indications

Kind: instance method of IAltaPay
Returns: Promise<IAltaPay> - promise indicating that function is waiting for async configuration to finish.

Promise will be fulfilled when configuration is complete and payment methods are loaded, validated and rendered.

Promise will be rejected if session not initialized or error occurs during payment methods injection.

Param Type Description
parentHtmlElement HTMLElement parent HTML element under which payment methods will be rendered

injectQR(parentHtmlElement, qrReturnUrl) ⇒ Promise<IAltaPay>

Inject the QR code for transferring the payment onto a mobile device into provided parentHtmlElement.

Warning: calling this method clears the child elements of parentHtmlElement, so make sure that the HTML element provided is meant to contain only payment methods.

Merchants can use JavaScript Promise to control user experience by introducing loading indications

Kind: instance method of IAltaPay
Returns: Promise<IAltaPay> - promise indicating that function is waiting for async configuration to finish. Promise will be fulfilled when the configuration is complete, and payment methods are loaded, validated and rendered. Promise will be rejected if the session is not initialized or an error occurs during payment methods injection.

Param Type Description
parentHtmlElement HTMLElement parent HTML element under which payment methods will be rendered. We accept <div> or <img>. If you provide <div> we will create <img> element with QR code inside it. Otherwise we will user <img> element provided.
qrReturnUrl string URL which the qr code should point to. This URL should be a regular checkout page
that will present the order details to the customer and allow the customer to select a payment method and complete the payment.

initiatePayment(config) ⇒ Promise.<IAltaPay>

Initiate payment method.

This method is starting payment process. Before it can be used, it requires:

Depending on the selected payment methods it will orchestrate finalizing the payment in different way.

Kind: instance method of IAltaPay
Returns: Promise.<IAltaPay> - promise indicating that function is waiting for async process to finish. Promise will be fulfilled when payment is processed. Promise will be rejected if no payment method is selected or error occurs during payment initialization.

Param Type Description
config string optional advanced parameters allowing to specify some extra parameters for payment initialisation.
You can pass object (recommended)
{ paymentMethodId, paymentDisplayComponent }
or string representing paymentMethodId (legacy)

- paymentDisplayComponent is used for embedding payment form into your website HTML component
- paymentMethodId is used for initialisation when payment method is selected on the backend service.
It is recommended to rely on AltaPay JS SDK to select payment method in general use cases.

handleRedirectData(redirectData) ⇒ Promise<IAltaPay>

Handle redirect data to verify payment status after being redirected back from 3rd party payment page.

After the customer is redirected to your page, and you initiated the AltaPay session and set the new callbacks on the session you have to handle the redirect data. Once the redirect data are submitted, the AltaPay checkout SDK solution will trigger the callback function right after the payment is finalized.

Kind: instance method of IAltaPay
Returns: Promise<IAltaPay> - promise indicating that function is waiting for async process to finish.

Promise will be fulfilled when existing session is loaded and IAltaPay started listening to payment status changes.

Promise will be rejected if requested session or payment is not existing or paymentID was not provided in redirectData.

Param Type Description
redirectData string base64 encoded data received as query parameter on redirectUrl

AltaPayFactory

AltaPayFactory is an object that provides helper functions to create AltaPay SDK objects

Kind: global class

getAddress(street, city, country, zipCode) ⇒ Address

Helper function to create a ready to use Address object.

Kind: instance method of AltaPayFactory

Param Type
street string
city string
country string
zipCode string

Example

AltaPayFactory.getAddress('Gyngemose Parkvej 50', 'Soeborg', 'DK', '2860')

getCustomer(firstName, lastName, email, phoneNumber, billingAddress, shippingAddress) ⇒ Customer

Helper function to create a ready to use Customer object.

Kind: instance method of AltaPayFactory
Returns: Customer - ready to use customer object that can interact with AltaPay Checkout API.

Param Type Description
firstName string of the customer
lastName string of the customer
email string of the customer
phoneNumber string of the customer without spaces. This must include the country code. You can prefix the code with + (e.g. +446721846), or 00 (e.g. 00446721846), or omit the prefix (e.g. 446721846).
billingAddress Address that will be used for payment processing, use getAddress to create this object
shippingAddress Address that will be used for shipment processing, use getAddress to create this object
transactionInfo {string:string} Optional. This is a one-dimensional associative array, where you can put any value that you would like to associate with the payment and will be propagated as a parameter to your callbacks

Example

AltaPayFactory.getCustomer(
    'John',
    'Doe',
    'example@email.com',
    '+4560020030',
    AltaPayFactory.getAddress('Gyngemose Parkvej 50', 'Soeborg', 'DK', '2860'),
    AltaPayFactory.getAddress('Gyngemose Parkvej 50', 'Soeborg', 'DK', '2860'),
    {'baseketId': 'abc123'}
)

getCustomerBuilder() ⇒ CustomerBuilder

Helper function to create CustomerBuilder used to configure Customer. See CustomerBuilder JSDoc for more details on how to use it to configure Customer

Kind: instance method of AltaPayFactory
Returns: CustomerBuilder - builder object used to specify the customer details

getOrganisationBuilder() ⇒ OrganisationBuilder

Helper function to create OrganisationBuilder used to configure Organisation. See OrganisationBuilder JSDoc for more details on how to use it to configure Organisation

Kind: instance method of AltaPayFactory
Returns: OrganisationBuilder - builder object used to specify the organisation details

getAmount(value, currency) ⇒ Amount

Helper function to create a ready to user Amount object.

Kind: instance method of AltaPayFactory
Returns: Amount - ready to use amount object that can interact with AltaPay Checkout API.

Param Type Description
value string representing price
currency string currency associated with the price // TODO: @Refactor("should we have validation on JS side here or some enum?")

Example

AltaPayFactory.getAmount(30098.52, 'DKK')

getOrderLine(itemId, description, quantity, unitPrice) ⇒ OrderLine

Helper function to create a ready to use OrderLine object.

Kind: instance method of AltaPayFactory
Returns: OrderLine - ready to use order line that can interact with AltaPay Checkout API.

Param Type Description
itemId string identifier of order item
description string short description of order item
quantity number amount of a given item
unitPrice number unit price

Example

AltaPayFactory.getOrderLine('123981239', 'Lomi 2-person sofa', 1, 28010.50)

getOrderLineBuilder(itemId, description, quantity, unitPrice) ⇒ OrderLineBuilder

Helper function to create OrderLineBuilder used to configure OrderLine.

Kind: instance method of AltaPayFactory
Returns: OrderLineBuilder - builder object used to configure order line for the checkout session.

Param Type Description
itemId string identifier of order item
description string short description of order item
quantity number amount of a given item
unitPrice number unit price

Example

AltaPayFactory.getOrderLineBuilder('123981239', 'Lomi 2-person sofa', 1, 28010.50);

See OrderLineBuilder JSDoc for more details on how to use it to configure optional fields of OrderLine

getOrder(orderId, amount, orderLines, customer) ⇒ Order

Helper function to create a ready to use Order object.

Kind: instance method of AltaPayFactory
Returns: Order - ready to use order that can interact with AltaPay Checkout API.

Param Type Description
orderId string shop order identifier
amount Amount amount of money to be paid for order in the specific currency, use getAmount to create this object
orderLines Array.<OrderLine> list of order lines (items in the cart) that constitutes the order, use getOrderLine to create this object
customer Customer data required to process the payment for the order, use getCustomer to create this object

Example

AltaPayFactory.getOrder(
    'testOrderId',
    AltaPayFactory.getAmount(30098.52, 'DKK'),
    [
        AltaPayFactory.getOrderLine('123981239', 'Lomi 2-person sofa', 1, 28010.50),
        AltaPayFactory.getOrderLine('123981240', 'Delivery', 1, 2078.02)
    ],
    AltaPayFactory.getCustomer(
        'John',
        'Doe',
        AltaPayFactory.getAddress('Gyngemose Parkvej 50', 'Soeborg', 'DK', '2860'),
        AltaPayFactory.getAddress('Gyngemose Parkvej 50', 'Soeborg', 'DK', '2860')
    )
)

getCallbacksBuilder() ⇒ CallbacksBuilder

Helper function to create CallbacksBuilder used to configure Callbacks. See CallbacksBuilder JSDoc for more details on how to use it to configure Callbacks

Kind: instance method of AltaPayFactory
Returns: CallbacksBuilder - builder object used to configure callbacks for the checkout session.

getConfigurationBuilder() ⇒ ConfigurationBuilder

Helper function to create ConfigurationBuilder used to create the Configuration

See ConfigurationBuilder JSDoc for more details on how to use it to create the Configuration

Kind: instance method of AltaPayFactory
Returns: ConfigurationBuilder - builder object used to create the configuration for the checkout session.

getAgreementBuilder() ⇒ AgreementBuilder

Helper function to create AgreementBuilder used to create the Agreement

See AgreementBuilder JSDoc for more details on how to use it to create the Agreement

Kind: instance method of AltaPayFactory
Returns: AgreementBuilder - builder object used to create the agreement for the checkout session.

getAltaPayEvent(type, paymentId, shopOrderId, status, errorMessage, errorDetails) ⇒ AltaPayEvent

Helper function to create AltaPayEvent object.

Kind: instance method of AltaPayFactory
Returns: AltaPayEvent - ready to use event that can interact with AltaPay Checkout API.

Param Type Description
type EventType of the event - currently available: PAYMENT, RENDERING
paymentId string|null indicating which payment this event is referring to
shopOrderId string indicating which customer's order this event is referring to
status string overall status of the payment process
errorMessage string|null additional error message that describes more details about the event
errorDetails ErrorDetails|null additional error details

Example

AltaPayFactory.getAltaPayEvent(
    EventType.PAYMENT,
    "dce40b43-13db-4307-8013-b41aa8f2a605",
    "1231/2023",
    PaymentStatus.SUCCEEDED,
    null,
    null
)
AltaPayFactory.getAltaPayEvent(
    EventType.RENDERING,
    null,
    "1231/2023",
    PaymentStatus.ERROR,
    "No payment methods available.",
    null
)
AltaPayFactory.getAltaPayEvent(
    EventType.RENDERING,
    null,
    "1231/2023",
    PaymentStatus.ERROR,
    "No payment methods available.",
    {
        merchantErrorMessage: "No payment methods available. Please verify your payment methods configuration.",
        merchantErrorCode: 163999,
        customerErrorMessage: "No payment methods available.",
        customerMessageMustBeShown: false
    }
)

OrderLineBuilder

OrderLineBuilder is an object that provides helper functions to create OrderLine SDK objects

Kind: global class

setUnitCode(value) ⇒ OrderLineBuilder

Helper function to set the unit code used to describe the quantity, e.g. kg, pcs, etc. If defined the value has to be 1-8 characters.

Kind: instance method of OrderLineBuilder

Param Type Description
value string Unit code used to describe the quantity.

Example

orderLineBuilder.setUnitCode('pcs')

setTaxPercent(value) ⇒ OrderLineBuilder

Helper function to set the tax rate of the order line. Non-negative value representing the tax rate in percent.

Kind: instance method of OrderLineBuilder

Param Type Description
value number Tax rate of the order line.

Example

orderLineBuilder.setTaxPercent(23.00)

setTaxAmount(value) ⇒ OrderLineBuilder

Helper function to set the total tax on an order line, before any discounts are applied. It is recommended to use taxAmount if possible. If you provide both taxPercent and taxAmount, the amount takes precedence. Must be a non-negative number if provided.

Kind: instance method of OrderLineBuilder

Param Type Description
value number Tax amount of the order line.

Example

orderLineBuilder.setTaxAmount(200.00);

setDiscountPercent(value) ⇒ OrderLineBuilder

Helper function to set the order line's discount in percent. Must be a non-negative number if provided.

Kind: instance method of OrderLineBuilder

Param Type Description
value number The order line's discount in percent. Must be a non-negative number if provided.

Example

OrderLineBuilder.setDiscountPercent(13.00)

setGoodsType(value) ⇒ OrderLineBuilder

Helper function to set type of the goods described in order line. Goods type must be up to 255 characters long.

Kind: instance method of OrderLineBuilder

Param Type Description
value string Type of the goods described in order line. Goods type must be up to 255 characters long.

Example

OrderLineBuilder.setGoodsType('SHIPMENT')

setImageURL(value) ⇒ OrderLineBuilder

Helper function to set URL to the image of the item. It will be displayed on the payment summary pages for providers that supports it (e.g. Klarna). Max length is 1024 characters.

Kind: instance method of OrderLineBuilder

Param Type Description
value string URL to the image of the item.

Example

OrderLineBuilder.setImageURL('htpps://example.com/image.png')

build() ⇒ OrderLine

Helper function to build the OrderLine object.

Kind: instance method of OrderLineBuilder

Example

OrderLineBuilder.build()

CustomerBuilder

Provides helper functions to create Customer objects

Kind: global class

setFirstName(value) ⇒ CustomerBuilder

Helper function to set the first name of a customer.

Kind: instance method of CustomerBuilder

Param Type
value string

Example

customerBuilder.setFirstName('John');

setLastName(value) ⇒ CustomerBuilder

Helper function to set the last name of a customer.

Kind: instance method of CustomerBuilder

Param Type
value string

Example

customerBuilder.setLastName('Kowalsky');

setEmail(value) ⇒ CustomerBuilder

Helper function to set the email address of a customer.

Kind: instance method of CustomerBuilder

Param Type
value string

Example

customerBuilder.setEmail('email@test.com');

setPhoneNumber(value) ⇒ CustomerBuilder

Helper function to set the phone number of a customer.

Kind: instance method of CustomerBuilder

Param Type
value string

Example

customerBuilder.setPhoneNumber('+4512345678');

setBillingAddress(value) ⇒ CustomerBuilder

Helper function to set the billing address of a customer.

Kind: instance method of CustomerBuilder

Param Type
value Address

Example

customerBuilder.setBillingAddress(AltaPayFactory.getAddress('Gyngemose Parkvej 50', 'Soeborg', 'DK', '2860'));

setShippingAddress(value) ⇒ CustomerBuilder

Helper function to set the shipping address of a customer.

Kind: instance method of CustomerBuilder

Param Type
value Address

Example

customerBuilder.setShippingAddress(AltaPayFactory.getAddress('Gyngemose Parkvej 50', 'Soeborg', 'DK', '2860'));

setBirthdate(value) ⇒ CustomerBuilder

Helper function to set the birthdate of a customer.

Kind: instance method of CustomerBuilder

Param Type
value string in format of yyyy-MM-dd, example: 1990-03-22

Example

customerBuilder.setBirthdate('1990-03-22');

setUsername(value) ⇒ CustomerBuilder

Helper function to set the username of a customer.

Kind: instance method of CustomerBuilder

Param Type
value string

Example

customerBuilder.setUsername('testUsername');

OrganisationBuilder

Provides helper functions to create Organisation objects

Kind: global class

setName(value) ⇒ OrganisationBuilder

Helper function to set the organisation name.

Kind: instance method of OrganisationBuilder

Param Type
value string

Example

organisationBuilder.setName('Rich Company Ltd');

setEntityType(value) ⇒ OrganisationBuilder

Helper function to set the organisation entity type.

Kind: instance method of OrganisationBuilder

Param Type
value OrganisationType

Example

organisationBuilder.setEntityType('LTD');

setNumber(value) ⇒ OrganisationBuilder

Helper function to set the organisation registration number.

Kind: instance method of OrganisationBuilder

Param Type
value string

Example

organisationBuilder.setNumber('2317244');

setVatId(value) ⇒ OrganisationBuilder

Helper function to set the organisation VAT id.

Kind: instance method of OrganisationBuilder

Param Type
value string

Example

organisationBuilder.setVatId('RO36247456');

getOrganisation(name, entityType, number, vatId) ⇒ Organisation

Helper function to create a ready to use Organisation object.

Kind: instance method of AltaPayFactory

Param Type
name string
entityType OrganisationType
number string
vatId string

Example

AltaPayFactory.getOrganisation('Your Company Ltd', OrganistionType.LTD, '32624-42374', 'RO3272474')

CallbacksBuilder

CallbacksBuilder is an object that provides helper functions to create Callbacks SDK objects

Kind: global class

setSuccess(value) ⇒ CallbacksBuilder

Helper function to set the success callback URL or JS function.

Kind: instance method of CallbacksBuilder

Param Type
value URL as string or function

Example

CallbacksBuilder.setSuccess('http://your-company.com/success')
CallbacksBuilder.setSuccess(function (altapayEvent) {
    // handle successful payment
})

setFailure(value) ⇒ CallbacksBuilder

Helper function to set the failure callback URL or JS function.

Kind: instance method of CallbacksBuilder

Param Type
value URL as string or function

Example

CallbacksBuilder.setFailure('http://your-company.com/failure')
CallbacksBuilder.setFailure(function (altapayEvent) {
    // handle successful payment
})

setRedirectUrl(value) ⇒ CallbacksBuilder

Helper function to set the redirect callback URL.

Kind: instance method of CallbacksBuilder

Param Type
value URL as string

Example

CallbacksBuilder.setRedirectUrl('http://your-company.com/redirect')

setNotificationUrl(value) ⇒ CallbacksBuilder

Helper function to set the notification callback URL.

Kind: instance method of CallbacksBuilder

Param Type
value URL as string

Example

CallbacksBuilder.setNotificationUrl('http://your-company.com/notification')

bodyFormat(value) ⇒ CallbacksBuilder

Helper function to set the data format of the callback data.

Kind: instance method of CallbacksBuilder

Param Type
value BodyFormat as string (JSON or XML)

Example

CallbacksBuilder.setBodyFormat('JSON')

setFormStylingUrl(value) ⇒ CallbacksBuilder

Helper function to set the payment styling form callback URL.

Kind: instance method of CallbacksBuilder

Param Type
value URL as string

Example

CallbacksBuilder.setFormStylingUrl('http://your-company.com/formStyling')

build() ⇒ Callbacks

Helper function to build the Callbacks object.

Kind: instance method of CallbacksBuilder

Example

CallbacksBuilder.build()

ConfigurationBuilder

ConfigurationBuilder is an object that provides helper functions to create Configuration SDK objects

Kind: global class

setTypePayment() ⇒ ConfigurationBuilder

Helper function to configure the session to work with PAYMENTS or AGREEMENTS.

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.setTypePayment()

setAgreement() ⇒ ConfigurationBuilder

Helper function to configure the session to work with a given type of AGREEMENT.

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.setAgreement()

setAutoCapture(value) ⇒ ConfigurationBuilder

Helper function to configure the session to capture the payment directly when customer pay for the goods.

Kind: instance method of ConfigurationBuilder

Param Type
value true or false

Example

ConfigurationBuilder.setAutoCapture(true)

setCcToken(value) ⇒ ConfigurationBuilder

Helper function to configure the Credit Card Token to automatically fill the credit card form.

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.setCcToken('U3kSorzbIP11kgMwTqs7F3lhZlfpf4F6NWvz5fo0OGLKUGO9OviTppM4mIWaOBRlbI8Sr8pWK1U3ZP1rEXAOJA==+1')

setShopName(value) ⇒ ConfigurationBuilder

Helper function to configure a shop name which is then used to limit the payment methods to the ones related with the given shop.

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.setShopName('Candy Shop')

setCountry(value) ⇒ ConfigurationBuilder

Helper function to configure the country code that is used for payment method filtering. Must be ISO 3166-1 alpha-2 code.

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.setCountry('DK')

setLanguage(value) ⇒ ConfigurationBuilder

Helper function to configure a language which is used to display the payment methods and payment forms in the desired language. It might be used by merchant to override the language of the browser in order to keep their page and payment forms in the same language.

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.setLanguage('en')

setPaymentDisplayType(value) ⇒ ConfigurationBuilder

Helper function to configure how payment form should be displayed. It could be either:

  • REDIRECT if you want to open payment form in the new page, or
  • SCRIPT if you want to open payment form on your page dynamically (if allow by selected payment method)

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.setPaymentDisplayType('REDIRECT')

setPaymentDisplayComponent(value) ⇒ ConfigurationBuilder

Helper function to configure where payment form should be displayed. It should contain ID of HTML element that is present on your website.

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.setPaymentDisplayComponent('id-of-your-html-element')

build() ⇒ Configuration

Helper function to build the Configuration object.

Kind: instance method of ConfigurationBuilder

Example

ConfigurationBuilder.build()

AgreementBuilder

AgreementBuilder is an object that provides helper functions to create Agreement SDK objects

Kind: global class

setAgreementType(value) ⇒ AgreementBuilder

Helper function to configure agreement type. Possible values: RECURRING|UNSCHEDULED.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setAgreementType('RECURRING')

setExpirationDate(value) ⇒ AgreementBuilder

Helper function to configure the agreement expiration date. It must have the format yyyy-MM-dd'T'HH:mm:ss'Z' so be compatible with ISO 8601 and expressed in UTC. Example: 2024-12-15T12:20:30Z.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setExpirationDate('2024-12-15T12:20:30Z')

setFrequency(value) ⇒ AgreementBuilder

Helper function to configure frequency between the charge agreement requests made by the merchant. Possible values: FLEXIBLE, DAILY, WEEKLY, BIWEEKLY, MONTHLY, QUARTERLY, YEARLY.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setFrequency(AgreementChargeFrequency.MONTHLY)

setNextChargeDate(value) ⇒ AgreementBuilder

Helper function to configure the date of the first charge agreement request made by the merchant. It must have the format yyyy-MM-dd'T'HH:mm:ss'Z' so be compatible with ISO 8601 and expressed in UTC. Example: 2024-12-15T12:20:30Z.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setNextChargeDate('2023-12-15T12:20:30Z')

setAgreementManagementURL(value) ⇒ AgreementBuilder

Helper function to configure a link to a page on the merchant side where the customer can manage the agreement.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setAgreementManagementURL('https://some-link')

setAutoReserve(value) ⇒ AgreementBuilder

Helper function to set autoReserve flag which indicates if the agreement setup should automatically be reserved.

Kind: instance method of AgreementBuilder

Note: this flag together with autoCapture define agreement behaviour according to the following:

agreement authType autoCapture agreement.autoReserve
subscription false (or not present) false (or not present)
subscriptionAndReserve false (or not present) true
subscriptionAndCharge true true (or not present)

Example

AgreementBuilder.setAutoReserve(true)

setUnscheduledType(value) ⇒ AgreementBuilder

Helper function to indicate the type of the unscheduled agreement. Must be set if agreementType = UNSCHEDULED and at least one of: autoCapture, agreement.autoReserve is set to true. Possible values: INCREMENTAL, RESUBMISSION, DELAYED_CHARGES, REAUTHORISATION, NO_SHOW, CHARGE.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setUnscheduledType('CHARGE')

setFallbackToPayment(value) ⇒ AgreementBuilder

Helper function to set fallbackToPayment flag indicating if the agreement should fallback to regular payment if payment method does not support agreements.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setFallbackToPayment(true)

setName(value) ⇒ AgreementBuilder

Helper function to set short name displayed to customer when accepting the agreement.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setName('VOD subscription')

setDescription(value) ⇒ AgreementBuilder

Helper function to set description of the agreement to be accepted by the customer.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setDescription('Gives monthly access to VOD platform')

setAmount(value) ⇒ AgreementBuilder

Helper function to set amount of money that is meant to be charged as a part of agreement.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setAmount(9.99)

setInitialAmount(value) ⇒ AgreementBuilder

Helper function to set amount of money to be charged when setting up the agreement if first payment differs from other payments within the agreement.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.setIntialAmount(29.99)

build() ⇒ Agreement

Helper function to build the Agreement object.

Kind: instance method of AgreementBuilder

Example

AgreementBuilder.build()

PaymentMethod

PaymentMethod is an object that holds relevant information about payment method.

Kind: global class

Param Type Description
id string unique identifier
description string description of the payment method
name string name of the payment method to be displayed
type string Possible values:
ACCOUNT_TO_ACCOUNT,
CARD,
EPAYMENT,
IDEALPAYMENT,
INVOICE,
MOBILE,
WALLET
type of payment method defining payment flow
logoUrl url URL to the logo
paymentMethodMetadata PaymentMethodMetadata additional information

PaymentMethodMetadata

PaymentMethodMetadata is an object that holds additional metadata for the payment method.

Kind: global class

Param Type Comments
terminalName string
merchantId string optional
canUseCredit boolean
canIssueNewCredit boolean

OnRenderPaymentMethodEvent

OnRenderPaymentMethodEvent is an object that holds relevant information about rendering payment method event.

Kind: global class

Param Type Description
paymentMethod PaymentMethod Information about the payment method to be render
defaultPaymentMethodElement HTMLElement Default HTMLElement build by AltaPay. You can style it and return in the response of RenderPaymentMethodCallbackFunction, or create new element
onSelectPaymentMethodCallback function The function you have to attach to the new element you create, on customer select payment method event. This is relevant only if you decide to not use the defaultPaymentMethodElement, but create and return a new html element

RenderPaymentMethodCallbackFunction(event) => HTMLElement

Definition of the callback function you have to provide in onRenderPaymentMethodCallback.

Returns: HTMLElement - the custom rendering of the Payment Method

Param Type Description
onRenderPaymentMethodEvent OnRenderPaymentMethodEvent Contains relevant information for rendering payment method that you can use in order to customize the rendered payment method element

AltaPayPaymentMethodFactory

AltaPayPaymentMethodFactory is an object that provides helper functions to create payment specific JS handlers

Kind: global class

createHandler(token, sessionId, order, method) ⇒ IAltaPayMethodHandler

Kind: instance method of AltaPayPaymentMethodFactory

Param Description
token JWT token for the session
sessionId identifier for the checkout session
order order information, see Order for more details
method payment method information received from the server

IAltaPayMethodHandler

Kind: global class

IAltaPayMethodHandler object is an interface that provides helper functions to create payment specific JS handlers

onRenderCheck() ⇒ Promise

Verifies if payment method is available for given checkout session.

It verifies if payment method is available for on the device used by the customer and configured properly.

Kind: instance method of IAltaPayMethodHandler
Returns: Promise - indicating if payment method could be used and rendered to the customer
Example

AltaPayPaymentMethodFactory
    .create(token, sessionId, order, method)
    .onRenderCheck()
    .then(() => {
        // Payment method is available for the customer
        // code to render payment method here
    })
    .catch(({message, errorCode}) => {
        // Payment method is not available for the customer
        // code to handle error here
    });

onInitiatePayment() ⇒ Promise

Initiate payment for the given payment method.

Requires to be called only after onRenderCheck() was successful when customer is clicking Pay button on the checkout page.

Kind: instance method of IAltaPayMethodHandler
Returns: Promise - indicating if payment was initiated successfully
Example

const method = AltaPayPaymentMethodFactory.create(token, sessionId, order, method);
// onRenderCheck() call and rendering of payment method here
// customer clicks Pay button
method.onInitiatePayment()
    .then(() => {
        // Payment was initiated successfully
        // code to handle success here
    })
    .catch(({message, errorCode}) => {
        // Payment was not initiated successfully
        // code to handle error here, like allow to retry with different payment method
    });