Open nuyawktuah opened 5 years ago
If this is a question, then the answer is yes. Some people would like to be able to give more or in between of what is proposed. Right now we don't have an easy way to do that.
Selecting a monthly payment option translates to one of the following planIds:
planId: 'no-monthly',
planId: 'twenty-monthly',
planId: 'fifty-monthly',
planId: 'hundred-monthly',
It looks like the selected planId is sent along with the payment requests to stripe. How are those planIds used? If a fill in custom option for monthly payment is created, what planId should it use?
One suggestion is to have the planIds dynamic based on the amount. So instead of them looking like above, they can look like:
planId: 'monthly-0',
planId: 'monthly-20',
planId: 'monthly-50',
planId: 'monthly-100',
Then we can just append whatever custom number the users selects to the monthly-
indicator. I don't know if that could work with the recurring payment system that uses the planIds though. I'm guessing that's something configured through the stripe account or something?
Here is the code that handles the payment request: https://github.com/nycmeshnet/nycmesh-stripe/blob/master/server.js
It checks for a planId and either creates a customer, subscribes them to the plan, and creates an invoice for the one-time charge, or just makes a one-time charge (in absence of a planId).
To handle a custom monthly payment, I believe we would have to create the custom subscription plan on the backend when processing the request, if it doesn't already exist.
Thanks for the link to that code Oliver!
I see what you mean. It looks like we're using Stripe's https://stripe.com/docs/billing/subscriptions/multiplan
subscription model. So if we wanted to keep setting individual plans to have distinct amounts we would have to continue making dynamic plans.
It looks like Stripe also allows per-unit subscriptions (https://stripe.com/docs/api/plans/create#create_plan-amount). If we created one that was set to $1 USD per unit, we could set the quantity to the amount for donations.
So first we create a custom donation plan one time
stripe.plans.create({
id: "custom-amount",
amount: 1,
interval: "month",
product: {
name: "Custom Donation Amount"
},
currency: "usd",
}, function(err, plan) {
// asynchronously called
});
And then when we create new subscribers instead of using the plan-id to set the amount like:
const subscription = {
customer: customer.id,
items: [
{
plan
}
],
trial_end
};
We set the quantity to the amount like:
const subscription = {
customer: customer.id,
items: [
{
plan:"custom-amount",
quantity: monthyDonationAmount,
}
],
trial_end
};
Is this issue referring to adding an open field to the monthly donation like: ?