Jyrone Parker

Creating A POS System With Lumen and Ionic – Part 2

[callaction url=”https://www.youtube.com/user/JPlaya01″ background_color=”#333333″ text_color=”#ffffff” button_text=”Go Now” button_background_color=”#e64429″]Subscribe To My Youtube Page[/callaction]

Before We Begin

Have you already have the Lumen back end micro service up and running? If not head over to part 1 and write your own implementation. Alternatively you can clone the repository from GitHub. Now with that working, let us begin!


As with part 1 I will assume you already have the environment set up to begin Ionic development. If you don’t, please head over and read my previous Ionic tutorial. Otherwise let’s create a new project

ionic start ParkerPay

cd into the new application and install the dependencies

bower install ngCordova  

cordova plugin add https://github.com/Paldom/SpinnerDialog.git

cordova plugin add cordova-plugin-dialogs

This will install ngCordova which will allow us to access native APIs via plugins, the two plugins are for accessing native spinner dialogs and alert dialogs. Now let’s edit the application logic, head over to www/js/app.js and paste the following code:

angular.module('parker-pay', ['ionic','ngCordova'])

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
if(window.StatusBar) {

.controller('HomeCtrl', function($scope,$http,$cordovaSpinnerDialog,$cordovaDialogs){
$scope.charge = {};
$scope.createToken = function(){
$cordovaSpinnerDialog.show("Processing Payment","Please wait....", true);
Stripe.setPublishableKey('STRIPE PUBLISHABLE KEY');
number: $scope.charge.number,
cvc: $scope.charge.cvc,
exp_month: $scope.charge.exp_month,
exp_year: $scope.charge.exp_year
}, $scope.stripeResponseHandler);

$scope.stripeResponseHandler = function(status, response){
if (response.error) {
// Show the errors on the form
$cordovaDialogs.alert('There was an error', 'Alert', 'OK')
.then(function() {
// callback success

} else {
// response contains id and card, which contains additional card details
var token = response.id;
// Insert the token into the form so it gets submitted to the server
var data = {token:token,amount:$scope.charge.amount,description:$scope.charge.description}
// and submit

// beep 1 time
$cordovaDialogs.alert('Payment was a success.', 'Alert', 'OK')
.then(function() {
// callback success

alert('There was an error.');

$cordovaDialogs.alert('There was an error', 'Alert', 'OK')
.then(function() {
// callback success


Be sure to put your Stripe key in. Last thing to do programmatically speaking, is to edit the index.html file. Paste the following code:

<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
<body ng-app="parker-pay" ng-controller="HomeCtrl">

<ion-header-bar class="bar-stable">
<h1 class="title">Parker Pay</h1>
<div class="list list-inset">
<label class="icon icon-left ion-pricetag item item-input">
<input ng-model="charge.amount" type="text" placeholder=" Amount">
<label class="icon icon-left ion-card item item-input">
<input ng-model="charge.number" type="text" placeholder=" Card Number">
<label class="ion-calendar icon icon-left item item-input">
<input ng-model="charge.exp_month" type="text" placeholder=" Exp. Month">
<label class="icon icon-left ion-calendar item item-input">
<input ng-model="charge.exp_year" type="text" placeholder=" Exp Year">
<label class="icon icon-left ion-card item item-input">
<input ng-model="charge.cvc" type="text" placeholder=" CVC">
<label class="icon icon-left ion-edit item item-input">
<input ng-model="charge.description" type="text" placeholder=" Description">
<div class="row">
<button ng-click="createToken()" class="col-offset-33  icon icon-left ion-social-usd button button-positive">

Next add your preferred platform by running

ionic platform add <PLATFORM> 

, connect your device and run ionic run <PLATFORM> , THAT’S IT YOU ARE NOW TAKING PAYMENTS!! See how easy that was? You are on your way to being an Artisan! Be sure to check the code out on GitHub

Leave a Reply


Follow Me!

%d bloggers like this: