From 1878fc72e131ac87bc214bad23661237187ab478 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 22 Jul 2016 15:25:27 +1000 Subject: [PATCH] add dynamic amount in js for stripe --- booking.stripe.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/booking.stripe.js b/booking.stripe.js index c6e2816..8d92b04 100644 --- a/booking.stripe.js +++ b/booking.stripe.js @@ -35,12 +35,21 @@ jQuery(document).ready(function($) { //email: currentForm.find('input[name="email"]').val(), //amount: currentForm.find('input[name="amount"]').val() * 100, //alert($(':input[name="description"]', $stripeForm)); + + //set the amount dynamically based on the card brand from the token + if ($(':input[name="card_brand"]', $stripeForm).val() == 'American Express') { + var $amount = $(':input[name="foreign_gross_amount"]', $stripeForm).val() * 100; + } + else { + var $amount = $(':input[name="gross_amount"]', $stripeForm).val() * 100; + } + handler.open({ name: $settings.name, currency: "aud", description: $(':input[name="description"]', $stripeForm).val(), email: $(':input[name="email"]', $stripeForm).val(), - amount: $(':input[name="amount"]', $stripeForm).val() * 100, + amount: $amount, zipCode: true, closed: function() { //document.getElementById("booking_stripe_form").submit();