Recurring Donation (Subscription) with User Set Amount
-
Hello. Thank you for your plugin.
I see where to create a donation button where the user sets the amount. I also see where to create a subscription button, but it requires a plan ID created in Stripe.
Is there a way to create a recurring monthly donation that is like a subscription, but the user sets the amount?
Thank you
-
Hello @perfectword7,
Thank you for using Direct Stripe.
This is not a feature of the plugin at the moment. That would require custom code using direct_stripe_before_success_redirection action hook.
Best wishes,
Nicolas
-
This reply was modified 7 years, 4 months ago by
Nicolas Figueira.
Hello @perfectword7,
I created an example how to do this at https://gist.github.com/New0/659b7398285e820cb72330f265c5122b
Best wishes,
Nicolas
Thank you! I will try implementing it, and let you know.
I entered the button’s Unique ID in place of MyButtonID, and put the whole snippet in the Child Theme’s function.php. The button type is set to “subscription.”
When I place the button on a WP page, all I get is a button that says “Payment,” and no place to enter the recurring donation amount.
Thanks for any help you can provide.
Hello @perfectword7,
I should have explain better, sorry about that.
Please insert a donation type button, the amount set by the user will be used as the amount of the new created plan.
Details of the plan, such as the name or the interval is to be set in the code provided in the gist.
Best wishes.
Thank you, but it still did not work for me. The donation went through, but it did not create a plan or set up the donor with a subscription.
Another issue: after the payment is submitted, the pop-up disappears, and the wordpress page shows a really huge “Processing…”
Then, after the “Processing…” disappears, the wordpress page returns to normal, but with a strange little green dash, which also eventually disappears. (See https://prnt.sc/m2tsj5)
There is never another notice that the transaction is complete.
Thanks again.
Hello @perfectword7,
I realize it might not work from the functions.php file of a theme, I edited the code for you to use it as a plugin. ( https://gist.github.com/New0/659b7398285e820cb72330f265c5122b )
– Edit the code with the css ID you set for your button
– Zip the file
– Go to Add new plugin page of your WordPress admin
– Click the Upload Plugin button and upload the zipped file
– Activate the plugin and testThe green line should be a bubble of text filled with the text set in Direct Stripe -> Settings, in the Success Message textarea under Global settings, did you set your own success message in this textarea ?
Let me know how that goes.
Best wishes.
We’re getting closer! π
So, I was using the button’s unique ID instead of the CSS ID. That’s why it wasn’t working.
I kept the code in my functions.php file, rather than uploading it as a plugin.
(And my “Success Message” was blank — so thank you for directing me to that.)
The only problem that I see now is that it seems to be charging the card twice, within two or three seconds of each other. See https://prnt.sc/m325l6
Thanks for all your help! I hope we can figure this out.
Hello @perfectword7,
You could add a trial period to the plan that would be equivalent to the interval.
( https://stripe.com/docs/api/plans?lang=php )I think you can add (in a new line under the interval line in the code):
trial_period_days => 30,Let me know how that goes!
It did not work. Still two transactions.
I tried without quotes, as you indicated,
"interval" => "month", trial_period_days => 30, "product" => [and with quotes
"interval" => "month", "trial_period_days" => "30", "product" => [Same results. Thank you.
Hello @perfectword7,
Sorry the code is to be used from the subscription, not the plan…
So there are two ways to achieve that :
– Unset the capture option on the button (from the Direct Stripe Button settings interface), this way the payment of the donation will be uncaptured (it will appear in the payments list as pending and won’t be charged unless you manually capture it ) and the charge of the subscription will be triggered.
– Or capture the donation but use
"trial_period_days" => 30,in the subscription (under the customer line ), this way, the plan charge will start 30 days later.Best wishes
Nice!
Both options work. Only one successful transaction.
I prefer adding
"trial_period_days" => 30,under"customer" => $charge->customer,because it’s doesn’t add a pending transaction alongside the successful one.Thanks for all the help!
I would be interested in this feature too, where the user sets the amount for the subscription. Is this relatively easy to add to Direct Stripe?
Thank you.
-
This reply was modified 7 years, 4 months ago by
The topic ‘Recurring Donation (Subscription) with User Set Amount’ is closed to new replies.