Improves datetime. Adds invoice URL

This commit is contained in:
Gustavo Maximiliano Cortez 2016-05-16 17:51:26 -03:00
commit 05e57983c6
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 29 additions and 10 deletions

View file

@ -61,7 +61,7 @@
</div>
<div class="large-5 medium-5 small-5 columns text-right">
<span class="text-warning" ng-if="item.status == 'ERROR'">Error</span>
<span class="text-light" ng-if="item.status != 'ERROR'">{{item.date * 1000 | amCalendar}}</span>
<span class="text-light" ng-if="item.status != 'ERROR'">{{item.date * 1000 | amTimeAgo}}</span>
</div>
<div class="large-1 medium-1 small-1 columns text-right">
<i class="icon-arrow-right3 size-18"></i>

View file

@ -108,7 +108,7 @@
<div class="tu text-gray size-12 text-left">BitPay invoice</div>
<div class="text-bold size-16 m5t text-left">{{buy.giftCard.bitpayInvoiceId}}</div>
<button class="m20t button outline round dark-gray tiny"
ng-click="$root.openExternalLink('https://bitpay.com/invoice/' + buy.giftCard.bitpayInvoiceId)">
ng-click="$root.openExternalLink(buy.giftCard.bitpayInvoiceUrl)">
<span class="text-gray">View invoice</span>
</button>
</div>

View file

@ -25,18 +25,24 @@
</div>
<ul class="no-bullet size-14">
<li class="line-b p10 oh">
<li class="line-b p10 oh pointer" ng-click="$root.openExternalLink()">
<i class="icon-arrow-right3 size-24 right text-bold"></i>
<span class="text-gray">Claim code</span>
<span class="text-bold right enable_text_select">{{card.gcClaimCode}}</span>
</li>
<li class="line-b p10 oh">
<span class="text-gray">Created at</span>
<span class="test-gray right enable_text_select">{{card.date * 1000 | amDateFormat:'MM/DD/YYYY HH:mm a'}}</span>
</li>
<li class="line-b p10 oh">
<span class="text-gray">Status</span>
<span class="text-success right" ng-if="card.status == 'SUCCESS'">Completed</span>
<span class="text-info right" ng-if="card.status == 'PENDING'">Pending</span>
<span class="text-warning right" ng-if="card.status == 'ERROR'">Error</span>
</li>
<li class="line-b p10 oh">
<span class="text-gray">BitPay Invoice ID</span>
<li class="line-b p10 oh pointer" ng-click="$root.openExternalLink(card.bitpayInvoiceUrl)">
<i class="icon-arrow-right3 size-24 right text-gray"></i>
<span class="text-gray">BitPay Invoice</span>
<span class="text-gray right enable_text_select">{{card.bitpayInvoiceId}}</span>
</li>
</ul>

View file

@ -169,7 +169,8 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
var gift = {
amount: dataSrc.price,
currencyCode: dataSrc.currency,
bitpayInvoiceId: data.data.id
bitpayInvoiceId: data.data.id,
bitpayInvoiceUrl: data.data.url
};
self.loading = 'Buying gift card...';
amazonService.buyGiftCard(gift, function(err, giftCard) {

View file

@ -19,7 +19,8 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
"gcExpirationDate":null,
"gcId":"A2GCN9BRX5QS76",
"status":"SUCCESS",
"bitpayInvoiceId":"NJtevvEponHbQVmYoL7FYp"
"bitpayInvoiceId":"NJtevvEponHbQVmYoL7FYp",
"bitpayInvoiceUrl":"http://test.bitpay.com/invoice?id=XwrLryQEypTKg4nq37t3bN"
};
root.setCredentials = function(network) {
@ -36,7 +37,7 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
};
};
var _getBitPay = function(endpoint, token) {
var _getBitPay = function(endpoint) {
return {
method: 'GET',
url: credentials.BITPAY_API + endpoint,
@ -67,8 +68,18 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
$log.info('BitPay Create Invoice: SUCCESS');
return cb(null, data.data);
}, function(data) {
$log.error('BitPay Create Invoice: ERROR ' + data.statusText);
return cb(data);
$log.error('BitPay Create Invoice: ERROR ' + data.data.error);
return cb(data.data.error);
});
};
root.getBitPayInvoice = function(id, cb) {
$http(_getBitPay('/invoices/' + id)).then(function(data) {
$log.info('BitPay Get Invoice: SUCCESS');
return cb(null, data.data);
}, function(data) {
$log.error('BitPay Get Invoice: ERROR ' + data.data.error);
return cb(data.data.error);
});
};
@ -112,6 +123,7 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
saveData.cardInfo.value.amount = gift.amount;
saveData.cardInfo.value.currencyCode = gift.currencyCode;
saveData['bitpayInvoiceId'] = gift.bitpayInvoiceId;
saveData['bitpayInvoiceUrl'] = gift.bitpayInvoiceUrl;
saveData['date'] = newId;
root.saveGiftCard(saveData, null, function(err) {
return cb(null, fakeData);