blob: 8f2c96ce706d5d090d3f8f00bc9ddaac9c1735c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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>
|