Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "open field" to /donate #75

Open
nuyawktuah opened this issue Jul 1, 2019 · 5 comments
Open

Add "open field" to /donate #75

nuyawktuah opened this issue Jul 1, 2019 · 5 comments
Assignees

Comments

@nuyawktuah
Copy link
Member

No description provided.

@apackin
Copy link
Contributor

apackin commented Jul 2, 2019

Is this issue referring to adding an open field to the monthly donation like: Screen Shot 2019-07-02 at 10 00 44 AM
?

@OlivierMorf
Copy link
Contributor

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.

@apackin
Copy link
Contributor

apackin commented Jul 8, 2019

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?

@nuyawktuah
Copy link
Member Author

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.

@apackin
Copy link
Contributor

apackin commented Jul 17, 2019

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
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants