Subversion Repositories wpShopGermany4

Rev

Rev 5519 | Rev 7110 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

        /**
         * Integration der Zahlung über Amazon in den Bestellabschluß
         */

?>

<?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 } ?>