Subversion Repositories wpShopGermany4

Rev

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

<?php 

        /**
         * Template für die Integration von "Bezahlen mit Amazon" in den Warenkorb
         */

?>
 
<div id="LoginWithAmazon"></div>

<div class="wpsg_amazonhandler" id="addressBookWidgetDiv"></div>
<div class="wpsg_amazonhandler" id="walletWidgetDiv"></div>

<input type="hidden" name="amazon[OrderReference]" id="wpsg_mod_amazon_OrderReference" value="" />

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

        OffAmazonPayments.Button('LoginWithAmazon', '<?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());
                        alert("Login: Es ist folgender Fehler aufgetreten: " + error.getErrorCode() + ' - ' + error.getErrorMessage());
                                
                } 
                
        } );

        <?php if (wpsg_isSizedString($this->view['wpsg_mod_amazon']['amazon_last_authorization_reference_id']) && $this->view['basket']['checkout']['payment'] == 3140) { ?>

        jQuery('.wpsg_checkoutbutton').hide();
        jQuery('.wpsg_amazonhandler').show();
        
        new OffAmazonPayments.Widgets.AddressBook( {
                
            sellerId: '<?php echo $this->get_option('wpsg_mod_amazon_seller_id'); ?>',

            onOrderReferenceCreate: function(orderReference) {

                var oID = orderReference.getAmazonOrderReferenceId();
                
                        jQuery('#wpsg_mod_amazon_OrderReference').val(oID);
                        jQuery('.wpsg_checkoutbutton').show();
                                     
            },
            
            onAddressSelect: function(orderReference) {
 
                    // Replace the following code with the action that you want to perform
                    // after the address is selected.
                    // The amazonOrderReferenceId can be used to retrieve
                // the address details by calling the GetOrderReferenceDetails
                    // operation. If rendering the AddressBook and Wallet widgets on the
                    // same page, you should wait for this event before you render the
                // Wallet widget for the first time.
                    // The Wallet widget will re-render itself on all subsequent
                    // onAddressSelect events, without any action from you. It is not
                // recommended that you explicitly refresh it.

                        new OffAmazonPayments.Widgets.Wallet({

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

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

                        alert("Wallet: Es ist folgender Fehler aufgetreten: " + error.getErrorCode() + ' - ' + error.getErrorMessage());
                             
                    }
                    
                }).bind("walletWidgetDiv");
                  
            },
            
            design: {
                    
              designMode: 'responsive'
                      
            },
            
            onError: function(error) {

                alert("Payment: Es ist folgender Fehler aufgetreten: " + error.getErrorCode() + ' - ' + error.getErrorMessage());
                       
            }
            
        } ).bind("addressBookWidgetDiv");

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