Jump to content
Craft

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

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

Share this post


Link to post
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...

Share this post


Link to post
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).

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

@brian! 

Ok, but now my customers don't have an option to pay using their credit card even they have a credit balance!

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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