Jump to content

How to use my credit balance on order with activated Stripe?


Craft

Recommended Posts

Hi guys,

When I try to make an order and pay using my credit balance, I should select the payment method below (Credit Card or PayPal) also (Find the attached screenshot).

If I selected PayPal, the order is executed successfully using my credit balance without asking me to use PayPal, but the issue now if I selected Credit Card (Stripe), the order is executed successfully also using my credit balance but this transaction is being executed in Stripe as Cancelled order (Find the attached screenshot), also I receive an SMS from my bank credit card that my card has been charged (but it will be refunded to my card again within 2 business days because it has been cancelled from Stripe).
I think that's a bug and the correct scenario is when the customer selects (Apply from my credit on order), the payment methods below should be disappeared.

Any advice?

Apply from credit.png

Stripe Canceled.png

Link to comment
Share on other sites

10 hours ago, Craft said:

I think that's a bug and the correct scenario is when the customer selects (Apply from my credit on order), the payment methods below should be disappeared.

logically it shouldn't be doing this (though you can say that a lot with WHMCS) - but I don't know if it's intended behaviour that it is doing it... somewhere in the back of my mind is a thought that it is "normal" for WHMCS to do this.

10 hours ago, Craft said:

Any advice?

which version of WHMCS is it? if it's not the latest, then checking the changelogs to see if any relevant changes have been made since your installed release... a quick look didn't reveal anything obvious in recent releases, but i'm not sure how far back I would need to go for your version.

I think opening a ticket will be the best bet to get them to confirm either way - not least because if it is a bug (which I doubt it is in their eyes), then I think the v8.2 beta circus will soon be coming to town and so now might be a good time to raise it.... the staff seem to be keeping a low profile in this place in recent months (quelle surprise!), so better to go to them.

you could hook that when the credit balance is equal or greater than the order total, stripe could be removed as an payment option - but I think it's fair to say that there are "quirks" with how stripe in WHMCS often handles credit balances and they're seemingly not considered as bugs...

Link to comment
Share on other sites

On 5/4/2021 at 3:51 PM, brian! said:

logically it shouldn't be doing this (though you can say that a lot with WHMCS) - but I don't know if it's intended behaviour that it is doing it... somewhere in the back of my mind is a thought that it is "normal" for WHMCS to do this.

which version of WHMCS is it? if it's not the latest, then checking the changelogs to see if any relevant changes have been made since your installed release... a quick look didn't reveal anything obvious in recent releases, but i'm not sure how far back I would need to go for your version.

I think opening a ticket will be the best bet to get them to confirm either way - not least because if it is a bug (which I doubt it is in their eyes), then I think the v8.2 beta circus will soon be coming to town and so now might be a good time to raise it.... the staff seem to be keeping a low profile in this place in recent months (quelle surprise!), so better to go to them.

you could hook that when the credit balance is equal or greater than the order total, stripe could be removed as an payment option - but I think it's fair to say that there are "quirks" with how stripe in WHMCS often handles credit balances and they're seemingly not considered as bugs...

 

Hi brian,

I'm using the latest version of WHMCS v8.1.3

I checked the mentioned 2 old topics and yes, they are saying the same issue and until now it hasn't been solved yet.

Is there an option to solve it using a hook?

I just need to disappear the payment methods option if the customer selected (Pay using credit balance).

Link to comment
Share on other sites

10 hours ago, Craft said:

Is there an option to solve it using a hook?

I just need to disappear the payment methods option if the customer selected (Pay using credit balance).

try the following...

<?php

# Remove Gateways When Credit Balance Greater Than Total Hook @Craft
# Written by brian!
 
function cart_gateway_removal_on_creditbalance_hook($vars) {

	if ($vars['templatefile']=='viewcart'){
		$gateways = $vars['gateways'];
		$disallowed = array('stripe');
		foreach ($gateways as $k => $item) {
			if (in_array($item['sysname'],$disallowed) and ($vars['creditBalance']->toNumeric() >= $vars['total']->toNumeric())) {
				unset($gateways[$k]);
			}
		}
		if (count($gateways) > 0) {
			return array("gateways" => $gateways);
		}
	}
}
add_hook("ClientAreaPageCart", 1, "cart_gateway_removal_on_creditbalance_hook");

