adding paypro
This commit is contained in:
parent
de6107206e
commit
5890bea48f
2 changed files with 76 additions and 47 deletions
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,59 +91,89 @@ 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,
|
||||||
comment = 'Amazon.com Gift Card';
|
}, function(err, paypro) {
|
||||||
|
|
||||||
outputs.push({
|
|
||||||
'toAddress': address,
|
|
||||||
'amount': amount,
|
|
||||||
'message': comment
|
|
||||||
});
|
|
||||||
|
|
||||||
var txp = {
|
|
||||||
toAddress: address,
|
|
||||||
amount: amount,
|
|
||||||
outputs: outputs,
|
|
||||||
message: comment,
|
|
||||||
payProUrl: null,
|
|
||||||
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
|
|
||||||
feeLevel: walletSettings.feeLevel || 'normal'
|
|
||||||
};
|
|
||||||
|
|
||||||
walletService.createTx(client, txp, function(err, createdTxp) {
|
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = bwcError.msg(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() {
|
$timeout(function() {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
|
|
||||||
if (accept) {
|
|
||||||
self.confirmTx(createdTxp, function(err, tx) {
|
|
||||||
if (err) {
|
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
|
||||||
self.error = bwcError.msg(err);
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var count = 0;
|
|
||||||
ongoingProcess.set('Processing Transaction...', true);
|
|
||||||
|
|
||||||
dataSrc.accessKey = dataInvoice.accessKey;
|
if (!paypro.verified) {
|
||||||
dataSrc.invoiceId = invoice.id;
|
$log.warn('Failed to verify payment protocol signatures');
|
||||||
dataSrc.invoiceUrl = invoice.url;
|
self.error = gettext('Payment Protocol Invalid');
|
||||||
dataSrc.invoiceTime = invoice.invoiceTime;
|
$timeout(function() {
|
||||||
|
$scope.$digest();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.debounceCreate(count, dataSrc);
|
var address, comment, amount, url;
|
||||||
|
|
||||||
|
address = paypro.toAddress;
|
||||||
|
amount = paypro.amount;
|
||||||
|
url = paypro.url;
|
||||||
|
comment = 'Amazon.com Gift Card';
|
||||||
|
|
||||||
|
outputs.push({
|
||||||
|
'toAddress': address,
|
||||||
|
'amount': amount,
|
||||||
|
'message': comment
|
||||||
|
});
|
||||||
|
|
||||||
|
var txp = {
|
||||||
|
toAddress: address,
|
||||||
|
amount: amount,
|
||||||
|
outputs: outputs,
|
||||||
|
message: comment,
|
||||||
|
payProUrl: url,
|
||||||
|
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
|
||||||
|
feeLevel: walletSettings.feeLevel || 'normal'
|
||||||
|
};
|
||||||
|
|
||||||
|
walletService.createTx(client, txp, function(err, createdTxp) {
|
||||||
|
ongoingProcess.set('Processing Transaction...', false);
|
||||||
|
if (err) {
|
||||||
|
self.error = bwcError.msg(err);
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
|
||||||
|
if (accept) {
|
||||||
|
self.confirmTx(createdTxp, function(err, tx) {
|
||||||
|
if (err) {
|
||||||
|
ongoingProcess.set('Processing Transaction...', false);
|
||||||
|
self.error = bwcError.msg(err);
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$digest();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var count = 0;
|
||||||
|
ongoingProcess.set('Processing Transaction...', true);
|
||||||
|
|
||||||
|
dataSrc.accessKey = dataInvoice.accessKey;
|
||||||
|
dataSrc.invoiceId = invoice.id;
|
||||||
|
dataSrc.invoiceUrl = invoice.url;
|
||||||
|
dataSrc.invoiceTime = invoice.invoiceTime;
|
||||||
|
|
||||||
|
self.debounceCreate(count, dataSrc);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue