Blame | Last modification | View Log | RSS feed
<?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>