Enter card details using camera @cardio #cordova #phonegap
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”);
}
);