Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 560f409

Browse files
committed
Handle partial payments on transaction modal
1 parent a929e37 commit 560f409

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

js/templates/transactionModal.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h3 class="txt-bright"><%= polyglot.t('CheckExchanges') %> </h3>
4444
<div class="pull-left pad20Left txt-bright" style="width:255px;">
4545
<div class="txt-center row10 textSize16px">
4646
<%= polyglot.t('buyFlow.SendBTCtoAddress', {
47-
amount: ob.buyer_order.order.payment.amount,
47+
amount: ob.intlNumFormat(ob.orderDue, 20),
4848
recipient: '<a class="textSize11px" href="bitcoin:' + ob.buyer_order.order.payment.address + '?amount=' + ob.buyer_order.order.payment.amount + '&message=' + ob.vendor_offer.listing.item.title + '">' + ob.buyer_order.order.payment.address + '</a>'
4949
})
5050
%>
@@ -585,6 +585,11 @@ <h3 class="txt-bright"><%= polyglot.t('CheckExchanges') %> </h3>
585585
<div style="height: 264px;" class="scrollOverflowY customThemeScrollbar">
586586

587587
<div class="flexRow custCol-border borderBottom">
588+
<% if(ob.status == 0 && ob.transactionType == "purchases"){ %>
589+
<div class="flexRow rowItem padding15">
590+
You have paid <%= ob.intlNumFormat(ob.orderPaid, 8) %> out of <%= ob.intlNumFormat(ob.orderPrice, 8) %>
591+
</div>
592+
<% } %>
588593
<div class="flexRow rowItem padding15">
589594
<div class="flexCol-7 overflowHidden">
590595
<a href="#userPage/<%- ob.vendor_offer.listing.id.guid %>/listing/<%- ob.vendor_offer.listing.contract_id %>">

js/views/transactionModalVw.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,25 @@ module.exports = baseVw.extend({
142142
},
143143

144144
render: function () {
145-
var self = this;
145+
var self = this,
146+
orderPrice = 0,
147+
orderPaid = 0,
148+
orderDue = 0;
149+
146150
$('.js-loadingModal').addClass("hide");
147-
//this.model.set('status', this.status);
148151
//makde sure data is valid
149152
if (this.model.get('invalidData')){
150153
messageModal.show(window.polyglot.t('errorMessages.serverError', self.model.get('error')));
151154
return;
152155
}
153156

157+
//calculate how much has been paid
158+
orderPrice = this.model.get("buyer_order").order.payment.amount;
159+
__.each(this.model.get("bitcoin_txs"), function(payment){
160+
orderPaid += payment.value;
161+
});
162+
orderDue = orderPrice - orderPaid;
163+
154164
loadTemplate('./js/templates/transactionModal.html', function(loadedTemplate) {
155165
//hide the modal when it first loads
156166
self.parentEl.html(self.$el);
@@ -163,7 +173,10 @@ module.exports = baseVw.extend({
163173
status: self.status,
164174
avatarURL: self.avatarURL,
165175
avatar_hash: self.avatar_hash,
166-
orderID: self.orderID
176+
orderID: self.orderID,
177+
orderPrice: orderPrice,
178+
orderPaid: orderPaid,
179+
orderDue: orderDue
167180
})
168181
));
169182
// add blur to container
@@ -195,6 +208,10 @@ module.exports = baseVw.extend({
195208
this.status = 2;
196209
this.tabState = "summary";
197210
break;
211+
case "partial payment":
212+
this.status = 0;
213+
this.tabState = "summary";
214+
break;
198215
/* //this notification is not sent yet by the server
199216
case "payment released":
200217
this.status = 3;

0 commit comments

Comments
 (0)