#joeeyireland_api

1 messages · Page 1 of 1 (latest)

still sparrowBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1242786642029445211

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

void raven
#

hi there!

#

how are you accepting payments? Checkout Session, Payment Element, something else?

ripe sail
#

using the checkout session, and i just have this so far

        'payment_method_types' => ['bacs_debit'],
        'line_items' => [[
            'price_data' => [
                'currency' => 'gbp',
                'product_data' => [
                    'name' => 'Donation',
                ],
                'unit_amount' => $_POST['amount'] * 100,
            ],
            'quantity' => 1,
        ]],
        'mode' => 'payment',
        'success_url' => home_url('/thank-you') . '?session_id={CHECKOUT_SESSION_ID}',
        'cancel_url' => home_url('/donate'),
    ]);```
#

i didnt know if there was a property which i could add the fees onto the order

void raven
#

you can't add a Checkout like this on the Chekcout Session page. but you could add one on your own website before redircting users to the Checkout Session.

#

and then manually compute the new amount users have to pay

ripe sail
#

but if i edit the amount wouldnt the fees be bigger ? for example,

on my webpage the user fills in the form, selects £8 which the transactions fees would be £0.32p so if i then add that to the £8 it would be £8.32 would that then not make the actual stripe fees more ?

void raven
ripe sail
#

so i could do this

    $percentage_fee = 0.014; // Stripe's BACS Direct Debit fee percentage (1.4% for UK)
    $fixed_fee = 0.20; 

    if (isset($_POST['processing_fees']) && $_POST['processing_fees']) {
        $total_amount = ($intended_amount + $fixed_fee) / (1 - $percentage_fee);
    } else {
        $total_amount = $intended_amount;
    }

    $total_amount_in_cents = intval(round($total_amount * 100));

    // Create a new Stripe Checkout Session
    $session = \Stripe\Checkout\Session::create([
        'payment_method_types' => ['bacs_debit'],
        'line_items' => [[
            'price_data' => [
                'currency' => 'gbp',
                'product_data' => [
                    'name' => 'Donation',
                ],
                'unit_amount' => $total_amount_in_cents,
            ],
            'quantity' => 1,
        ]],
        'mode' => 'payment',
        'success_url' => home_url('/thank-you') . '?session_id={CHECKOUT_SESSION_ID}',
        'cancel_url' => home_url('/donate'),
    ]);```
#

which seems to work when going to checkout it asks me for 8.32

void raven
#

something like this. but keep in mind the Stripe fee cna change depending on the Payment Method used and the country of the user.

ripe sail
#

very true but this gives me a base, thank you very much for your help