Subversion Repositories wpShopGermany4

Rev

Rev 5485 | 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>

<style type="text/css">

    #addressBookWidgetDiv{ width:auto; height:228px; margin:15px 0; }
    #walletWidgetDiv { width:100%; height:228px; margin:15px 0; }
    #walletWidgetDiv iframe,
    #addressBookWidgetDiv iframe { max-width:100%; border:0px !important; }
    #LoginWithAmazon { float:right; }
    .wpsg_mod_paypalapi_button_wrap { float:left; }

</style>

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

<div class="wpsg_clear"></div>

<script>

    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(document).ready(function() {

        jQuery('.wpsg_checkoutbutton').hide();
        jQuery('.wpsg_amazonhandler').show();
        jQuery('#LoginWithAmazon').hide();

        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>