Stripe: Application Fee Error due to header flaw - Needs fix for Stripe tech support

Wappler’s shopping cart tutorial is based on a straight ecommerce where a client pays a store. That works well for this use case.
Our website is a platform connecting people, and taking a fee. We are using the method where the payment directly goes to the Connected Account and an Application Fee comes back to us (as opposed to our website getting paid and doing a Payout to another account)


We are following:
Enable other businesses to accept payments directly (stripe.com)
and
Creating direct charges (stripe.com)
We are able to create a checkout session, pass the title(name), currency, amount, and on_behalf_of (connected account id)

This all works well and we have gone to the checkout page, used a test card, verified payments through webhooks. All good.
But as soon as we add an Application Fee, the API returns this error: "Can only apply an application_fee_amount when the PaymentIntent is attempting a direct payment (using an OAuth key or Stripe-Account header) or destination payment (using ‘transfer_data[destination]’).
What should we do differently to allow for the Application Fee to work?

Hi guys,
Endless trials & errors make us feel it could be a bug in your Create Checkout Session module:
There is nowhere to setup Payment Intent with direct payment using a Stripe-Account header. We’ve managed to set all necessary fields below except the last line. Where do we define the stripe -account header in your checkout component?

// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
\Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

$session = \Stripe\Checkout\Session::create([
  'payment_method_types' => ['card'],
  'line_items' => [[
    'name' => 'Stainless Steel Water Bottle',
    'amount' => 1000,
    'currency' => 'usd',
    'quantity' => 1,
  ]],
  'payment_intent_data' => [
    'application_fee_amount' => 123,
  ],
  'mode' => 'payment',
  'success_url' => 'https://example.com/success',
  'cancel_url' => 'https://example.com/cancel',
], ['stripe_account' => '{{CONNECTED_STRIPE_ACCOUNT_ID}}']);

Hello @George @Teodor
Any idea why we keep getting the same error msg Can only apply an application_fee_amount when the PaymentIntent is attempting a direct payment (using an OAuth key or Stripe-Account header)? Yet we’ve followed the instruction to create a direct charge: “To create a direct charge on the connected account, create a PaymentIntent object and add the Stripe-Account header with a value of the connected account ID”. Do we add the stripe-account “header” in the metadata table, don’t we?

Stripe instructs us to add the Stripe-Account header to the PaymentIntent object but there is no header table in the PaymentIntent properties. Adding the Stripe-Account to the metadata does not seem to work as expected. Is that the right way or should the properties have a Headers table like an API action component?


So according to the Stripe Tech support, the wappler component needs a fix, as it does not include the stripe-account header in the request even though it is in the code. We’ve tested two syntax variations below with "stripe_account": "{{qryOffer[0].stripeAcctID}}" and "header": {"stripe_account": "{{qryOffer[0].stripeAcctID}}"} in the code:

"action": "createPaymentIntent",
"options": {
"payment_method_types": [
"card"
],
"amount": "{{qryOffer[0].amount}}",
"currency": "{{qryOffer[0].currency}}",
"description": "{{qryOffer[0].title}}",
"application_fee_amount": 10,
"on_behalf_of": "{{qryOffer[0].stripeAcctID}}",
"receipt_email": "{{qryOffer[0].email}}",
"capture_method": "automatic"
},
"stripe_account": "{{qryOffer[0].stripeAcctID}}",
"outputType": "object",
"meta": [
{
"name": "amount",
"type": "number"

and:

"action": "createPaymentIntent",
"options": {
"payment_method_types": [
"card"
],
"amount": "{{qryOffer[0].amount}}",
"currency": "{{qryOffer[0].currency}}",
"description": "{{qryOffer[0].title}}",
"application_fee_amount": 10,
"on_behalf_of": "{{qryOffer[0].stripeAcctID}}",
"receipt_email": "{{qryOffer[0].email}}",
"capture_method": "automatic"
},
"header": {
"stripe_account": "{{qryOffer[0].stripeAcctID}}"
},
"outputType": "object",
"meta": [
{
"name": "amount",
"type": "number"

@George please advise if this needs a fix on your end or if Stripe needs to look deeper into our case.
Thank you.

We don’t have yet a general header option for passing stripe_account.

Does the above worked for you? I don’t see any docs about the header config option in Stripe.

Yet it is imperative to pass this header for a working Stripe payment flow, as explained here:
https://stripe.com/docs/connect/direct-charges No Direct Charge can happen if stripe-account header is not set. None of the above syntaxes work.

You have a header option in the API call, just need the same for the Stripe components, or else your payment intent / payment flow / create checkout session module for more complexe payment flows won’t work.

Yes I see that are also other set of parameters that we currently do not use and are only for connected accounts:
for php:

and for node:

So will see if we can add them to the options as well - but those are really specific for connected accounts only.

Right, it is specific to Stripe Connect. Stripe Connect is a key feature and we suspect more wappler users are going to get stuck soon.
Meanwhile, what shall we do now?

It is indeed very specific to Stripe connect only - when you want to charge mutate other stripe users accounts, so only used when you are building extensive interconnected market places. Not widely common to do so.

Anyway we will see if we can add those options in the next update.

1 Like

Appreciate it. It is critical we get this going for our ambitious platform as we are completely stuck now. We have other sophisticated projects down the road with same config so we want to remain loyal wappler customers.
Please note though that the below flow is not so rare:

1 Like

Just to confirm - did adding this header option in de code of your server connect stripe action options, worked?

Nope. Sorry! :grimacing:
It may be the way we inserted it, the placement, or just not adding all the lines needed in various places… So we are on the right track but need this to be done by/on Wappler in a way that will communicate fully compliant to Stripe

Hi @George and @Teodor,
We are able to work with you just by replacing the files you could send to us. We understand there is a big 4.0 upgrade at the moment, but we can be a test case for any bug fix and Connect.
Thank you!

1 Like

Hi Wappler team :slight_smile:
Would you have any news on how that could be fixed please? We are at a complete standstill and the Stripe integration was a big selling point in choosing Wappler…
Many thanks for your help.

Well you can change the source file as you find out currently and later one use the one from Wappler when we update it.

@George @Teodor we don’t understand your answer. We have chosen Wappler for the reason that it was low code and the integration would be working. They are not, and we are informing you of bugs. We are also open to getting your new files in advance to help out in your fixing of these bugs. We have tried changing the complex Wappler code and it’s not successful as we’re not experienced coders like Wappler, so asking for files coming from you instead.