the only line that you should need to change will be the $disallowed array that defines which gateway(s) to remove if the credit balance is equal or greater than the total amount.

$disallowed = array('stripe');

there is also a conditional statement at the end to ensure that there is at least one payment gateway option still showing in the cart - that avoids the situation if a product group were only assigned to use the Stripe gateway, it prevents the gateway being removed and giving the user no payment options at all.

Link to comment
Share on other sites

16 minutes ago, brian! said:

but you wanted the stripe gateway removed if they had sufficient credit - i'm not sure what you actually want the hook to do????

I want to hide the payment method section if the customer selected (Apply $xxx from my credit balance)

hide payment methods.png

Link to comment
Share on other sites

26 minutes ago, Craft said:

I want to hide the payment method section if the customer selected (Apply $xxx from my credit balance)

but you will need at least one payment gateway option  at checkout - otherwise the cart will throw an error....

a5uA4JF.png

o6SKfWq.png

that's why the hook ensures that it returns at least one gateway option. 🙂

what you might need to do is have an offline option, e.g bank transfer - that would allow the order to continue.... but then you're into the realms of hiding that option when total > credit balance, plus validating at checkout to ensure they haven't selected not to use the credit, but still use bank transfer.... it's all doable, but you will have to think about exactly what you want to occur under each circumstance.

Link to comment
Share on other sites

4 hours ago, brian! said:

but you will need at least one payment gateway option  at checkout - otherwise the cart will throw an error....

that's why the hook ensures that it returns at least one gateway option. 🙂

what you might need to do is have an offline option, e.g bank transfer - that would allow the order to continue.... but then you're into the realms of hiding that option when total > credit balance, plus validating at checkout to ensure they haven't selected not to use the credit, but still use bank transfer.... it's all doable, but you will have to think about exactly what you want to occur under each circumstance.

Ok fine.

Can we do the following exactly?

1. If the customer selected (Apply $xxx from my credit balance), it shows the offline payment method (bank transfer) and hide Stripe & PayPal

2. Else if the customer selected (Do not apply any credit), it hide the offline payment method and shows only Stripe & PayPal

Link to comment
Share on other sites

This seems like a bug. I run version 7 and this does not happen. If you have enough credits in your account, your card should not be charged at all.

This seems a very nasty bug as well. I can imagine customers complaining you charged their credit card, even if its automatically refunded, most debit cards don't refund the amount until days later, most pre-authorizations are cleared in over 10 days which will quickly get you angry customers as that amount gets locked in their card, and they can't use them.

Edited by yggdrasil
Link to comment
Share on other sites

1 hour ago, yggdrasil said:

This seems a very nasty bug as well. I can imagine customers complaining you charged their credit card, even if its automatically refunded, most debit cards don't refund the amount until days later, most pre-authorizations are cleared in over 10 days which will quickly get you angry customers as that amount gets locked in their card, and they can't use them.

Unfortunately, that's correct!

1773669900_CreditBalance.thumb.png.6b3760b05d55e5b65ad39d21468f8d1f.png

Link to comment
Share on other sites

10 hours ago, yggdrasil said:

This seems like a bug. I run version 7 and this does not happen. If you have enough credits in your account, your card should not be charged at all.

it's not a bad shout that this could be a bug - especially if you say that it occurs with Stripe, but not PayPal - its worth opening a ticket with Support to see what they say before going any further.

11 hours ago, Craft said:

Can we do the following exactly?

1. If the customer selected (Apply $xxx from my credit balance), it shows the offline payment method (bank transfer) and hide Stripe & PayPal

2. Else if the customer selected (Do not apply any credit), it hide the offline payment method and shows only Stripe & PayPal

for it to react to a setting in that way, would require JS in the hook.

Link to comment
Share on other sites

5 hours ago, brian! said:

