commit
17c54ba5cf
3 changed files with 89 additions and 42 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, balanceService) {
|
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, $timeout, balanceService) {
|
||||||
|
|
||||||
$rootScope.title = 'Payment intent';
|
$rootScope.title = 'Payment intent';
|
||||||
|
|
||||||
|
|
@ -22,8 +22,11 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun
|
||||||
var ret = _.filter($rootScope.iden.listWallets(), function(w) {
|
var ret = _.filter($rootScope.iden.listWallets(), function(w) {
|
||||||
return w.balanceInfo && w.balanceInfo.totalBalanceBTC;
|
return w.balanceInfo && w.balanceInfo.totalBalanceBTC;
|
||||||
});
|
});
|
||||||
$scope.wallets = ret;
|
$timeout(function() {
|
||||||
$scope.loading = false;
|
$scope.wallets = ret;
|
||||||
|
$scope.loading = false;
|
||||||
|
$scope.$digest();
|
||||||
|
}, 1000);
|
||||||
};
|
};
|
||||||
if ($rootScope.iden) {
|
if ($rootScope.iden) {
|
||||||
var iden = $rootScope.iden;
|
var iden = $rootScope.iden;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
|
|
||||||
|
|
||||||
$scope.updateTxs = _.throttle(function() {
|
$scope.updateTxs = _.throttle(function() {
|
||||||
console.log('[send.js.44:updateTxs:]'); //TODO
|
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
if (!w) return;
|
if (!w) return;
|
||||||
|
|
||||||
|
|
@ -104,6 +103,18 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
Object.defineProperty($scope,
|
||||||
|
"address", {
|
||||||
|
get: function() {
|
||||||
|
return this._address;
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
this._address = newValue;
|
||||||
|
_onChanged();
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
|
|
@ -122,22 +133,6 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
return w && _.keys(w.addressBook).length > 0;
|
return w && _.keys(w.addressBook).length > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($rootScope.pendingPayment) {
|
|
||||||
var pp = $rootScope.pendingPayment;
|
|
||||||
var amount = pp.data.amount * 100000000 * satToUnit;
|
|
||||||
var alternativeAmountPayPro = rateService.toFiat((amount + $scope.defaultFee) * w.settings.unitToSatoshi, $scope.alternativeIsoCode);
|
|
||||||
if (pp.data.merchant) {
|
|
||||||
$scope.address = 'bitcoin:' + pp.address.data + '?amount=' + amount + '&r=' + pp.data.r;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$scope.address = pp.address + '';
|
|
||||||
$scope.amount = amount;
|
|
||||||
$scope.alternative = alternativeAmountPayPro;
|
|
||||||
}
|
|
||||||
$scope.alternativeAmountPayPro = $filter('noFractionNumber')(alternativeAmountPayPro, 2);
|
|
||||||
$scope.commentText = pp.data.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||||
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
|
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
|
||||||
|
|
||||||
|
|
@ -201,6 +196,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
$scope.address = $scope.amount = $scope.commentText = null;
|
$scope.address = $scope.amount = $scope.commentText = null;
|
||||||
form.address.$pristine = form.amount.$pristine = true;
|
form.address.$pristine = form.amount.$pristine = true;
|
||||||
$rootScope.pendingPayment = null;
|
$rootScope.pendingPayment = null;
|
||||||
|
$scope.isPayUri = null;
|
||||||
if (err) return $scope._showError(err);
|
if (err) return $scope._showError(err);
|
||||||
|
|
||||||
$scope.notifyStatus(status);
|
$scope.notifyStatus(status);
|
||||||
|
|
@ -451,6 +447,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
if (!$scope.sendForm || !$scope.sendForm.address) {
|
if (!$scope.sendForm || !$scope.sendForm.address) {
|
||||||
delete $rootScope.merchant;
|
delete $rootScope.merchant;
|
||||||
$rootScope.merchantError = false;
|
$rootScope.merchantError = false;
|
||||||
|
$scope.isPayUri = false;
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -483,15 +480,36 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
$scope.cancelSend = function(form) {
|
$scope.cancelSend = function(form) {
|
||||||
delete $rootScope.merchant;
|
delete $rootScope.merchant;
|
||||||
$rootScope.merchantError = false;
|
$rootScope.merchantError = false;
|
||||||
|
$scope.isPayUri = false;
|
||||||
form.address.$setViewValue('');
|
form.address.$setViewValue('');
|
||||||
form.address.$render();
|
form.address.$render();
|
||||||
form.amount.$setViewValue('');
|
form.amount.$setViewValue('');
|
||||||
|
form.amount.$render();
|
||||||
form.comment.$setViewValue('');
|
form.comment.$setViewValue('');
|
||||||
|
form.comment.$render();
|
||||||
form.$setPristine();
|
form.$setPristine();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.onChanged = function() {
|
var _onChanged = function(pp) {
|
||||||
var value = $scope.address || '';
|
var value;
|
||||||
|
|
||||||
|
if (pp) {
|
||||||
|
$scope.isPayUri = true;
|
||||||
|
var amount = (pp.data && pp.data.amount) ? pp.data.amount * 100000000 * satToUnit : 0;
|
||||||
|
$scope.commentText = pp.data.message;
|
||||||
|
if (pp.data.merchant) {
|
||||||
|
value = 'bitcoin:' + pp.address.data + '?amount=' + amount + '&r=' + pp.data.r;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
value = pp.address + '';
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.amount = amount;
|
||||||
|
}, 1000);
|
||||||
|
$scope.address = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
value = value || $scope.address || '';
|
||||||
var uri;
|
var uri;
|
||||||
|
|
||||||
$scope.error = $scope.success = null;
|
$scope.error = $scope.success = null;
|
||||||
|
|
@ -501,14 +519,28 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.indexOf('bitcoin:') === 0) {
|
if (value.indexOf('bitcoin:') === 0) {
|
||||||
uri = new bitcore.BIP21(value).data;
|
uri = new bitcore.BIP21(value);
|
||||||
} else if (/^https?:\/\//.test(value)) {
|
} else if (/^https?:\/\//.test(value)) {
|
||||||
uri = {
|
uri = {
|
||||||
merchant: value
|
data : {
|
||||||
|
merchant: value
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uri || !uri.merchant) {
|
if (!uri || !uri.data.merchant) {
|
||||||
|
if (uri && uri.address) {
|
||||||
|
var amount = (uri.data && uri.data.amount) ? uri.data.amount * 100000000 * satToUnit : 0;
|
||||||
|
var address = uri.address.data;
|
||||||
|
if (amount && address) {
|
||||||
|
$scope.isPayUri = true;
|
||||||
|
}
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.amount = amount;
|
||||||
|
}, 1000);
|
||||||
|
$scope.commentText = uri.data.message;
|
||||||
|
$scope.address = address;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -518,7 +550,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.fetchingURL = uri.merchant;
|
$scope.fetchingURL = uri.data.merchant;
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
apply();
|
apply();
|
||||||
|
|
||||||
|
|
@ -535,7 +567,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
|
|
||||||
// Payment Protocol URI (BIP-72)
|
// Payment Protocol URI (BIP-72)
|
||||||
$scope.wallet.fetchPaymentRequest({
|
$scope.wallet.fetchPaymentRequest({
|
||||||
url: uri.merchant
|
url: uri.data.merchant
|
||||||
}, function(err, merchantData) {
|
}, function(err, merchantData) {
|
||||||
if (!timeout) return;
|
if (!timeout) return;
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
|
@ -562,6 +594,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
var unregister = $scope.$watch('address', function() {
|
var unregister = $scope.$watch('address', function() {
|
||||||
if ($scope.sendForm.address.$viewValue !== lastAddr) {
|
if ($scope.sendForm.address.$viewValue !== lastAddr) {
|
||||||
delete $rootScope.merchantError;
|
delete $rootScope.merchantError;
|
||||||
|
$scope.isPayUri = false;
|
||||||
$scope.sendForm.amount.$setViewValue('');
|
$scope.sendForm.amount.$setViewValue('');
|
||||||
$scope.sendForm.amount.$render();
|
$scope.sendForm.amount.$render();
|
||||||
unregister();
|
unregister();
|
||||||
|
|
@ -608,4 +641,11 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
apply();
|
apply();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ($rootScope.pendingPayment) {
|
||||||
|
var value;
|
||||||
|
var pp = $rootScope.pendingPayment;
|
||||||
|
_onChanged(pp);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
tooltip="{{'Enter a valid Bitcoin address. Payment Protocol URLs are also supported'|translate}}"
|
tooltip="{{'Enter a valid Bitcoin address. Payment Protocol URLs are also supported'|translate}}"
|
||||||
tooltip-trigger="mouseenter"
|
tooltip-trigger="mouseenter"
|
||||||
tooltip-placement="right"></i>
|
tooltip-placement="right"></i>
|
||||||
<small translate ng-hide="!sendForm.address.$pristine || address">required</small>
|
<small translate ng-hide="!sendForm.address.$pristine && address">required</small>
|
||||||
</label>
|
</label>
|
||||||
<span translate class="has-error right size-12" ng-show="sendForm.address.$invalid && address">
|
<span translate class="has-error right size-12" ng-show="sendForm.address.$invalid && address">
|
||||||
<span class="icon-input"><i class="fi-x"></i></span>
|
<span class="icon-input"><i class="fi-x"></i></span>
|
||||||
|
|
@ -49,8 +49,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="text" id="address" name="address" ng-disabled="loading || !!$root.merchant"
|
<input type="text" id="address" name="address" ng-disabled="loading || !!$root.merchant || isPayUri"
|
||||||
placeholder="{{'Bitcoin address'|translate}}" ng-model="address" ng-change="onChanged()" valid-address required>
|
placeholder="{{'Bitcoin address'|translate}}" ng-model="address" valid-address required>
|
||||||
<i class="fi-address-book"></i>
|
<i class="fi-address-book"></i>
|
||||||
<div ng-hide="showScanner || disableScanner">
|
<div ng-hide="showScanner || disableScanner">
|
||||||
<a class="postfix button black" ng-click="openScanner()"><i class="fi-camera size-24"></i></a>
|
<a class="postfix button black" ng-click="openScanner()"><i class="fi-camera size-24"></i></a>
|
||||||
|
|
@ -71,9 +71,10 @@
|
||||||
<div class="large-6 medium-6 columns">
|
<div class="large-6 medium-6 columns">
|
||||||
<div class="row collapse">
|
<div class="row collapse">
|
||||||
<label for="amount" class="small-7 columns m5b"><span translate>Amount</span>
|
<label for="amount" class="small-7 columns m5b"><span translate>Amount</span>
|
||||||
<small translate ng-hide="!sendForm.amount.$pristine">required</small>
|
<small translate ng-hide="!sendForm.amount.$pristine && amount">required</small>
|
||||||
</label>
|
</label>
|
||||||
<span translate class="has-error right size-12" ng-show="(sendForm.amount.$invalid || notValidAmount) && !sendForm.amount.$pristine">
|
<span translate class="has-error right size-12" ng-show="sendForm.amount.$invalid &&
|
||||||
|
!sendForm.amount.$pristine && (notValidAmount || amount)">
|
||||||
<span class="icon-input"><i class="fi-x"></i></span>
|
<span class="icon-input"><i class="fi-x"></i></span>
|
||||||
Not valid
|
Not valid
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -84,7 +85,7 @@
|
||||||
<div class="small-9 columns">
|
<div class="small-9 columns">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="number" id="amount"
|
<input type="number" id="amount"
|
||||||
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0)"
|
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0) || isPayUri"
|
||||||
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">
|
||||||
|
|
@ -106,8 +107,9 @@
|
||||||
<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">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="number" id="alternative_amount"
|
<input type="number" id="alternative"
|
||||||
ng-disabled="loading || !isRateAvailable || ($root.merchant && +$root.merchant.total > 0)"
|
ng-disabled="loading || !isRateAvailable || ($root.merchant && +$root.merchant.total > 0) ||
|
||||||
|
isPayUri"
|
||||||
name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative" requiredautocomplete="off">
|
name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative" requiredautocomplete="off">
|
||||||
<i class="icon-usd"></i>
|
<i class="icon-usd"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -128,28 +130,30 @@
|
||||||
<p> From {{fetchingURL}}
|
<p> From {{fetchingURL}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="large-12 columns" ng-show="!!$root.merchant">
|
<div class="large-12 columns" ng-show="!!$root.merchant || isPayUri">
|
||||||
<h3>This is a payment protocol transaction</h3>
|
<h3 ng-show="!isPayUri">This is a payment protocol transaction</h3>
|
||||||
<div class="send-note">
|
<div class="send-note">
|
||||||
<p>
|
<p>
|
||||||
<b>{{$root.merchant.pr.pd.memo}}</b>
|
<span ng-show="isPayUri">Payment to: </span>
|
||||||
|
<b>{{$root.merchant.pr.pd.memo || address}}</b>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<i>{{amount + defaultFee}} {{$root.wallet.settings.unitName}}</i>
|
<i>{{amount + defaultFee}} {{$root.wallet.settings.unitName}}</i>
|
||||||
<span class="text-gray" ng-if="isRateAvailable">
|
<span class="text-gray" ng-if="isRateAvailable">
|
||||||
{{ alternativeAmountPayPro }} {{ alternativeIsoCode }}
|
{{ alternative }} {{ alternativeIsoCode }}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-gray" >
|
<span class="text-gray" >
|
||||||
(<span translate>Including fee of</span>
|
(<span translate>Including fee of</span>
|
||||||
{{defaultFee}}
|
{{defaultFee}}
|
||||||
{{$root.wallet.settings.unitName}})
|
{{$root.wallet.settings.unitName}})
|
||||||
</span>
|
</span>
|
||||||
<p>
|
<p ng-show="!!$root.merchant">
|
||||||
Expires {{$root.merchant.expiration | amTimeAgo }}
|
Expires {{$root.merchant.expiration | amTimeAgo }}
|
||||||
[{{$root.merchant.domain}}]
|
[{{$root.merchant.domain}}]
|
||||||
<span ng-show="!!$root.merchant.pr.ca"><i class="fi-lock"></i> {{$root.merchant.pr.ca}}</span>
|
<span ng-show="!!$root.merchant.pr.ca"><i class="fi-lock"></i> {{$root.merchant.pr.ca}}</span>
|
||||||
<span ng-show="!$root.merchant.pr.ca" style="color:red;weight:bold;"><i class="fi-unlock"></i> Untrusted</span>
|
<span ng-show="!$root.merchant.pr.ca" style="color:red;weight:bold;"><i class="fi-unlock"></i> Untrusted</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -170,7 +174,7 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-6 medium-6 small-6 columns text-left">
|
<div class="large-6 medium-6 small-6 columns text-left">
|
||||||
<a ng-click="cancelSend(sendForm)" class="button warning m0" ng-show="!!$root.merchant">
|
<a ng-click="cancelSend(sendForm)" class="button warning m0" ng-show="!!$root.merchant || isPayUri">
|
||||||
Cancel
|
Cancel
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue