Subversion Repositories wpShopGermany4

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8420 daniel 1
<?php
2
 
3
	declare(strict_types=1);
4
 
5
	/**
6
	 * @author: daniel
7
	 * @date: 09.06.24
8
	 * @time: 12:04
9
	 */
10
 
11
	namespace wpsg;
12
 
13
?>
14
 
15
<?php echo GiroPayPalAPI::getInstance()->integrateSDK(); ?>
16
 
17
<script>
18
 
19
	paypal.PaymentFields({
20
		fundingSource: paypal.FUNDING.GIROPAY,
21
		style: {
22
			variables: {},
23
			rules: {},
24
		},
25
		onInit: (data, actions) => {
26
 
27
			const form = document.querySelector("form#wpsg_checkout_form");
28
 
29
			form.addEventListener("submit", (e) => {
30
 
31
				const formData = new FormData(form);
32
				const paymentSource = formData.get("wpsg[checkout][payment]");
33
 
34
				if (paymentSource === '10_1') {
35
 
36
					e.preventDefault();
37
 
38
					actions.validate().then((valid) => {
39
 
40
						if (valid) {
41
 
42
							window.location.href = '<?php echo $this->getUrl(\wpsg_ShopController::URL_BASKET, 'wpsg_mod_paypalapi', 'giroPaySet', [], true); ?>';
43
 
44
						}
45
 
46
					});
47
 
48
				}
49
 
50
			});
51
 
52
		},
53
		fields: {
54
			name: {
55
				value: "<?php echo ($_SESSION['wpsg']['checkout']['vname']??'').' '.($_SESSION['wpsg']['checkout']['name']??''); ?>"
56
			},
57
		},
58
	}).render("#giropay-container");
59
 
60
</script>