it's not a hook that I have ready-made.

Yea I know 🙂

I have talked to WHMCS technical support and they have replicated this issue from their end and they have sent this bug to their development team to fix, but they have no time frame when this bug could be solved!

Link to comment
Share on other sites

@brian!

Your Hook has solved 50% of the issue because it made a new issue where you are forcing the customers to use their credit balance, what if they need to pay it using a credit card?

I think we can do some changes in the hook to solve the issue:
If the credit balance is greater or equal to the total, SHOW an offline payment gateway ("bank transfer" and we will rename it to "Pay using Credit Balance")
So, now we are giving the option to the customers to pay using a credit card even they have a credit balance. Also, if they don't have a credit balance, they will not be confused with showing this offline payment gateway.

In coding: you can do the inverse, the offline payment gateway will be visible by default and it will be hidden if only the credit balance is lower than the total.

 

Link to comment
Share on other sites

14 hours ago, Craft said:

I have talked to WHMCS technical support and they have replicated this issue from their end and they have sent this bug to their development team to fix, but they have no time frame when this bug could be solved!

aah the usual ETA line - the translation being that there could be a hotfix posted in the next 5 mins; it might be included in the v8.2 betas... or you could be waiting until hell freezes over. 🥶

14 hours ago, Craft said:

Your Hook has solved 50% of the issue because it made a new issue where you are forcing the customers to use their credit balance, what if they need to pay it using a credit card?

I might argue that it's not the hook or me doing that, it's you... or specifically how the gateways are being used.

I assumed the whole purpose of that hook was that you wanted if the user had sufficient credit balance, that they can't use Stripe - it does that... there's nothing to stop you leaving PayPal as an option at checkout if this bug isn't affecting that gateway... the hook is only going to work if credit > total... if the total is $10, but the credit is $5, the hook will do nothing as you'll need to be charging to a gateway anyway.

15 hours ago, Craft said:

If the credit balance is greater or equal to the total, SHOW an offline payment gateway ("bank transfer" and we will rename it to "Pay using Credit Balance")

any reason you can't use PayPal for this if it's already an option at checkout ?

15 hours ago, Craft said:

So, now we are giving the option to the customers to pay using a credit card even they have a credit balance.

but they already have that option if you don't use the hook.... you don't want them to use Stripe if they have a sufficient balance, but you still want to give them the option of using Stripe if they choose to.... there's a way to do that - do nothing!

15 hours ago, Craft said:

In coding: you can do the inverse, the offline payment gateway will be visible by default and it will be hidden if only the credit balance is lower than the total.

oh I know how to do it - i'm just failing to see the point of it.

if you wanted to, you could force them to use the sufficient balance (a gateway choice is still being made, it's just hidden), but you don't want to go down that road... actually, i'm so confused on what you really want to do, i'm totally lost. 🗺️

F8icdeb.png

Link to comment
Share on other sites

2 hours ago, brian! said:

any reason you can't use PayPal for this if it's already an option at checkout ?

I know that using credit balance with the PayPal gateway isn’t doing any issues, but I don’t want to do that because the customers don’t know this info, so they will be confused and scared to select pay with PayPal and they already selected (Apply credit balance for this order).

Also, I want to allow them to pay using a credit card even they have a credit balance.

 

2 hours ago, brian! said:
 

In coding: you can do the inverse, the offline payment gateway will be visible by default and it will be hidden if only the credit balance is lower than the total.

Can we do this hook?

Link to comment
Share on other sites

20 hours ago, Craft said:

I know that using credit balance with the PayPal gateway isn’t doing any issues, but I don’t want to do that because the customers don’t know this info, so they will be confused and scared to select pay with PayPal and they already selected (Apply credit balance for this order).

then choose PayPal (aka remove stripe) and hide all the gateway options with CSS on the hook.

20 hours ago, Craft said:

Also, I want to allow them to pay using a credit card even they have a credit balance.

literally - I give up. sdesole.gif

20 hours ago, Craft said:

Can we do this hook?

not me - i'm out of this one. drapblac.gif

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated