Subversion Repositories wpShopGermany4

Rev

Blame | Last modification | View Log | RSS feed

<?php
        
        declare(strict_types=1);
        
        /**
         * @author: daniel
         * @date: 09.06.24
         * @time: 12:04
         */
        
        namespace wpsg;
        
?>

<?php echo GiroPayPalAPI::getInstance()->integrateSDK(); ?>

<script>
 
        paypal.PaymentFields({
                fundingSource: paypal.FUNDING.GIROPAY,
                style: {
                        variables: {},
                        rules: {},
                },
                onInit: (data, actions) => {
                
                        const form = document.querySelector("form#wpsg_checkout_form");
                 
                        form.addEventListener("submit", (e) => {
                                
                                const formData = new FormData(form);
                                const paymentSource = formData.get("wpsg[checkout][payment]");
                                
                                if (paymentSource === '10_1') {

                                        e.preventDefault();

                                        actions.validate().then((valid) => {

                                                if (valid) {

                                                        window.location.href = '<?php echo $this->getUrl(\wpsg_ShopController::URL_BASKET, 'wpsg_mod_paypalapi', 'giroPaySet', [], true); ?>';

                                                }

                                        });

                                }

                        });

                },
                fields: {
                        name: {
                                value: "<?php echo ($_SESSION['wpsg']['checkout']['vname']??'').' '.($_SESSION['wpsg']['checkout']['name']??''); ?>"
                        },
                },
        }).render("#giropay-container");
        
</script>