cardFlight.configure({
apiToken: "<Card Flight API Token>",
accountToken: "<Merchant Account Token>"
});
cardFlight.beginSwipe(func(<card>), func(<error>)[, options])
Pass the options {swipeMessage: 'none'}
to beginSwipe to swipe without a popup message (the CardFlight beginSwipeWithMessage:nil
).
The callback provided to setCallbackOnSwipeComplete returns general card info — card.name, .last4, .cardType, .expirationMonth, .expirationYear. If the swipe is successful, the card is tokenized and the success callback provided to beginSwipe is called.
var swipeCallback = function (card) {
console.log("swipe successful", card);
}
cardFlight.setCallbackOnSwipeComplete(swipeCallback)
// beginSwipe callback returns after tokenize, returns only card.cardToken
var successCallback = function (card) {
console.log("Tokenize successful", card.cardToken);
}
var errorCallback = function (error) {
console.log("swipe error", error.message)
}
cardFlight.beginSwipe(successCallback, errorCallback, {
swipeMessage: "Begin Swipe"
});
{
cardToken: "<token on merchant>"
}
{
message: "<some descriptive error message>",
type: "<some type in Error.TYPES>"
}