Accept Payment

The most basic function is the acceptPayment(options) function. This is the function that the Commerce Cloud Endless Aisle app calls when it's ready to accept payment It's within this function that Endless Aisle begins communicating with the payment device.

For Adyen, the function looks like this for Release 1.7.2 or later:

adyen.acceptPayment = function(options){
    adyen.needsSignature = false;
    options.currency = Alloy.Models.basket.getCurrency();
    options.order_no = Alloy.Models.basket.getOrderNo();
    adyen._acceptPayment(options);
};

This function is the entry point.

The currency and order_no are properties of the options object and are needed in the native code for Adyen; therefore, they are added to the options object in acceptPayment. (It is possible that the payment device you are implementing doesn't require this information.)The code then calls _acceptPayment(options), which is a native function in the com.demandware.adyen module. The function that calls into the native code can be called anything; there is no requirement that it be called _acceptPayment. The options argument can have properties in it when acceptPayment() is called. For example, if manual entry is requested, there is a property called manual set in options, which lets the payment module know that the device should initiate a manual entry transaction.

To enable the device to accept payment, consult the manufacturer's library. This is the code you need to write based on the payment device SDK.

Related Links

Create a Payment Module

Load the Native Module

Approve Payment

Cancel Payment

Cancel Server Transaction

Handle Errors

Support Manual Card Number Entry

Support Payment with Gift Cards

Display Whether the Payment Device Is Connected

Configure Device in Admin Dashboard

Support Barcode Scanner