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

Commit 62b3d74

Browse files
authored
Merge pull request #1772 from OpenBazaar/transactionFixes
Transaction fixes
2 parents 0af6b73 + 371bedf commit 62b3d74

File tree

5 files changed

+44
-40
lines changed

5 files changed

+44
-40
lines changed

css/obBase.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,6 +3065,11 @@ input[type="number"].fieldItem.fieldItem-withButton {
30653065
padding-left: 50px;
30663066
}
30673067

3068+
input[type="number"].fieldItem.spinButtons {
3069+
overflow: hidden;
3070+
padding-right: 25px;
3071+
}
3072+
30683073
.numberSpinnerUp,
30693074
.numberSpinnerDown {
30703075
cursor: pointer;

js/templates/buyDetails.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131
</div>
3232
<div class="flexCol-2">
33-
<div class="rowItem padding2015">
33+
<div class="rowItem padding0 paddingTop20">
3434
<form id="buyWizardQuantity" class="positionWrapper">
3535
<input type="number" step="1" min="1" class="fieldItem spinButtons js-buyWizardQuantity border1 custCol-border marginTop4" value="1"/>
3636
<div class="numberSpinnerUp"></div>
@@ -39,7 +39,7 @@
3939
</div>
4040
</div>
4141
<div class="flexCol-4 overflowHidden">
42-
<div class="rowItem padding2015 alignRight marginTop20">
42+
<div class="rowItem padding5 paddingTop20 alignRight marginTop20">
4343
<span class="noOverflow fontSize13 js-buyWizardBTCPrice"></span>
4444
<span class="noOverflow textOpacity75 fontSize13 js-buyWizardPrice">
4545
<% if(ob.userCurrencyCode != 'BTC'){ %>
@@ -51,7 +51,7 @@
5151
</div>
5252

5353
<!-- only display shipping if physical item -->
54-
<% if( ob.vendor_offer.listing.metadata.category === "physical good" ) { %>
54+
<% if( ob.vendor_offer.listing.metadata.category === "physical good" ) { %>
5555
<div class="flexRow custCol-border borderBottom">
5656
<div class="flexCol-8">
5757
<div class="rowItem padding2015">

js/views/buyAddressesVw.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var __ = require('underscore'),
44
$ = require('jquery'),
55
loadTemplate = require('../utils/loadTemplate'),
6-
baseVw = require('./baseVw'),
6+
baseVw = require('./baseVw'),
77
localize = require('../utils/localize');
88

99
module.exports = baseVw.extend({
@@ -36,7 +36,8 @@ module.exports = baseVw.extend({
3636
)
3737
);
3838
//this does not add it to the DOM, that is done by the parent view
39-
self.$('.js-buyWizardAddressRadio').eq(selected).prop('checked', true).trigger('click');
39+
self.$('.js-buyWizardAddressRadio').eq(selected).prop('checked', true);
40+
self.selectAddress(selected);
4041
//self.setAddress(selected);
4142
});
4243
return this;
@@ -46,8 +47,8 @@ module.exports = baseVw.extend({
4647
$(".js-buyWizardAddressNext").trigger( "click" );
4748
},
4849

49-
selectAddress: function(){
50-
var index = this.$el.find('.js-buyWizardAddressRadio:checked').val();
50+
selectAddress: function(selected){
51+
var index = selected || this.$el.find('.js-buyWizardAddressRadio:checked').val();
5152
this.setAddress(index);
5253
},
5354

js/views/buyWizardVw.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ module.exports = baseModal.extend({
230230
} else {
231231
this.model.set('selectedModerator', "");
232232
}
233-
233+
234234
this.$el.find('#BuyWizardPaymentType .js-buyWizardModNext').removeClass('disabled');
235235

236236
},
@@ -251,7 +251,7 @@ module.exports = baseModal.extend({
251251
this.$buyWizardMap.find('iframe').addClass('blurMore');
252252

253253
//set chosen inputs
254-
$('.chosen').chosen({
254+
$('.chosen').chosen({
255255
search_contains: true,
256256
no_results_text: window.polyglot.t('chosenJS.noResultsText'),
257257
placeholder_text_single: window.polyglot.t('chosenJS.placeHolderTextSingle'),
@@ -349,7 +349,7 @@ module.exports = baseModal.extend({
349349

350350
addressData.shipping_addresses = newAddresses;
351351

352-
saveToAPI(targetForm, this.userModel.toJSON(), self.model.get('serverUrl') + "settings", function(){
352+
saveToAPI(targetForm, this.userModel.toJSON(), app.serverConfigs.getActive().getServerBaseUrl() + "/settings", function(){
353353
self.$el.find('#buyWizardNameInput').val("");
354354
self.$el.find('#buyWizardStreetInput').val("");
355355
self.$el.find('#buyWizardCityInput').val("");
@@ -400,23 +400,23 @@ module.exports = baseModal.extend({
400400
addressString = address.street + ", " + address.city + ", " + address.state + " " + address.postal_code + " " + address.displayCountry;
401401
} else {
402402
// if address is invalid, we'll create a dummy address for which google maps will show a map of the world
403-
addressString = "123 Street, City, State 12345 Country";
403+
addressString = "123 Street, City, State 12345 Country";
404404
}
405405

406406
addressString = encodeURIComponent(addressString);
407407
var $iFrame = $('<iframe class="js-iframe-pending positionTop" width="525" height="250" frameborder="0" style="border:0; margin-top: 0; height: 250px; clip: rect(0,0,0,0)" />');
408-
408+
409409
if ($currentIframe.length) {
410410
this.$buyWizardMap.find('.js-mapSpinner').removeClass('hide');
411411
$iFrame.insertBefore($currentIframe);
412412
} else {
413413
this.$buyWizardMap.find('.mapWrap')
414414
.prepend($iFrame);
415415
}
416-
416+
417417
$iFrame.on('load', () => {
418418
this.$buyWizardMap.find('.js-mapSpinner').addClass('hide');
419-
419+
420420
$currentIframe.addClass('js-iframe-leaving')
421421
.fadeOut({
422422
duration: 'slow',
@@ -439,7 +439,7 @@ module.exports = baseModal.extend({
439439

440440
if (modForm[0].checkValidity()) {
441441
if (bitCoinReturnAddr != this.userModel.get('refund_address')) {
442-
saveToAPI(modForm, this.userModel.toJSON(), this.model.get('serverUrl') + "settings", function () {
442+
saveToAPI(modForm, this.userModel.toJSON(), app.serverConfigs.getActive().getServerBaseUrl() + "/settings", function () {
443443
window.obEventBus.trigger("updateUserModel");
444444
self.skipAddressCheck();
445445
},
@@ -490,7 +490,7 @@ module.exports = baseModal.extend({
490490
app.simpleMessageModal.open({
491491
title: window.polyglot.t('errorMessages.serverError'),
492492
message: window.polyglot.t('errorMessages.missingError')
493-
});
493+
});
494494
return;
495495
}
496496

@@ -524,7 +524,7 @@ module.exports = baseModal.extend({
524524

525525
this.buyRequest = $.ajax({
526526
type: "POST",
527-
url: self.model.get('serverUrl') + "purchase_contract",
527+
url: app.serverConfigs.getActive().getServerBaseUrl() + "/purchase_contract",
528528
contentType: false,
529529
processData: false,
530530
data: formData,
@@ -579,12 +579,12 @@ module.exports = baseModal.extend({
579579
totalBTCPrice = data.amount - this.partialPaymentAmount;
580580
this.$el.find('.js-buyWizardDetailsTotalBTC').text(templateHelpers.intlNumFormat(totalBTCPrice, 8));
581581
this.payURL = data.payment_address;
582-
582+
583583
payHREF = "bitcoin:"+ data.payment_address+"?amount="+totalBTCPrice;
584584
if (localStorage.getItem('AdditionalPaymentData') != "false") {
585585
payHREF += "&label="+storeName+"&message="+message;
586586
}
587-
587+
588588
this.hideMaps();
589589
this.$el.find('.js-buyWizardPay').removeClass('hide');
590590
dataURI = qr(payHREF, {type: 10, size: 10, level: 'M'});
@@ -631,13 +631,12 @@ module.exports = baseModal.extend({
631631
},
632632

633633
checkPayment: function(){
634-
var self = this,
635-
formData = new FormData();
634+
var formData = new FormData();
636635

637636
formData.append("order_id", this.orderID);
638637
$.ajax({ //this only triggers the server to send a new socket message
639638
type: "POST",
640-
url: self.model.get('serverUrl') + "check_for_payment",
639+
url: app.serverConfigs.getActive().getServerBaseUrl() + "/check_for_payment",
641640
contentType: false,
642641
processData: false,
643642
data: formData,
@@ -653,7 +652,7 @@ module.exports = baseModal.extend({
653652
new Notification(window.polyglot.t('buyFlow.paymentSent'), {
654653
silent: true
655654
});
656-
655+
657656
// play notification sound
658657
var notificationSound = document.createElement('audio');
659658
notificationSound.setAttribute('src', './audio/notification.mp3');
@@ -690,4 +689,4 @@ module.exports = baseModal.extend({
690689

691690
this.close();
692691
}
693-
});
692+
});

js/views/transactionModalVw.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ module.exports = baseModal.extend({
126126
app.simpleMessageModal.open({
127127
title: window.polyglot.t('errorMessages.getError'),
128128
message: '<i>' + window.polyglot.t('errorMessages.serverError') + '</i>'
129-
});
129+
});
130130
} else {
131131
app.simpleMessageModal.open({
132132
title: window.polyglot.t('errorMessages.getError'),
@@ -159,7 +159,7 @@ module.exports = baseModal.extend({
159159
app.simpleMessageModal.open({
160160
title: window.polyglot.t('errorMessages.serverError'),
161161
message: self.model.get('error')
162-
});
162+
});
163163
return;
164164
}
165165

@@ -187,7 +187,7 @@ module.exports = baseModal.extend({
187187
orderDue: orderDue
188188
})
189189
));
190-
190+
191191
baseModal.prototype.render.apply(self);
192192

193193
if (self.status == 0){
@@ -264,14 +264,14 @@ module.exports = baseModal.extend({
264264
if (localStorage.getItem('AdditionalPaymentData') != "false") {
265265
payHREF += "&message=" + this.model.get('vendor_offer').listing.item.title.substring(0, 20) + " " + this.orderID;
266266
}
267-
267+
268268
dataURI = qr(payHREF, {type: 10, size: 10, level: 'M'});
269269
this.$el.find('.js-transactionPayQRCode').attr('src', dataURI);
270270
} else {
271271
app.simpleMessageModal.open({
272272
title: window.polyglot.t('errorMessages.getError'),
273273
message: window.polyglot.t('errorMessages.serverError')
274-
});
274+
});
275275
}
276276
},
277277

@@ -311,7 +311,7 @@ module.exports = baseModal.extend({
311311
this.$el.find('.js-' + state).removeClass('hide');
312312
this.$el.find('.js-' + state + 'Tab').addClass('active').removeClass('hide');
313313
this.discussionForm.removeClass('formChecked');
314-
314+
315315
if (state == "discussion"){
316316
$.post(app.serverConfigs.getActive().getServerBaseUrl() + '/mark_discussion_as_read', {id: this.orderID});
317317
this.$('.js-unreadBadge').addClass('hide');
@@ -359,7 +359,7 @@ module.exports = baseModal.extend({
359359
this.$('.js-transactionShowContract').removeClass('hide');
360360
this.$('.js-transactionsConfirmOrderHolder').removeClass('bottom0');
361361
},
362-
362+
363363
showConfirmForm: function(){
364364
this.$('.js-transactionShowContract').addClass('hide');
365365
this.$('.js-transactionsConfirmOrderHolder').addClass('bottom0');
@@ -469,20 +469,19 @@ module.exports = baseModal.extend({
469469
},
470470

471471
checkPayment: function(){
472-
var self = this,
473-
formData = new FormData();
472+
var formData = new FormData();
474473

475474
formData.append("order_id", this.orderID);
476475
$.ajax({ //this only triggers the server to send a new socket message
477476
type: "POST",
478-
url: self.model.get('serverUrl') + "check_for_payment",
477+
url: app.serverConfigs.getActive().getServerBaseUrl() + "/check_for_payment",
479478
contentType: false,
480479
processData: false,
481480
data: formData,
482481
dataType: "json"
483482
});
484483
},
485-
484+
486485
getDiscussion: function(){
487486
var self = this;
488487
this.discussionCount = 0;
@@ -661,7 +660,7 @@ module.exports = baseModal.extend({
661660
},
662661

663662
copyTx: function(e){
664-
663+
665664
var tx = $(e.target).data('tx');
666665
clipboard.writeText(tx);
667666
},
@@ -743,10 +742,10 @@ module.exports = baseModal.extend({
743742
acceptResolution: function(e){
744743
var self = this,
745744
resData = {};
746-
745+
747746
$(e.target).addClass('loading');
748747
resData.order_id = this.orderID;
749-
748+
750749
saveToAPI(null, null, this.serverUrl + "release_funds", function(){
751750
self.status = 6;
752751
self.tabState = "summary";
@@ -831,8 +830,8 @@ module.exports = baseModal.extend({
831830
},
832831

833832
close: function() {
834-
this.confirmStatus && this.confirmStatus.remove();
833+
this.confirmStatus && this.confirmStatus.remove();
835834

836835
baseModal.prototype.close.apply(this, arguments);
837836
}
838-
});
837+
});

0 commit comments

Comments
 (0)