Stripe payment_method

I’m creating a Stripe payment page on another project (I’ve successfully done this before on other projects) but I must be doing something not quite right as Stripe isn’t progressing to the charge stage. It’s a PHP project.

Can anyone let me know the process the Wappler actions go through so I can find the bit I’ve missed? I’m comparing two projects in fine detail and they both look exactly the same but one creates the payment intent and then immediately does a successful charge and the other just does the payment intent and no more.

Comparing the XML within Stripe’s dashboard, the one that works includes this part:

"charges": {
        "object": "list",
        "data": [
        ],
        "has_more": false,
        "total_count": 0,
        "url": "/v1/charges?payment_intent=pi_3MtWJbdhsywg4CMZ1cIVoXam"
      },

Whereas this part is completely missing in the one which doesn’t work. But what puts it there?

Hi Jon, there are a number of ways to use Stripe for your payment gateway.

  1. A single payment originated from a page in your project
  2. Stripe’s prebuilt checkout page
  3. A combination of the above

Assuming the first option, all you need is a payment intent as per

Thanks Ben. Yep, that’s exactly what I’ve done, and did on other projects. I’m stumped as to why Stripe seems to be processing them slightly differently where one site completes the payment fine but another doesn’t.

I’m trying to find out where the "charges" part of the XML comes from as that is the difference.

I still can’t work out why Stripe isn’t processing the charge and is only getting as far as the payment intent.

Is there anyone that can help me with this? I have a site going live imminently and the payments is the only bit not working.

Hi Jon!

I had an issue with Stripe where my interface worked perfectly for 2 years and then stopped working for some api keys and not others. It turned out that the stripe api was passing back data in a different format for api keys created after a certain date. That date was some time in autumn last year.

May be worth checking if this is contributing to your issue!

Best wishes,
Antony.

Great to hear from you Antony. Hope you’re well.

This is a completely new build and I only did the Stripe integration in the last 2-3 weeks and the Stripe account is new, too, so I don’t think it’s going to be the same issue. Thanks for the tip, though.

I’ve redone everything so many times and worked through all the docs and videos but I just cannot see why it’s not doing the charge. It does the payment intent fine.

1 Like

Checklist:

  1. Setup Stripe
    image

  2. Create a Payment Intent making sure that there is a value in the two required fields. The amount needs to be in the smallest currency unit (e.g., 100 cents to charge $1.00)

  3. Retrieve the Client Secret

Thanks Ben. Yep, that’s exactly what I’ve got. The secret is returned fine, the payment intent is created, the endpoint executes for the payment intent created action, but the charge isn’t done and the Stripe JSON in the events list doesn’t include the charge part. I’ve contacted Stripe but they couldn’t help so it seems to be specific to how Wappler does things.

@patrick or @Teodor - are you able to help me out at all?

Anything in the Stripe logs on their dashboard? Usually quite helpful

Hi @scalaris. Nothing of help. If I do the Test Stripe Webhook then it does all the stages perfectly - payment intent, charge, etc. But any actual purchases (test mode, of course) only do the payment intent part.

Cheers, Jon

Anything in the network inspector? Stripe is usually quite verbose

Do you mean on my site when the card details are submitted? Nothing. Only my SC response containing the client secret.

In Stripe there is just one event showing:

A new payment pi_3MyuUbxxxxxvkSFz07Fclm8T for £22.00 was created

I would expect there to be another event for the charge.

This is starting to get desperate. Can anyone help me get this working? @Teodor?

Hey Jon,

Given your description, perhaps you have a standard server connect form, instead of a Stripe Checkout form?

Here is a basic payment intent flow that shows how to have a single purchase (very much the same as Ben’s), using an in-app payment method (as opposed to using Stripe checkout portal). Maybe it will trigger something for you.

checkout api:

And you will need the secret key configured:

Here’s the stripe component on the client side:

<dmx-stripe id="stripe1" key="pk_test_9v8bV-REDACTED-Q2Hom" dmx-bind:line-items="" checkout="server">
</dmx-stripe>

There also must be a Stripe Checkout Form:

<form id="form_purchase" is="dmx-stripe-checkout-form" method="post" action="/api/checkout" dmx-on:error="notifies1.warning(error)" dmx-on:success="notifies1.success('Valid order')">

        <div class="row">
            <div class="col-12 col-md-8 col-lg-7 col-xl-5 text-start">
                <div class="row">
                    <div class="col">
                        <h1>Purchase</h1>
                        <p class="text-h3">Enter your details below.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <dmx-stripe-payment-method id="input1" payment-methods="card" display="tabs"></dmx-stripe-payment-method>
                    </div>
                </div>
                <div class="row mt-4">
                    <div class="col">
                        <button id="form_purchase.submit" class="btn btn-primary" type="submit">Buy now&nbsp;<span class="spinner-border spinner-border-sm" role="status" dmx-show="processing"></span>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </form>
2 Likes

I could kiss you!!! :rofl:

I had everything correct except the form which was set as a server connect form rather than a Stripe checkout form. That change and it’s just done a charge.

You wouldn’t believe how many hours I’ve spent staring at it all trying to work out why it wasn’t working.

Big, big thanks @mebeingken.

2 Likes

I’m sure there are many people on this forum who have wanted to kiss @mebeingken after he has so lovingly responded with the perfect answer to their desperate calls for help…

I am one for sure.

Thank you for who you are, Ken! :tada:

3 Likes