dpn517111 2019-05-04 06:38
浏览 28

如何在条带自定义结帐弹出窗口中预先填写结算明细

Stripe custom payment checkout box is asking for billing data, we can put these values by getting from user account so he don't need to fill them again.

var handler = StripeCheckout.configure({
            billingAddress: true,
            opened: function() {
                jQuery('.wp-travel-form-field.button-field').find('.wt-icon.wt-icon-spinner').remove();
            },
            closed: function() {
                jQuery('.wp-travel-form-field.button-field').find('.wt-icon.wt-icon-spinner').remove();
            },
            currency: cart_data.currency,
            key: wp_travel.payment.stripe_publishable_key,
            panelLabel: 'Pay' + " {{amount}}",
            shippingAddress: true,
            token: function(token, args) {
                var gateway = $("input[name='wp_travel_payment_gateway']:checked").val();
                var mode = $('[name=wp_travel_payment_mode]').attr('value');
                var title = $('.entry-title').html() || 'Trip Book';
                var description = $('#overview').find('p').html() || 'Trip Description';

                if (!mode) {
                    mode = 'full';
                }
                $('.stripe-spin').show();
                // Use the token to create the charge with a server-side script.
                // Ajax POST
                $.ajax({
                    cache: false,
                    crossDomain: true,
                    data: {
                        token: token,
                        args: args,
                        action: 'stripe_charge',

                        gateway: gateway,
                        mode: mode,
                        // currency: currency,
                        title: title,
                        description: description,
                        total: cart_data.amount,
                        // partial: partial
                    },
                    type: "POST",
                    url: wp_travel.ajaxUrl,
                    success: function(msg) {
                        if (msg.status) {
                            response = msg.charge;
                            complete(response);
                        }
                    }

                    // Done - check for errors - empty cart if success
                }).done(function(data, status, xhr) {

                    // Fail - add message
                }).fail(function(xhr, status, error) {

                    // Porbably nothing required here
                }).always(function(data, status, error) {
                    $('.stripe-spin').show();
                    // Debug

                });
            }

        });
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 个人网站被恶意大量访问,怎么办
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大