From 2cbfda6cf72f58a719a05d4594157f1f939c11b0 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 22 Jul 2016 16:02:23 +1000 Subject: [PATCH] fix for international stripe fee token --- booking.helper.inc | 12 +++++++++--- booking.tokens.inc | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/booking.helper.inc b/booking.helper.inc index 92d4356..1d850f8 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -1045,10 +1045,11 @@ function _booking_total_due($person) * * @param $person - the object relating to the registration node * @param $amount_paid - if we have previously calculated the amount paid, this can be passed as a value - * @param $include_fees - boolean to indicate whether we want the net amount or the amount owing including paypal fees + * @param $include_fees - boolean to indicate whether we want the net amount or the amount owing including paypal or stripe fees + * @param $include_fees - boolean to indicate whether we want the fees for an international transaction * @return amount owing as a decimal value */ -function _booking_amount_owing($person, $amount_paid = 0, $include_fees = TRUE) { +function _booking_amount_owing($person, $amount_paid = 0, $include_fees = TRUE, $international_fees = FALSE) { global $event; //quick sanity check if (! $person->nid) { @@ -1077,7 +1078,12 @@ function _booking_amount_owing($person, $amount_paid = 0, $include_fees = TRUE) $amount_owing = _booking_add_paypal_fees($total_due - $amount_paid, $person->booking_country); } elseif ($payment_processor_type == 1) { - $amount_owing = _booking_add_stripe_fees($total_due - $amount_paid, $person->booking_country); + if ($international_fees == FALSE) { + $amount_owing = _booking_add_stripe_fees($total_due - $amount_paid, $person->booking_country); + } + else { + $amount_owing = _booking_add_stripe_fees($total_due - $amount_paid, 'FakeCountry'); + } } } //otherwise we're using manual payment processing so don't add any fees diff --git a/booking.tokens.inc b/booking.tokens.inc index f58ec17..eefd25c 100644 --- a/booking.tokens.inc +++ b/booking.tokens.inc @@ -439,7 +439,7 @@ function booking_token_info() { ); $info['tokens']['booking']['stripe-deposit-amount'] = array( 'name' => t('Stripe Deposit Only'), - 'description' => t('The deposit amount required to confirm the registration including stripe fees.') + 'description' => t('The deposit amount required to confirm the registration including stripe fees. These tokens are only used for display purposes, not in the actual calculations.') ); $info['tokens']['booking']['stripe-total-amount'] = array( 'name' => t('Stripe Outstanding Balance'), @@ -634,8 +634,8 @@ function booking_define_personspecific_tokens($node) $tokens['paypal-deposit-amount'] = _booking_deposit_amount($node, TRUE); $tokens['paypal-total-amount'] = _booking_amount_owing($node, $amount_paid); $tokens['stripe-deposit-amount'] = _booking_deposit_amount($node, TRUE); - $tokens['stripe-total-amount'] = _booking_amount_owing($node, $amount_paid); - $tokens['stripe-total-intl'] = _booking_amount_owing($node, $amount_paid); + $tokens['stripe-total-amount'] = _booking_amount_owing($node, $amount_paid, TRUE, FALSE); + $tokens['stripe-total-intl'] = _booking_amount_owing($node, $amount_paid, TRUE, TRUE); } if (variable_get('booking_enable_travelform', 0) == 1) {