5485 |
thomas |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
7110 |
thomas |
4 |
* Integration der Zahlung über Amazon in den Bestellabschluss
|
5485 |
thomas |
5 |
*/
|
|
|
6 |
|
|
|
7 |
?>
|
|
|
8 |
|
|
|
9 |
<?php if ($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE) { ?>
|
|
|
10 |
|
6069 |
thomas |
11 |
<p><?php echo __('Zahlung wurde erfolgreich mit AmazonPay abgewickelt.', 'wpsg'); ?></p>
|
5485 |
thomas |
12 |
|
|
|
13 |
<?php } else if ($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_PAST) { ?>
|
|
|
14 |
|
6069 |
thomas |
15 |
<p><?php echo __('Zahlung wurde bereits erfolgreich mit AmazonPay abgewickelt.', 'wpsg'); ?></p>
|
5485 |
thomas |
16 |
|
|
|
17 |
<?php } else if ($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_START || $this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_GO) { ?>
|
|
|
18 |
|
5519 |
thomas |
19 |
<p><?php echo __('Zahlung mittels der folgenden Zahlungsoption abschließen','wpsg'); ?></p>
|
|
|
20 |
|
5485 |
thomas |
21 |
<div id="PayWithAmazon" style="<?php echo (($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_GO)?'display:none':''); ?>"></div>
|
|
|
22 |
|
|
|
23 |
<script type="text/javascript">/* <![CDATA[ */
|
|
|
24 |
|
|
|
25 |
var authRequest;
|
|
|
26 |
|
|
|
27 |
OffAmazonPayments.Button('PayWithAmazon', '<?php echo $this->get_option('wpsg_mod_amazon_seller_id'); ?>', {
|
|
|
28 |
|
|
|
29 |
type: "PwA",
|
|
|
30 |
color: "Gold",
|
|
|
31 |
size: "small",
|
|
|
32 |
language: "de-DE",
|
|
|
33 |
|
|
|
34 |
authorization: function() {
|
|
|
35 |
|
|
|
36 |
loginOptions = {
|
|
|
37 |
scope: "profile payments:widget payments:shipping_address payments:billing_address",
|
|
|
38 |
popup: true
|
|
|
39 |
};
|
|
|
40 |
|
|
|
41 |
authRequest = amazon.Login.authorize(loginOptions, "<?php echo $this->view['wpsg_mod_amazon']['redirectURL']; ?>");
|
|
|
42 |
|
|
|
43 |
},
|
|
|
44 |
|
|
|
45 |
onError: function(error) {
|
|
|
46 |
|
|
|
47 |
console.log("Login: Es ist folgender Fehler aufgetreten: " + error.getErrorCode() + ' - ' + error.getErrorMessage());
|
|
|
48 |
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
} );
|
|
|
52 |
|
|
|
53 |
var autoRun = setInterval(function(){
|
|
|
54 |
|
|
|
55 |
if (jQuery('#PayWithAmazon img').length > 0)
|
|
|
56 |
{
|
|
|
57 |
|
|
|
58 |
//setTimeout(function(){ jQuery('#PayWithAmazon img').click(); }, 1000);
|
|
|
59 |
clearInterval(autoRun);
|
|
|
60 |
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
}, 100);
|
|
|
64 |
|
|
|
65 |
/* ]]> */</script>
|
|
|
66 |
|
|
|
67 |
<?php } ?>
|
|
|
68 |
|
|
|
69 |
<?php if ($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_GO) { ?>
|
|
|
70 |
|
|
|
71 |
<form id="wpsg_mod_amazon_paymentForm" method="POST" action="<?php echo $this->getUrl(wpsg_ShopController::URL_BASKET, 'wpsg_mod_amazon', 'return'); ?>">
|
|
|
72 |
|
|
|
73 |
<input type="hidden" name="order_id" value="<?php echo $_REQUEST['order_id']; ?>" />
|
|
|
74 |
<input type="hidden" name="wpsg_done" value="<?php echo $_REQUEST['wpsg_done']; ?>" />
|
|
|
75 |
<input type="hidden" name="amazon[OrderReference]" id="wpsg_mod_amazon_OrderReference" value="" />
|
|
|
76 |
|
|
|
77 |
<div id="walletWidgetDiv"></div>
|
|
|
78 |
|
|
|
79 |
<input type="submit" class="wpsg_button" name="submit" value="<?php echo __('Zahlung durchführen', 'wpsg'); ?>" id="wpsg_mod_amazon_doPayment" style="display:none;" />
|
|
|
80 |
<div class="wpsg_clear"></div>
|
|
|
81 |
|
|
|
82 |
</form>
|
|
|
83 |
|
|
|
84 |
<script type="text/javascript">/* <![CDATA[ */
|
|
|
85 |
|
|
|
86 |
new OffAmazonPayments.Widgets.Wallet( {
|
|
|
87 |
|
|
|
88 |
sellerId: '<?php echo $this->get_option('wpsg_mod_amazon_seller_id'); ?>',
|
|
|
89 |
|
|
|
90 |
onOrderReferenceCreate: function(orderReference) {
|
|
|
91 |
|
|
|
92 |
jQuery('#wpsg_mod_amazon_OrderReference').val(orderReference.getAmazonOrderReferenceId());
|
|
|
93 |
jQuery('#wpsg_mod_amazon_doPayment').show();
|
|
|
94 |
|
|
|
95 |
},
|
|
|
96 |
|
|
|
97 |
onPaymentSelect: function(orderReference) {
|
|
|
98 |
|
|
|
99 |
// Replace this code with the action that you want to perform
|
|
|
100 |
// after the payment method is selected.
|
|
|
101 |
|
|
|
102 |
},
|
|
|
103 |
|
|
|
104 |
design: {
|
|
|
105 |
|
|
|
106 |
designMode: 'responsive'
|
|
|
107 |
|
|
|
108 |
},
|
|
|
109 |
|
|
|
110 |
onError: function(error) {
|
|
|
111 |
|
|
|
112 |
jQuery('#wpsg_mod_amazon_paymentForm').hide();
|
|
|
113 |
jQuery('#PayWithAmazon').show();
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
} ).bind("walletWidgetDiv");
|
|
|
119 |
|
|
|
120 |
/* ]]> */</script>
|
|
|
121 |
<?php } ?>
|