summaryrefslogtreecommitdiff
path: root/views/mods/mod_amazon/order_done.phtml
blob: a0eb84398fcadf7595a5666756cb87147c65c383 (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
<?php

	/**
	 * Integration der Zahlung über Amazon in den Bestellabschluss
	 */

?>

<?php if ($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE) { ?>

<p><?php echo __('Zahlung wurde erfolgreich mit AmazonPay abgewickelt.', 'wpsg'); ?></p>

<?php } else if ($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_PAST) { ?>

<p><?php echo __('Zahlung wurde bereits erfolgreich mit AmazonPay abgewickelt.', 'wpsg'); ?></p>

<?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) { ?>

<p><?php echo __('Zahlung mittels der folgenden Zahlungsoption abschließen','wpsg'); ?></p>

<div id="PayWithAmazon" style="<?php echo (($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_GO)?'display:none':''); ?>"></div>

<script type="text/javascript">/* <![CDATA[ */
 
	var authRequest; 

	OffAmazonPayments.Button('PayWithAmazon', '<?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());
				
		} 
	        
	} );

	var autoRun = setInterval(function(){ 

		if (jQuery('#PayWithAmazon img').length > 0)
		{

			//setTimeout(function(){ jQuery('#PayWithAmazon img').click(); }, 1000);
			clearInterval(autoRun);
		
		}

	}, 100);

/* ]]> */</script>
	
<?php } ?>

<?php if ($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_GO) { ?>

<form id="wpsg_mod_amazon_paymentForm" method="POST" action="<?php echo $this->getUrl(wpsg_ShopController::URL_BASKET, 'wpsg_mod_amazon', 'return'); ?>">
	
	<input type="hidden" name="order_id" value="<?php echo $_REQUEST['order_id']; ?>" />
	<input type="hidden" name="wpsg_done" value="<?php echo $_REQUEST['wpsg_done']; ?>" />	
	<input type="hidden" name="amazon[OrderReference]" id="wpsg_mod_amazon_OrderReference" value="" />
	
	<div id="walletWidgetDiv"></div>
	
	<input type="submit" class="wpsg_button" name="submit" value="<?php echo __('Zahlung durchführen', 'wpsg'); ?>" id="wpsg_mod_amazon_doPayment" style="display:none;" />
	<div class="wpsg_clear"></div>
	
</form>

<script type="text/javascript">/* <![CDATA[ */
                                            
	new OffAmazonPayments.Widgets.Wallet( {

		sellerId: '<?php echo $this->get_option('wpsg_mod_amazon_seller_id'); ?>',

		onOrderReferenceCreate: function(orderReference) {

			jQuery('#wpsg_mod_amazon_OrderReference').val(orderReference.getAmazonOrderReferenceId());
			jQuery('#wpsg_mod_amazon_doPayment').show();

		},
		
		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) {

			jQuery('#wpsg_mod_amazon_paymentForm').hide();
			jQuery('#PayWithAmazon').show();
			
	   	     
		}
	    	    
	} ).bind("walletWidgetDiv");
	    	
/* ]]> */</script>
<?php } ?>