fixed paypro

This commit is contained in:
Ivan Socolsky 2014-10-31 16:10:11 -03:00
parent de7bfe90e0
commit a685fd77f1
3 changed files with 19 additions and 11 deletions

View File

@ -143,7 +143,7 @@ angular.module('copayApp.controllers').controller('SendController',
if (merchantData.pr.ca) { if (merchantData.pr.ca) {
message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.'; message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.';
} }
message += ' Message from server: ' + merchantData.ack.memo; message += ' Message from server: ' + merchantData.pr.pd.memo;
message += ' For merchant: ' + merchantData.pr.pd.payment_url; message += ' For merchant: ' + merchantData.pr.pd.payment_url;
} }
notification.success('Success', message); notification.success('Success', message);
@ -156,7 +156,7 @@ angular.module('copayApp.controllers').controller('SendController',
if (merchantData.pr.ca) { if (merchantData.pr.ca) {
message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.'; message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.';
} }
message += ' Message from server: ' + merchantData.ack.memo; message += ' Message from server: ' + merchantData.pr.pd.memo;
message += ' For merchant: ' + merchantData.pr.pd.payment_url; message += ' For merchant: ' + merchantData.pr.pd.payment_url;
} }
notification.success('Transaction broadcasted', message); notification.success('Transaction broadcasted', message);
@ -464,6 +464,7 @@ angular.module('copayApp.controllers').controller('SendController',
// whether we're in the Send scope or not. // whether we're in the Send scope or not.
if (!scope.sendForm || !scope.sendForm.address) { if (!scope.sendForm || !scope.sendForm.address) {
delete $rootScope.merchant; delete $rootScope.merchant;
$rootScope.merchantError = false;
if (callback) callback(); if (callback) callback();
return; return;
} }
@ -547,9 +548,8 @@ angular.module('copayApp.controllers').controller('SendController',
var balance = $rootScope.availableBalance; var balance = $rootScope.availableBalance;
var available = +(balance * w.settings.unitToSatoshi).toFixed(0); var available = +(balance * w.settings.unitToSatoshi).toFixed(0);
if (merchantData && available < +merchantData.total) { if (merchantData && available < +merchantData.total) {
err = new Error('No unspent outputs available.'); err = new Error('Insufficient funds.');
err.amount = merchantData.total; err.amount = merchantData.total;
} }

View File

@ -1434,7 +1434,7 @@ Wallet.prototype.createPaymentTx = function(options, cb) {
return self.receivePaymentRequest(options, pr, cb); return self.receivePaymentRequest(options, pr, cb);
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
log.debug('Server was did not return PaymentRequest.'); log.debug('Server did not return PaymentRequest.');
log.debug('XHR status: ' + status); log.debug('XHR status: ' + status);
if (options.fetch) { if (options.fetch) {
return cb(new Error('Status: ' + status)); return cb(new Error('Status: ' + status));
@ -1592,6 +1592,8 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
self.sendIndexes(); self.sendIndexes();
self.sendTxProposal(ntxid); self.sendTxProposal(ntxid);
self.emit('txProposalsUpdated'); self.emit('txProposalsUpdated');
} else {
return cb(new Error('Error creating the transaction'));
} }
log.debug('You are currently on this BTC network:', network); log.debug('You are currently on this BTC network:', network);
@ -1867,9 +1869,15 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
merchantData.total = merchantData.total.toString(10); merchantData.total = merchantData.total.toString(10);
var b = new Builder(opts) var b;
try {
b = new Builder(opts)
.setUnspent(unspent) .setUnspent(unspent)
.setOutputs(outs); .setOutputs(outs);
} catch (e) {
log.debug(e.message);
return;
};
merchantData.pr.pd.outputs.forEach(function(output, i) { merchantData.pr.pd.outputs.forEach(function(output, i) {
var script = { var script = {
@ -2304,7 +2312,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, comment, opts, cb)
var ntxid = self.createTxSync(toAddress, amountSatStr, comment, safeUnspent, opts); var ntxid = self.createTxSync(toAddress, amountSatStr, comment, safeUnspent, opts);
if (!ntxid) { if (!ntxid) {
return cb(new Error('Error creating the Transaction')); return cb(new Error('Error creating the transaction'));
} }
self.sendIndexes(); self.sendIndexes();

View File

@ -72,7 +72,7 @@
</label> </label>
<div class="small-9 columns"> <div class="small-9 columns">
<input type="number" id="amount" <input type="number" id="amount"
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0) || $root.merchantError" ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0)"
name="amount" placeholder="{{'Amount'|translate}}" ng-model="amount" name="amount" placeholder="{{'Amount'|translate}}" ng-model="amount"
min="0.00000001" max="10000000000" valid-amount required min="0.00000001" max="10000000000" valid-amount required
autocomplete="off"> autocomplete="off">
@ -95,7 +95,7 @@
<label for="alternative"><span translate>Amount in</span> {{ alternativeName }} </label> <label for="alternative"><span translate>Amount in</span> {{ alternativeName }} </label>
<div class="small-9 columns"> <div class="small-9 columns">
<input type="number" id="alternative_amount" <input type="number" id="alternative_amount"
ng-disabled="loading || !isRateAvailable || ($root.merchant && +$root.merchant.total > 0) || $root.merchantError" ng-disabled="loading || !isRateAvailable || ($root.merchant && +$root.merchant.total > 0)"
name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative" name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative"
required required
autocomplete="off" autocomplete="off"