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
});
}
});