Skip to content

Commit

Permalink
payment-request-timed-out
Browse files Browse the repository at this point in the history
  • Loading branch information
karliatto committed Mar 25, 2018
1 parent 84ba62f commit 01bd19b
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 2 deletions.
75 changes: 75 additions & 0 deletions css/views/payment-timed-out.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.view.payment-timed-out {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
box-sizing: border-box;
padding: 0;
padding-bottom: 4rem;
}

.view.payment-timed-out .timed-out-image {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
width: 16rem;
height: 16rem;
max-width: 90%;
max-height: 90%;
background: #D8000C;
border-radius: 50%;
-webkit-animation: scale .5s ease-in-out;
animation: scale .5s ease-in-out;
margin: 0 auto;
}

.view.payment-timed-out .timed-out-message {
color: #fff;
font-size: 6.2rem;
font-weight: 100;
text-align: center;
}

.timed-out-message-text {
color: #fff;
font-size: 2rem;
}

@-webkit-keyframes scale {
0% {
-webkit-transform: scale(0) translateZ(0);
transform: scale(0) translateZ(0);
}
20% {
-webkit-transform: scale(1.5) translateZ(0);
transform: scale(1.5) translateZ(0);
}
60% {
-webkit-transform: scale(0.75) translateZ(0);
transform: scale(0.75) translateZ(0);
}
100% {
-webkit-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
}
}

@keyframes scale {
0% {
-webkit-transform: scale(0) translateZ(0);
transform: scale(0) translateZ(0);
}
20% {
-webkit-transform: scale(1.5) translateZ(0);
transform: scale(1.5) translateZ(0);
}
60% {
-webkit-transform: scale(0.75) translateZ(0);
transform: scale(0.75) translateZ(0);
}
100% {
-webkit-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
}
}
7 changes: 7 additions & 0 deletions html/templates/payment-timed-out.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="timed-out-image">
<div class="timed-out-message"></div>
<div class="timed-out-message-text">{{i18n "payment-timed-out.message"}}</div>
</div>
<div class="secondary-controls">
<a class="secondary-control button done">{{i18n "payment-timed-out.ok"}}</a>
</div>
3 changes: 3 additions & 0 deletions js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ app.config = (function() {
minLength: 1,
unlockTime: 5 * 60 * 1000,
},
paymentRequest: {
timedOut: 5 * 60 * 1000,
},
settings: [
{
name: 'configurableCryptoCurrencies',
Expand Down
2 changes: 2 additions & 0 deletions js/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ app.lang['en'] = (function() {
'pin-required.instructions': 'Enter the admin PIN to continue',
'pin-required.incorrect': 'The PIN you entered was incorrect',
'device.camera.not-available': 'Device camera not available',
'payment-timed-out.message': 'Timed out',
'payment-timed-out.ok': 'Ok',
};

})();
7 changes: 7 additions & 0 deletions js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ app.Router = (function() {
routes: {
'pay': 'pay',
'confirmed': 'paymentConfirmation',
'timed-out': 'paymentTimedOut',
'pay/:amount': 'choosePaymentMethod',
'pay/:amount/:method': 'displayPaymentAddress',
'payment-details/:paymentId': 'paymentDetails',
Expand Down Expand Up @@ -162,6 +163,12 @@ app.Router = (function() {
app.mainView.renderView('PaymentDetails', {
paymentId: paymentId
});
},

paymentTimedOut: function() {

app.mainView.renderView('PaymentTimedOut');

}

});
Expand Down
17 changes: 15 additions & 2 deletions js/views/display-payment-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ app.views.DisplayPaymentAddress = (function() {
'quicktouch .back': 'back',
},

timerForTimeOut: false,

serializeData: function() {

return {
Expand Down Expand Up @@ -147,6 +149,7 @@ app.views.DisplayPaymentAddress = (function() {
var paymentMethod = app.paymentMethods[this.options.method];
var paymentRequest = this.paymentRequest.toJSON();
var received = false;
var timedOut = false;
var errorWhileWaiting;

paymentMethod.listenForPayment(paymentRequest, function(error, wasReceived) {
Expand All @@ -160,6 +163,7 @@ app.views.DisplayPaymentAddress = (function() {
var done = _.bind(function(error) {

this.stopListeningForPayment();
clearTimeout(this.timerForTimeOut);

if (error) {
return app.mainView.showMessage(error);
Expand All @@ -171,12 +175,20 @@ app.views.DisplayPaymentAddress = (function() {
// Show success screen.
app.router.navigate('confirmed', { trigger: true });
} else {
app.mainView.showMessage(new Error(app.i18n.t('pay-address.timeout')));
// Update the status of the payment request.
this.paymentRequest.save({ status: 'timed-out' });
// Show timed-out screen.
app.router.navigate('timed-out', { trigger: true });
}

}, this);

async.until(function() { return received; }, function(next) {
this.timerForTimeOut = setTimeout(function() {
timedOut = true;
}, app.config.paymentRequest.timedOut)

async.until(function() { return received || timedOut; }, function(next) {

if (errorWhileWaiting) {
return next(errorWhileWaiting);
} else {
Expand Down Expand Up @@ -228,6 +240,7 @@ app.views.DisplayPaymentAddress = (function() {
onClose: function() {

this.stopListeningForPayment();
clearTimeout(this.timerForTimeOut);
},

onBackButton: function() {
Expand Down
36 changes: 36 additions & 0 deletions js/views/payment-timed-out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var app = app || {};

app.views = app.views || {};

app.views.PaymentTimedOut= (function() {

'use strict';

return app.abstracts.BaseView.extend({

className: 'payment-timed-out',

template: '#template-payment-timed-out',

events: {
'quicktouch .done': 'done',
},

done: function(evt) {

if (evt && evt.preventDefault) {
evt.preventDefault();
}

// Navigate back to the homescreen
app.router.navigate('main', { trigger: true });
},

onBackButton: function() {

this.done();
}

});

})();

0 comments on commit 01bd19b

Please sign in to comment.