I’m experiencing an issue with updating the donation amount when using PayPal as the payment gateway. #7906
Unanswered
vozamk
asked this question in
Payment Gateways
Replies: 1 comment
-
Hi @vozamk To add an additional fee to the donations, you can try the following code:
The sample above will add an extra amount (2) using the same currency from the donation. It should work for all gateways. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I’ve added a custom block to the form using a select.y-addition-payment__sum-select field, allowing donors to optionally add a percentage-based fee to support our foundation. The added amount is calculated and appended to the original donation via the following function:
function myprefix_give_pre_insert_payment( $payment_data ) {
if ( isset( $_POST['additional_payment'] ) ) {
$toFundPercent = isset( $_POST['additional_payment'] ) ? $_POST['additional_payment'] : 1;
$toFund = ( $payment_data['price'] * $toFundPercent ) / 100;
$price = $toFund - $payment_data['price'];
}
}
add_filter( 'give_pre_insert_payment', 'myprefix_give_pre_insert_payment', 10, 1 );
The form is configured with three gateways: PayPal, Stripe, and Google/Apple Pay. The update works perfectly for Stripe and Google/Apple Pay — the donation amount reflects the additional fee. However, when donors use PayPal, the updated amount is not reflected, and the original donation amount is passed instead.
Could you please advise how to properly update the amount before PayPal processes the payment? Is there a hook or method to ensure PayPal receives the modified total?
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions