diff options
Diffstat (limited to 'views/mods/mod_amazon_v2/overview_button.phtml')
| -rw-r--r-- | views/mods/mod_amazon_v2/overview_button.phtml | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/views/mods/mod_amazon_v2/overview_button.phtml b/views/mods/mod_amazon_v2/overview_button.phtml new file mode 100644 index 0000000..8f2c96c --- /dev/null +++ b/views/mods/mod_amazon_v2/overview_button.phtml @@ -0,0 +1,47 @@ +<?php
+
+ /**
+ *
+ */
+
+?>
+
+<script async="async" src="https://static-eu.payments-amazon.com/OffAmazonPayments/de/sandbox/lpa/js/Widgets.js"></script>
+
+<div id="buy-now">JETZT kaufen</div>
+
+<script>
+
+ var sellerId = '<?php echo $this->get_option('wpsg_mod_amazon_v2_seller_id'); ?>';
+ var id = '<?php echo $_SESSION['wpsg_mod_amazon_v2_amazonCheckoutSessionId']; ?>';
+ var buyNowBtn = document.getElementById("buy-now");
+
+ buyNowBtn.addEventListener('click', function () {
+
+ OffAmazonPayments.initConfirmationFlow(sellerId, id, function(confirmationFlow) {
+
+ placeOrder(confirmationFlow);
+
+ });
+
+ });
+
+ function placeOrder(confirmationFlow) {
+
+ jQuery.ajax({
+ url: '<?php echo $this->getUrl(wpsg_ShopController::URL_BASKET, 'wpsg_mod_amazon_v2', 'placeOrder', [], true) ?>',
+success: function (data) {
+confirmationFlow.success(); // continue Amazon Pay hosted site
+},
+error: function (data) { // called on ajax error and timeout
+confirmationFlow.error(); // abort Amazon Pay initConfirmationFlow
+// you might want to add additional error handling
+},
+timeout: "your timeout value" //specify your timeout value (for example, 3000)
+//If the ajax request takes longer than this timeout (in ms), the error callback
+//will be called
+});
+
+ }
+
+</script>
\ No newline at end of file |
