adding paypro

This commit is contained in:
Gabriel Bazán 2016-08-03 10:05:20 -03:00 committed by Gustavo Maximiliano Cortez
commit 5890bea48f
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
2 changed files with 76 additions and 47 deletions

View file

@ -82,11 +82,11 @@
<ul class="no-bullet size-14 m30v text-center"> <ul class="no-bullet size-14 m30v text-center">
<li class="line-b p10 oh pointer" ng-show="card.status == 'SUCCESS' && card.cardStatus == 'Fulfilled'" ng-click="cancelGiftCard()"> <li class="line-b p10 oh pointer" ng-show="card.status == 'SUCCESS' && card.cardStatus == 'Fulfilled'" ng-click="cancelGiftCard()">
<span class="text-warning">Cancel gift card</span> <span class="text-warning">Cancel</span>
</li> </li>
<li class="line-b p10 oh pointer" ng-show="card.status == 'FAILURE' || card.cardStatus == 'RefundedToPurchaser' <li class="line-b p10 oh pointer" ng-show="card.status == 'FAILURE' || card.cardStatus == 'RefundedToPurchaser'
|| card.cardStatus == 'Expired'" ng-click="remove()"> || card.cardStatus == 'Expired'" ng-click="remove()">
<span class="text-warning">Remove gift card</span> <span class="text-warning">Remove</span>
</li> </li>
</ul> </ul>

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('buyAmazonController', angular.module('copayApp.controllers').controller('buyAmazonController',
function($rootScope, $scope, $ionicModal, $log, $timeout, $state, lodash, profileService, bwcError, configService, walletService, fingerprintService, amazonService, ongoingProcess) { function($rootScope, $scope, $ionicModal, $log, $timeout, $state, lodash, profileService, bwcError, gettext, configService, walletService, fingerprintService, amazonService, ongoingProcess) {
var self = this; var self = this;
var client; var client;
@ -91,10 +91,39 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
return; return;
} }
var address, comment, amount; $log.debug('Fetch PayPro Request...', invoice.paymentUrls.BIP73);
address = invoice.bitcoinAddress; client.fetchPayPro({
amount = parseInt((invoice.btcPrice * 100000000).toFixed(0)); payProUrl: invoice.paymentUrls.BIP73,
}, function(err, paypro) {
if (err) {
$log.warn('Could not fetch payment request:', err);
var msg = err.toString();
if (msg.match('HTTP')) {
msg = gettext('Could not fetch payment information');
}
self.error = msg;
$timeout(function() {
$scope.$digest();
});
return;
}
if (!paypro.verified) {
$log.warn('Failed to verify payment protocol signatures');
self.error = gettext('Payment Protocol Invalid');
$timeout(function() {
$scope.$digest();
});
return;
}
var address, comment, amount, url;
address = paypro.toAddress;
amount = paypro.amount;
url = paypro.url;
comment = 'Amazon.com Gift Card'; comment = 'Amazon.com Gift Card';
outputs.push({ outputs.push({
@ -108,7 +137,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
amount: amount, amount: amount,
outputs: outputs, outputs: outputs,
message: comment, message: comment,
payProUrl: null, payProUrl: url,
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true, excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
feeLevel: walletSettings.feeLevel || 'normal' feeLevel: walletSettings.feeLevel || 'normal'
}; };
@ -148,6 +177,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
}); });
}); });
}); });
});
}, 100); }, 100);
}; };
@ -237,7 +267,6 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
}); });
return bwcError.cb(err, null, cb); return bwcError.cb(err, null, cb);
} }
walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) { walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) {
if (err) { if (err) {
$log.debug(err); $log.debug(err);