7735 |
daniel |
1 |
<?php
|
5485 |
thomas |
2 |
|
7735 |
daniel |
3 |
/**
|
|
|
4 |
* Template für die Integration von "Bezahlen mit Amazon" in den Warenkorb
|
|
|
5 |
*/
|
5485 |
thomas |
6 |
|
|
|
7 |
?>
|
7735 |
daniel |
8 |
|
5485 |
thomas |
9 |
<div id="LoginWithAmazon"></div>
|
|
|
10 |
|
|
|
11 |
<div class="wpsg_amazonhandler" id="addressBookWidgetDiv"></div>
|
|
|
12 |
<div class="wpsg_amazonhandler" id="walletWidgetDiv"></div>
|
|
|
13 |
|
7735 |
daniel |
14 |
<style type="text/css">
|
|
|
15 |
|
|
|
16 |
#addressBookWidgetDiv{ width:auto; height:228px; margin:15px 0; }
|
|
|
17 |
#walletWidgetDiv { width:100%; height:228px; margin:15px 0; }
|
|
|
18 |
#walletWidgetDiv iframe,
|
|
|
19 |
#addressBookWidgetDiv iframe { max-width:100%; border:0px !important; }
|
|
|
20 |
#LoginWithAmazon { float:right; }
|
|
|
21 |
.wpsg_mod_paypalapi_button_wrap { float:left; }
|
|
|
22 |
|
|
|
23 |
</style>
|
|
|
24 |
|
5485 |
thomas |
25 |
<input type="hidden" name="amazon[OrderReference]" id="wpsg_mod_amazon_OrderReference" value="" />
|
|
|
26 |
|
|
|
27 |
<div class="wpsg_clear"></div>
|
|
|
28 |
|
7735 |
daniel |
29 |
<script>
|
5485 |
thomas |
30 |
|
7735 |
daniel |
31 |
var authRequest;
|
5485 |
thomas |
32 |
|
7735 |
daniel |
33 |
OffAmazonPayments.Button('LoginWithAmazon', '<?php echo $this->get_option('wpsg_mod_amazon_seller_id'); ?>', {
|
5485 |
thomas |
34 |
|
7735 |
daniel |
35 |
type: "PwA",
|
|
|
36 |
color: "Gold",
|
|
|
37 |
size: "small",
|
|
|
38 |
language: "de-DE",
|
5485 |
thomas |
39 |
|
7735 |
daniel |
40 |
authorization: function() {
|
5485 |
thomas |
41 |
|
7735 |
daniel |
42 |
loginOptions = {
|
|
|
43 |
scope: "profile payments:widget payments:shipping_address payments:billing_address",
|
|
|
44 |
popup: true
|
|
|
45 |
};
|
5485 |
thomas |
46 |
|
7735 |
daniel |
47 |
authRequest = amazon.Login.authorize(loginOptions, "<?php echo $this->view['wpsg_mod_amazon']['redirectURL']; ?>");
|
5485 |
thomas |
48 |
|
7735 |
daniel |
49 |
},
|
5485 |
thomas |
50 |
|
7735 |
daniel |
51 |
onError: function(error) {
|
5485 |
thomas |
52 |
|
7735 |
daniel |
53 |
//console.log("Login: Es ist folgender Fehler aufgetreten: " + error.getErrorCode() + ' - ' + error.getErrorMessage());
|
|
|
54 |
alert("Login: Es ist folgender Fehler aufgetreten: " + error.getErrorCode() + ' - ' + error.getErrorMessage());
|
5485 |
thomas |
55 |
|
7735 |
daniel |
56 |
}
|
5485 |
thomas |
57 |
|
7735 |
daniel |
58 |
} );
|
5485 |
thomas |
59 |
|
7735 |
daniel |
60 |
<?php if (wpsg_isSizedString($this->view['wpsg_mod_amazon']['amazon_last_authorization_reference_id']) && $this->view['basket']['checkout']['payment'] == 3140) { ?>
|
5485 |
thomas |
61 |
|
7735 |
daniel |
62 |
jQuery(document).ready(function() {
|
5485 |
thomas |
63 |
|
7735 |
daniel |
64 |
jQuery('.wpsg_checkoutbutton').hide();
|
|
|
65 |
jQuery('.wpsg_amazonhandler').show();
|
|
|
66 |
jQuery('#LoginWithAmazon').hide();
|
|
|
67 |
|
|
|
68 |
new OffAmazonPayments.Widgets.AddressBook( {
|
|
|
69 |
|
|
|
70 |
sellerId: '<?php echo $this->get_option('wpsg_mod_amazon_seller_id'); ?>',
|
|
|
71 |
|
|
|
72 |
onOrderReferenceCreate: function(orderReference) {
|
|
|
73 |
|
|
|
74 |
var oID = orderReference.getAmazonOrderReferenceId();
|
|
|
75 |
|
|
|
76 |
jQuery('#wpsg_mod_amazon_OrderReference').val(oID);
|
|
|
77 |
jQuery('.wpsg_checkoutbutton').show();
|
|
|
78 |
|
|
|
79 |
},
|
|
|
80 |
|
|
|
81 |
onAddressSelect: function(orderReference) {
|
|
|
82 |
|
|
|
83 |
// Replace the following code with the action that you want to perform
|
|
|
84 |
// after the address is selected.
|
|
|
85 |
// The amazonOrderReferenceId can be used to retrieve
|
|
|
86 |
// the address details by calling the GetOrderReferenceDetails
|
|
|
87 |
// operation. If rendering the AddressBook and Wallet widgets on the
|
|
|
88 |
// same page, you should wait for this event before you render the
|
|
|
89 |
// Wallet widget for the first time.
|
|
|
90 |
// The Wallet widget will re-render itself on all subsequent
|
|
|
91 |
// onAddressSelect events, without any action from you. It is not
|
|
|
92 |
// recommended that you explicitly refresh it.
|
|
|
93 |
|
|
|
94 |
new OffAmazonPayments.Widgets.Wallet({
|
|
|
95 |
|
|
|
96 |
sellerId: '<?php echo $this->get_option('wpsg_mod_amazon_seller_id'); ?>',
|
|
|
97 |
|
|
|
98 |
onPaymentSelect: function(orderReference) {
|
|
|
99 |
|
|
|
100 |
// Replace this code with the action that you want to perform
|
|
|
101 |
// after the payment method is selected.
|
|
|
102 |
|
|
|
103 |
},
|
|
|
104 |
|
|
|
105 |
design: {
|
|
|
106 |
|
|
|
107 |
designMode: 'responsive'
|
|
|
108 |
|
|
|
109 |
},
|
|
|
110 |
|
|
|
111 |
onError: function(error) {
|
|
|
112 |
|
|
|
113 |
alert("Wallet: Es ist folgender Fehler aufgetreten: " + error.getErrorCode() + ' - ' + error.getErrorMessage());
|
|
|
114 |
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
}).bind("walletWidgetDiv");
|
|
|
118 |
|
|
|
119 |
},
|
|
|
120 |
|
|
|
121 |
design: {
|
|
|
122 |
|
|
|
123 |
designMode: 'responsive'
|
|
|
124 |
|
|
|
125 |
},
|
|
|
126 |
|
|
|
127 |
onError: function(error) {
|
|
|
128 |
|
|
|
129 |
alert("Payment: Es ist folgender Fehler aufgetreten: " + error.getErrorCode() + ' - ' + error.getErrorMessage());
|
|
|
130 |
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
} ).bind("addressBookWidgetDiv");
|
|
|
134 |
|
|
|
135 |
});
|
|
|
136 |
|
|
|
137 |
<?php } ?>
|
|
|
138 |
|
|
|
139 |
</script>
|