summaryrefslogtreecommitdiff
path: root/views/mods/mod_amazon/basket_inner_prebutton.phtml
blob: 628ec683feb5d1111f0e0afda605c1407a9503f0 (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
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
<?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>

<input type="hidden" name="amazon[OrderReference]" id="wpsg_mod_amazon_OrderReference" value="" />

<div class="wpsg_clear"></div>
 
<script type="text/javascript">/* <![CDATA[ */
 
	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('.wpsg_checkoutbutton').hide();
	jQuery('.wpsg_amazonhandler').show();
	
	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>