Skip to content

Commit c3d5535

Browse files
authored
Merge pull request #62 from shopware5/pt-13158/checkout-in-ios-webview
PT-13158 - Fix checkout in ios web view
2 parents a050436 + 342ead6 commit c3d5535

13 files changed

+54
-27
lines changed

Resources/views/frontend/_public/src/js/jquery.create_order_function.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
delete this.latestResponse;
4242

4343
if (jsonResponse.redirectTo) {
44-
window.location.replace(jsonResponse.redirectTo);
44+
$.redirectToUrl(jsonResponse.redirectTo);
4545
return;
4646
}
4747
}
@@ -121,7 +121,7 @@
121121
return;
122122
}
123123

124-
window.location.replace(this.sourcePlugin.opts.paypalErrorPage);
124+
$.redirectToUrl(this.sourcePlugin.opts.paypalErrorPage);
125125
};
126126

127127
$.createSwagPaymentPaypalCreateOrderFunction = function(createOrderUrl, sourcePlugin) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(function ($) {
2+
/**
3+
* @param { string } url
4+
*/
5+
$.redirectToUrl = function (url) {
6+
setTimeout(function () {
7+
window.location.replace(url);
8+
}, 250);
9+
};
10+
})(jQuery);

Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified-sepa.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,19 @@
183183

184184
onApprove: function(data, actions) {
185185
var params = {
186-
token: data.orderID,
187-
payerId: data.payerID,
188-
basketId: this.opts.basketId
189-
};
186+
token: data.orderID,
187+
payerId: data.payerID,
188+
basketId: this.opts.basketId
189+
},
190+
url = $.swagPayPalRenderUrl(this.opts.returnUrl, params);
190191

191192
$.loadingIndicator.open({
192193
openOverlay: true,
193194
closeOnClick: false,
194195
theme: 'light'
195196
});
196197

197-
actions.redirect($.swagPayPalRenderUrl(this.opts.returnUrl, params));
198+
$.redirectToUrl(url);
198199
},
199200

200201
/**
@@ -205,7 +206,8 @@
205206
extraParams = {};
206207
}
207208

208-
window.location.replace($.swagPayPalRenderUrl(this.opts.paypalErrorPage, extraParams));
209+
var url = $.swagPayPalRenderUrl(this.opts.paypalErrorPageUrl, extraParams);
210+
$.redirectToUrl(url);
209211
}
210212
});
211213

Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.advanced-credit-debit-card-fallback.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
theme: 'light'
105105
});
106106

107-
actions.redirect(this.renderConfirmUrl(data));
107+
var url = this.renderConfirmUrl(data);
108+
$.redirectToUrl(url);
108109
},
109110

110111
/**
@@ -123,7 +124,7 @@
123124
},
124125

125126
onPayPalAPIError: function() {
126-
window.location.replace(this.opts.paypalErrorPage);
127+
$.redirectToUrl(this.opts.paypalErrorPage);
127128
}
128129
});
129130
})(jQuery, window);

Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.advanced-credit-debit-card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@
387387
jsonResponse = JSON.parse(response.responseText);
388388

389389
if (jsonResponse.redirectTo) {
390-
window.location.replace(jsonResponse.redirectTo);
390+
$.redirectToUrl(jsonResponse.redirectTo);
391391

392392
return;
393393
}

Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.express-address-patch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
var url = new URL(window.location);
6666
url.searchParams.set(this.opts.requireAddressPatchKey, requireAddressPatch.toString());
6767

68-
window.location.href = url.toString();
68+
$.redirectToUrl(url.toString());
6969
window.history.pushState({ path: url.toString() }, '', url.toString());
7070
},
7171

Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.express-checkout-button.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,12 @@
371371
data: data
372372
}).then(function (response) {
373373
var params = {
374-
expressCheckout: response.expressCheckout,
375-
token: response.token
376-
};
374+
expressCheckout: response.expressCheckout,
375+
token: response.token
376+
},
377+
url = $.swagPayPalRenderUrl(me.opts.confirmUrl, params);
377378

378-
actions.redirect($.swagPayPalRenderUrl(me.opts.confirmUrl, params));
379+
$.redirectToUrl(url);
379380
}, function () {
380381
me.onPayPalAPIError();
381382
}).promise();

Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.in-context-checkout.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@
208208
theme: 'light'
209209
});
210210

211-
return actions.redirect(this.renderConfirmUrl(data));
211+
var url = this.renderConfirmUrl(data);
212+
$.redirectToUrl(url);
212213
},
213214

214215
/**

Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.pay-later.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@
167167
theme: 'light'
168168
});
169169

170-
return actions.redirect(this.renderConfirmUrl(data));
170+
var url = this.renderConfirmUrl(data);
171+
$.redirectToUrl(url);
171172
},
172173

173174
/**
@@ -186,7 +187,7 @@
186187
},
187188

188189
onPayPalAPIError: function() {
189-
window.location.replace(this.opts.paypalErrorPage);
190+
$.redirectToUrl(this.opts.paypalErrorPage);
190191
}
191192
});
192193

Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.polling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
},
4444

4545
redirectToSuccess() {
46-
window.location = this.opts.successUrl;
46+
$.redirectToUrl(this.opts.successUrl);
4747
},
4848

4949
redirectToError() {
50-
window.location = this.opts.errorUrl;
50+
$.redirectToUrl(this.opts.errorUrl);
5151
},
5252

5353
retryPolling() {

0 commit comments

Comments
 (0)