Home > Uncategorized > Enter card details using camera @cardio #cordova #phonegap

Enter card details using camera @cardio #cordova #phonegap

cardio

Entering a 16 digit number into an app is error prone, and can frustrate a user right at the point of purchase. There is a really cool Cordova / Phonegap plugin that allows you scan a credit card using the camera, so you can input it into the page, without the user having to type.

Although the plugin is developed by paypal, you can use it with other PSPs, like stripe, – and since the processing is done on-device, there is no transmission of sensitive data.

You add the plugin to your project using:

cordova plugin add https://github.com/card-io/card.io-Cordova-Plugin

Then you call it in Javascript with code such as;

CardIO.scan({
“requireExpiry”: true,
“requireCVV”: true,
“requirePostalCode”: false,
“restrictPostalCodeToNumericOnly”: true
},
function(response){

$scope.form.CardNumber = parseInt(response[“cardNumber”]);
var dtExpiry = new Date(response[“expiryYear”], response[“expiryMonth”], 1);
$scope.form.CardExpiry = dtExpiry;
$scope.form.CardCvv = parseInt(response[“cvv”]);
$scope.$apply();
},
function(){
sweetAlert(“Oops…”, “Your card scan has failed”, “error”);
}
);

Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: