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,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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue