发送给用户在表单中输入的贝宝数据

时间:2020-02-13 11:41:54

标签: jquery

我没有找到想要的东西,并且打开了一个新主题。我正在将电子商务系统集成到我的网站中,看来一切正常! 我只想了解如何将用户在网站表单中输入的信息(例如姓名/姓氏,地址等)转发给PayPal!我已经在PayPal结帐表格中输入了所有可能的变量,但是当数据在PayPal网站上提交时,除了用户输入的数据之外,所有内容(物品,数量,总数等)都会显示出来。显示已经在Paypal上注册的用户地址,但不显示在我的网站上输入的数据。我读到您必须输入变量,并输入了进行测试的可能性,但是它不起作用。 我希望你能帮助我。

<form id="paypal-form" action="" method="post">
<input type="hidden" name="cmd" value="_ext-enter" />
<input type="hidden" name="redirect_cmd" value="_cart">
<input type="hidden" name="business" value="business@example.com" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="email" value="1" />
<input type="hidden" name="first_name" value="1" />
<input type="hidden" name="last_name" value="1" />
<input type="hidden" name="address1" value="1" />
<input type="hidden" name="address2" value="1" />
<input type="hidden" name="city" value="1" />
<input type="hidden" name="state" value="1" />
<input type="hidden" name="zip" value="1" />
<input type="hidden" name="day_phone_a" value="1" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="item_number" value="1" />
<input type="hidden" name="notify_url" value="http://www.example.com/shop.html" />
<input type="hidden" name="cancel_return" value="http://www.example.com/shop.html" />
<input type="hidden" name="image_url" value="1" />
<input type="hidden" name="cs" value="1" />
<input type="hidden" name="custom" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="Ic" value="US">
<input type="hidden" name="item_name" value="my site" />
<input type="hidden" name="amount" value="2" />
<input type="hidden" name="shipping" value="2">
<input type="hidden" name="return" value="http://www.example.com/shop.html">
<input type="hidden" name="rm" value="1">
<input type="submit" id="paypal-btn" class="btn" value="Pay with PayPal" />
</form>

jQuery代码

    // Add the required hidden values to the PayPal form before submitting

    populatePayPalForm: function() {
        var self = this;
        if( self.$paypalForm.length ) {
            var $form = self.$paypalForm;
            var cart = self._toJSONObject( self.storage.getItem( self.cartName ) );
            var shipping = self.storage.getItem( self.shippingRates );
            var numShipping = self._convertString( shipping );
            var cartItems = cart.items; 
            var singShipping = Math.floor( numShipping / cartItems.length );

            $form.attr( "action", self.paypalURL );
            $form.find( "input[name='business']" ).val( self.paypalBusinessEmail );
            $form.find( "input[name='currency_code']" ).val( self.paypalCurrency );

            for( var i = 0; i < cartItems.length; ++i ) {
                var cartItem = cartItems[i];
                var n = i + 1;
                var name = cartItem.product;
                var price = cartItem.price;
                var qty = cartItem.qty;

                $( "<div/>" ).html( "<input type='hidden' name='quantity_" + n + "' value='" + qty + "'/>" ).
                insertBefore( "#paypal-btn" );
                $( "<div/>" ).html( "<input type='hidden' name='item_name_" + n + "' value='" + name + "'/>" ).
                insertBefore( "#paypal-btn" );
                $( "<div/>" ).html( "<input type='hidden' name='item_number_" + n + "' value='Art. " + name + "'/>" ).
                insertBefore( "#paypal-btn" );
                $( "<div/>" ).html( "<input type='hidden' name='amount_" + n + "' value='" + self._formatNumber( price, 2 ) + "'/>" ).
                insertBefore( "#paypal-btn" );
                $( "<div/>" ).html( "<input type='hidden' name='shipping_" + n + "' value='" + self._formatNumber( singShipping, 2 ) + "'/>" ).
                insertBefore( "#paypal-btn" );

            }



        }
    },



    // Displays user information

    displayUserDetails: function() {
        if( this.$userDetails.length ) {
            if( this.storage.getItem( "shipping-name" ) == null ) {
                var name = this.storage.getItem( "billing-name" );
                var email = this.storage.getItem( "billing-email" );
                var phone = this.storage.getItem( "billing-phone" );
                var city = this.storage.getItem( "billing-city" );
                var province = this.storage.getItem( "billing-province" );
                var address = this.storage.getItem( "billing-address" );
                var zip = this.storage.getItem( "billing-zip" );
                var country = this.storage.getItem( "billing-country" );

                var html = "<div class='detail'>";
                    html += "<h2>Fatturazione e spedizione</h2>";
                    html += "<ul>";
                    html += "<li>" + name + "</li>";
                    html += "<li>" + email + "</li>";
                    html += "<li>" + phone + "</li>";
                    html += "<li>" + city + "</li>";
                    html += "<li>" + province + "</li>";
                    html += "<li>" + address + "</li>";
                    html += "<li>" + zip + "</li>";
                    html += "<li>" + country + "</li>";
                    html += "</ul></div>";

                this.$userDetails[0].innerHTML = html;
            } else {
                var name = this.storage.getItem( "billing-name" );
                var email = this.storage.getItem( "billing-email" );
                var phone = this.storage.getItem( "billing-phone" );
                var city = this.storage.getItem( "billing-city" );
                var province = this.storage.getItem( "billing-province" );
                var address = this.storage.getItem( "billing-address" );
                var zip = this.storage.getItem( "billing-zip" );
                var country = this.storage.getItem( "billing-country" );

                var sName = this.storage.getItem( "shipping-name" );
                var sCity = this.storage.getItem( "shipping-city" );
                var sProvince = this.storage.getItem( "shipping-province" );
                var sAddress = this.storage.getItem( "shipping-address" );
                var sZip = this.storage.getItem( "shipping-zip" );
                var sCountry = this.storage.getItem( "shipping-country" );

                var html = "<div class='detail'>";
                    html += "<h2>Fatturazione</h2>";
                    html += "<ul>";
                    html += "<li>" + name + "</li>";
                    html += "<li>" + email + "</li>";
                    html += "<li>" + phone + "</li>";
                    html += "<li>" + city + "</li>";
                    html += "<li>" + province + "</li>";
                    html += "<li>" + address + "</li>";
                    html += "<li>" + zip + "</li>";
                    html += "<li>" + country + "</li>";
                    html += "</ul></div>";

                    html += "<div class='detail right'>";
                    html += "<h2>Spedizione</h2>";
                    html += "<ul>";
                    html += "<li>" + sName + "</li>";
                    html += "<li>" + sCity + "</li>";
                    html += "<li>" + sProvince + "</li>";
                    html += "<li>" + sAddress + "</li>";
                    html += "<li>" + sZip + "</li>";
                    html += "<li>" + sCountry + "</li>";
                    html += "</ul></div>";

                this.$userDetails[0].innerHTML = html;    

            }
        }
    },

0 个答案:

没有答案