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