Support » Plugin: Stripe Payments WordPress Plugin – WP Simple Pay » How to automatically create forms and detect successful payments?

  • Resolved Babak Fakhamzadeh

    (@mastababa)


    I want to create payment forms automatically, assign unique IDs to them (or get their unique ID to assign to a particular post) and then process payments such that on success or failure, I can update certain fields related to the payment or payment attempt and the executing user.

    How do I make this work using this plugin?

    For clarification, imagine I have a LOT of digital products with different prices. I do not want to create all payment forms by hand. I want to create them in code. Then, I want to be able to automatically detect successful payments so that, on successful payment, I can immediately offer the download.

    In short, I need to create and set forms in code and then need access to a webhook with payment results.

    How to make this work?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author spencerfinnell

    (@spencerfinnell)

    Hello @mastababa

    WP Simple Pay Payment Forms are stored as a custom post type in WordPress, registered with an ID of simple-pay. You can use wp_insert_post() to programmatically create a payment form, and configure it via custom meta data. I would recommend creating a form manually first then inspecting which fields are created in wp_posts and wp_postmeta to determine what needs to be added with your customization.

    The Lite version of WP Simple Pay does not support Stripe Webhook handling so the only way to determine a successful payment would be to manually reverify the Stripe Checkout Session ID that is included in the URL when redirected back to your website, or set up your own Webhook receivers. WP Simple Pay Pro offers built-in Webhook handling.

    Beyond that, I would also recommend looking at one of our other products, Easy Digital Downloads: https://wordpress.org/plugins/easy-digital-downloads — this is more of a full eCommerce system closer to what you are describing.

    I hope that helps!

    Thread Starter Babak Fakhamzadeh

    (@mastababa)

    Thanks for the quick response. That plugin you mention looks quite promising. However, the products I’m selling are not actually digital downloads, they are online events, where the URL is ‘just’ the URL of a post, with the content available based on whether the purchase was made or not.

    I have inspected the custom fields you add to the payment forms. And I’ve seen that the, coming back from Stripe, the query string parameters include ‘form_id’ and ‘session_id’.
    The form_id allows me to tie the purchase to the original product, but, as this comes in via the query string, this is not very secure. I do not see where, or how, I can access the session_id *before* the purchase is final, or how to use the session ID to confirm a valid response from Stripe.

    Or, you mean I should set my own Session ID?

    Plugin Author spencerfinnell

    (@spencerfinnell)

    @mastababa

    Another one of Sandhills Development’s products, Restrict Content Pro, might also suit your needs for selling access to content.

    For WP Simple Pay Lite, ?session_id in the URL refers to the Stripe Checkout Session (https://stripe.com/docs/api/checkout/sessions). You would use value of this ID to check back with Stripe to ensure it actually exists in Stripe (and that someone isn’t just making up an ID), then performing the actions to grant access to the content.

    Thread Starter Babak Fakhamzadeh

    (@mastababa)

    Ah, I now understand why you mentioned the *manual* confirmation of the session ID.

    And thanks for pointing me to this other plugin.

    I think I know enough for now. Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to automatically create forms and detect successful payments?’ is closed to new replies.