Skip to content

Add ability to make use of Stripe's "multiple payment configurations" feature #282

Closed Answered by chadwells
chadwells asked this question in Ideas
Discussion options

You must be logged in to vote

I found this is possible through https://github.com/craftcms/commerce-stripe?tab=readme-ov-file#buildgatewayrequest -- essentially doing something like:

Event::on(
    PaymentIntents::class,
    PaymentIntents::EVENT_BUILD_GATEWAY_REQUEST,
    function (BuildGatewayRequestEvent $e) {
        /** @var Transaction $transaction */
        $transaction = $e->transaction;
        $order = $transaction->getOrder();

        $e->request['amount'] = $order->outstandingBalance;
        $e->request['currency'] = $order->paymentCurrency;
        $e->request['automatic_payment_methods'] = ['enabled' => true];
        $e->request['payment_method_configuration'] = $stripeConfigId;
    },
);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by chadwells
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant