Skip to content

Commit

Permalink
Merge pull request #62 from shopware5/pt-13158/checkout-in-ios-webview
Browse files Browse the repository at this point in the history
PT-13158 - Fix checkout in ios web view
  • Loading branch information
mitelg authored Aug 28, 2024
2 parents a050436 + 342ead6 commit c3d5535
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
delete this.latestResponse;

if (jsonResponse.redirectTo) {
window.location.replace(jsonResponse.redirectTo);
$.redirectToUrl(jsonResponse.redirectTo);
return;
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@
return;
}

window.location.replace(this.sourcePlugin.opts.paypalErrorPage);
$.redirectToUrl(this.sourcePlugin.opts.paypalErrorPage);
};

$.createSwagPaymentPaypalCreateOrderFunction = function(createOrderUrl, sourcePlugin) {
Expand Down
10 changes: 10 additions & 0 deletions Resources/views/frontend/_public/src/js/jquery.redirect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function ($) {
/**
* @param { string } url
*/
$.redirectToUrl = function (url) {
setTimeout(function () {
window.location.replace(url);
}, 250);
};
})(jQuery);
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,19 @@

onApprove: function(data, actions) {
var params = {
token: data.orderID,
payerId: data.payerID,
basketId: this.opts.basketId
};
token: data.orderID,
payerId: data.payerID,
basketId: this.opts.basketId
},
url = $.swagPayPalRenderUrl(this.opts.returnUrl, params);

$.loadingIndicator.open({
openOverlay: true,
closeOnClick: false,
theme: 'light'
});

actions.redirect($.swagPayPalRenderUrl(this.opts.returnUrl, params));
$.redirectToUrl(url);
},

/**
Expand All @@ -205,7 +206,8 @@
extraParams = {};
}

window.location.replace($.swagPayPalRenderUrl(this.opts.paypalErrorPage, extraParams));
var url = $.swagPayPalRenderUrl(this.opts.paypalErrorPageUrl, extraParams);
$.redirectToUrl(url);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
theme: 'light'
});

actions.redirect(this.renderConfirmUrl(data));
var url = this.renderConfirmUrl(data);
$.redirectToUrl(url);
},

/**
Expand All @@ -123,7 +124,7 @@
},

onPayPalAPIError: function() {
window.location.replace(this.opts.paypalErrorPage);
$.redirectToUrl(this.opts.paypalErrorPage);
}
});
})(jQuery, window);
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@
jsonResponse = JSON.parse(response.responseText);

if (jsonResponse.redirectTo) {
window.location.replace(jsonResponse.redirectTo);
$.redirectToUrl(jsonResponse.redirectTo);

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
var url = new URL(window.location);
url.searchParams.set(this.opts.requireAddressPatchKey, requireAddressPatch.toString());

window.location.href = url.toString();
$.redirectToUrl(url.toString());
window.history.pushState({ path: url.toString() }, '', url.toString());
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,12 @@
data: data
}).then(function (response) {
var params = {
expressCheckout: response.expressCheckout,
token: response.token
};
expressCheckout: response.expressCheckout,
token: response.token
},
url = $.swagPayPalRenderUrl(me.opts.confirmUrl, params);

actions.redirect($.swagPayPalRenderUrl(me.opts.confirmUrl, params));
$.redirectToUrl(url);
}, function () {
me.onPayPalAPIError();
}).promise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@
theme: 'light'
});

return actions.redirect(this.renderConfirmUrl(data));
var url = this.renderConfirmUrl(data);
$.redirectToUrl(url);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
theme: 'light'
});

return actions.redirect(this.renderConfirmUrl(data));
var url = this.renderConfirmUrl(data);
$.redirectToUrl(url);
},

/**
Expand All @@ -186,7 +187,7 @@
},

onPayPalAPIError: function() {
window.location.replace(this.opts.paypalErrorPage);
$.redirectToUrl(this.opts.paypalErrorPage);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
},

redirectToSuccess() {
window.location = this.opts.successUrl;
$.redirectToUrl(this.opts.successUrl);
},

redirectToError() {
window.location = this.opts.errorUrl;
$.redirectToUrl(this.opts.errorUrl);
},

retryPolling() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,19 @@

onApprove: function(data, actions) {
var params = {
token: data.orderID,
payerId: data.payerID,
basketId: this.opts.basketId
};
token: data.orderID,
payerId: data.payerID,
basketId: this.opts.basketId
},
url = $.swagPayPalRenderUrl(this.opts.returnUrl, params);

$.loadingIndicator.open({
openOverlay: true,
closeOnClick: false,
theme: 'light'
});

actions.redirect($.swagPayPalRenderUrl(this.opts.returnUrl, params));
$.redirectToUrl(url);
},

destroy: function() {
Expand Down
1 change: 1 addition & 0 deletions Subscriber/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function onCollectJavascript()
$this->pluginDir . '/Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.pui-phone-number-field.js',
$this->pluginDir . '/Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.pui-birthday-field.js',
$this->pluginDir . '/Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.polling.js',
$this->pluginDir . '/Resources/views/frontend/_public/src/js/jquery.redirect.js',
];

return new ArrayCollection($jsPath);
Expand Down
11 changes: 10 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
<label lang="de">PayPal</label>
<label lang="en">PayPal</label>

<version>6.1.9</version>
<version>6.1.10</version>
<copyright>(c) by shopware AG</copyright>
<license>MIT</license>
<link>http://store.shopware.com</link>
<author>shopware AG</author>
<compatibility minVersion="5.2.27" maxVersion="5.99.99"/>

<changelog version="6.1.10">
<changes lang="de">
PT-13158 - Fehler während des Bestellabschlusses in iOS Web-Views behoben;
</changes>
<changes lang="en">
PT-13158 - Fix error during order checkout in iOS web views;
</changes>
</changelog>

<changelog version="6.1.9">
<changes lang="de">
PT-13158 - Fehler beim Laden des PayPal-Buttons für den Bestellabschluss in Web-Views behoben;
Expand Down

0 comments on commit c3d5535

Please sign in to comment.