Approve Payment

When the payment information has been retrieved and the device returns it, you transfer it into JavaScript. See the Appcelerator module documentation which tells you how to communicate across the JavaScript bridge. For example, the Verifone device module that is included with Commerce Cloud Endless Aisle fires the event magneticCardData. The result is returned across the JavaScript bridge, in JavaScript. The verifoneDevice.js code contains an event listener for the magneticCardData event.

After the data is returned from the device, you call either one of these events with the payment information in the payload:

The Adyen code looks like this:

 Alloy.eventDispatcher.trigger('payment:cc_approved', {
        owner: e.cardHolderName,
        card_type: e.cardString,
        pan: "xxxx-xxxx-xxxx-"+e.cardNumber,
        month: e.cardExpiryMonth,
        year: e.cardExpiryYear,
        transaction_id: e.pspReference,
        payment_reference_id: e.pspAuthCode,
        is_contactless: false
      });

For release 1.7.1 and earlier:

Ti.App.fireEvent('cc_payment_approved', {
    owner: e.cardHolderName,
    card_type: e.cardString,
    pan: "xxxx-xxxx-xxxx-"+e.cardNumber,
    month: e.cardExpiryMonth,
    year: e.cardExpiryYear,
    transaction_id: e.pspReference,
    payment_reference_id: e.pspAuthCode,
    is_contactless: false
});

At this point the payment process is complete.

Note: Different payment processors work differently. For example, Verifone only reads the card data and returns it to the application. Therefore, a different set of events is used. After the data is returned from the device, the cc_payment_entered event is fired in version 1.7.1 and earlier. In 1.7.2 and later, the payment:credit_card_data event is fired:
Alloy.eventDispatcher.trigger('payment:credit_card_data', {
    track_1:e.track1,
    track_2:e.track2,
    pan:e.pan,
    month:e.month,
    year:e.year,
    is_contactless:e.contactless == "true",
    terminal_id:e.terminal_id
});

For release 1.7.1 and earlier:

Ti.App.fireEvent('cc_payment_entered', {
    track_1:e.track1,
    track_2:e.track2,
    pan:e.pan,
    month:e.month,
    year:e.year,
    is_contactless:e.contactless == "true",
    terminal_id:e.terminal_id
});

Related Links

Create a Payment Module

Load the Native Module

Accept 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