Subversion Repositories wpShopGermany4

Rev

Rev 7110 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
7756 daniel 23
<script type="text/javascript">
5485 thomas 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
 
7756 daniel 55
		if (jQuery('#PayWithAmazon img').length > 0) {
5485 thomas 56
 
57
			//setTimeout(function(){ jQuery('#PayWithAmazon img').click(); }, 1000);
58
			clearInterval(autoRun);
59
 
60
		}
61
 
62
	}, 100);
63
 
7756 daniel 64
</script>
5485 thomas 65
 
66
<?php } ?>
67
 
68
<?php if ($this->view['wpsg_mod_amazon']['state'] === wpsg_mod_amazon::ORDER_DONE_GO) { ?>
69
 
70
<form id="wpsg_mod_amazon_paymentForm" method="POST" action="<?php echo $this->getUrl(wpsg_ShopController::URL_BASKET, 'wpsg_mod_amazon', 'return'); ?>">
71
 
72
	<input type="hidden" name="order_id" value="<?php echo $_REQUEST['order_id']; ?>" />
73
	<input type="hidden" name="wpsg_done" value="<?php echo $_REQUEST['wpsg_done']; ?>" />
74
	<input type="hidden" name="amazon[OrderReference]" id="wpsg_mod_amazon_OrderReference" value="" />
75
 
7756 daniel 76
	<div id="walletWidgetDiv"></div><br />
5485 thomas 77
 
78
	<input type="submit" class="wpsg_button" name="submit" value="<?php echo __('Zahlung durchführen', 'wpsg'); ?>" id="wpsg_mod_amazon_doPayment" style="display:none;" />
79
	<div class="wpsg_clear"></div>
80
 
81
</form>
82
 
7756 daniel 83
<script>
84
 
85
    jQuery('#walletWidgetDiv').show();
86
 
5485 thomas 87
	new OffAmazonPayments.Widgets.Wallet( {
88
 
89
		sellerId: '<?php echo $this->get_option('wpsg_mod_amazon_seller_id'); ?>',
90
 
91
		onOrderReferenceCreate: function(orderReference) {
92
 
93
			jQuery('#wpsg_mod_amazon_OrderReference').val(orderReference.getAmazonOrderReferenceId());
94
			jQuery('#wpsg_mod_amazon_doPayment').show();
95
 
96
		},
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
			jQuery('#wpsg_mod_amazon_paymentForm').hide();
114
			jQuery('#PayWithAmazon').show();
115
 
116
 
117
		}
118
 
119
	} ).bind("walletWidgetDiv");
120
 
7756 daniel 121
</script>
5485 thomas 122
<?php } ?>