Skip to content

Amount being sent as float #97

Description

@djm56

My client site has very complex tax and shipping calculations. So when it takes the Cart total and times it by 100 here on this line.

https://github.com/tubiz/woo-paystack/blob/master/includes/class-wc-gateway-paystack.php#L877

It is sometimes still sending a float value.
I have a feeling that tax is calculated on each product and not the total, but this was a requirement from the client.
Regardless the gateway only accepts integers.

I did a quick change to the code, it is a dirty fix but it seems to be working fine especially considering that values are not rolled up.

$amount = ! is_int( $amount ) ? intval( $amount ) : $amount;

So the final looks like

$order        = wc_get_order( $order_id );
$amount       = $order->get_total() * 100;
$txnref       = $order_id . '_' . time();
$callback_url = WC()->api_request_url( 'WC_Gateway_Paystack' );

$payment_channels = $this->get_gateway_payment_channels( $order );

$amount = ! is_int( $amount ) ? intval( $amount ) : $amount;

$paystack_params = array(
	'amount'       => $amount,
	'email'        => $order->get_billing_email(),
	'currency'     => $order->get_currency(),
	'reference'    => $txnref,
	'callback_url' => $callback_url,
);

Maybe this will help someone else

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions