Commit Graph

229 Commits

Author SHA1 Message Date
Vinoth Kannan 6f70af5e42
DEV: execute campaign refresh job only if stripe is configured. (#108) 2022-02-04 11:06:40 +05:30
Blake Erickson 23bfa1b567
FIX: Exclude blocked charges in campaign total (#96)
The campaign total should only include payments that have succeeded.

See: https://meta.discourse.org/t/209591/14
2021-11-25 08:11:52 -07:00
Blake Erickson c6c5ed2ed3
FIX: Include one-time purchases in campaign total (#95)
* FIX: Include one-time purchases in campaign total

On the subscription banner that shows on the top of the forum it shows
the total amount raised toward a goal. But the amount shown was not
including one-time purchases. It was only showing subscriptions.

This change updates the sync with stripe logic so that it also includes
one-time purchases.

See: https://meta.discourse.org/t/-/209591

* rubocop: remove extra blank line
2021-11-22 12:46:40 -07:00
Vinoth Kannan 33008b0b47
DEV: use existing customer id instead of creating. (#92)
Previosuly, new customer record is created in Stripe for each subscription in Discourse.
2021-10-08 09:40:16 +05:30
Vinoth Kannan 3ce422ffbe
FIX: set interval field correctly in object root for recurring plans. (#91)
The interval field was missing in the Ember object since it was only available inside the nested object.

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2021-09-21 18:12:17 +05:30
Justin DiRose 6414a1f6e5
FEATURE: Show/hide campaign banner with goal status (#85) 2021-07-15 15:05:27 -05:00
Justin DiRose 8ab7a63167
FEATURE: Validate coupon codes on form submit (#74) 2021-06-16 12:54:54 -05:00
Justin DiRose 227c55e6f5
FIX: Restrict mods from seeing Subscriptions admin features (#70)
As reported [on Meta](https://meta.discourse.org/t/discourse-subscriptions/140818/352?u=justin), moderators could access all of the subscriptions data (plugins/prices/subscribers) and manage them. This should not be the case, so this PR adds a route constraint to 404 moderators from these routes.
2021-06-08 17:24:13 -05:00
Justin DiRose f596a0f78a
FEATURE: Campaigns (#67)
Co-authored-by: Jordan Vidrine <jordan@jordanvidrine.com>

See https://github.com/discourse/discourse-subscriptions/pull/67 for the full description.
2021-06-02 13:15:03 -05:00
Justin DiRose a282475da3
FEATURE: Admin > Subscriptions Pagination (#50)
Meta topic: https://meta.discourse.org/t/subscriptions-add-pagination-to-admin-subscriptions-view/172500

This adds support for pagination using our `{{load-more}}` component in core. Implementation on the backend was a bit tricky because we don't return all results from Stripe, only those that match local subscriptions stored in the `DiscourseSubscriptions::Subscription` model.
2021-02-05 11:57:53 -06:00
Justin DiRose 072b558d40
FEATURE: Give option to repurchase products multiple times (#46)
Feature requested here: https://meta.discourse.org/t/subscriptions-allow-users-to-purchase-one-time-products-multiple-times/173732/

There may be cases where a site admin wants to allow the repurchasing of a product. This implements the functionality by adding a repurchaseable toggle in the admin screen when creating a product. This saves an attribute to the Stripe product metadata.

When a user has already purchased an item with this toggle enabled, they will be able to purchase it again when browsing to `/s`.
2021-01-31 14:17:44 -06:00
Justin DiRose 400313cded
FEATURE: Allow creation of coupons in admin panel (#43)
Adds full support to create coupon/promo codes in the Admin > Plugins > Subscriptions section of the plugin. The Create Coupon button opens a form on the same page, and the active checkboxes toggle the active status of the coupon code.
2021-01-13 11:47:22 -06:00
Justin DiRose da9b58398b
FEATURE: Support for coupons in checkout (#41)
This adds support for Stripe Promo Codes in the user checkout process. 

Also adds a discounted field to User > Billing > Subscriptions to show the amount or percent discounted.

This does not currently add in support for creating promo codes in the Subscriptions interface (that will come at a later point in time). Instead a coupon can be created with a promo code right from the Stripe dashboard.
2021-01-07 15:25:44 -06:00
Justin DiRose b92627677f
FEATURE: Implement refunds from dashboard (#27)
An implementation of refunds from the Admin dashboard. To refund, go to Plugins > Subscriptions > Subscriptions then click the `Cancel` button. You'll be presented with a modal. If you wish to refund only the most recent payment, check the box. 

This only implements refunds for Subscriptions, not One Time Payments. One Time Payments will still need to be handled manually at this time.
2020-10-29 10:31:12 -05:00
Justin DiRose 3a5078ded6
REFACTOR: Simplify controller setup (#24)
The code in the plugin needed a dramatic cleanup. This refactor collapses the Plan/Product/Subscription controllers on the backend into one new controller: `SubscribeController`.

This reduces N+1 calls to the back end during the subscription process and simplifies use of the code. 

I've also removed a bunch of dead code and refactored some logic into methods for easier readability. No feature/functionality changes in this commit; only refactoring. However, refactoring will allow for implementation of better anonymous user handling, so this is largely a foundation to enable making that change.
2020-10-21 13:36:31 -05:00
Faizaan Gagan 55e6accb9c
FEATURE: Markdown support for product description (#21) 2020-10-12 10:01:33 -05:00
Justin DiRose a868e6b838
FEATURE: Cancel payments at end of subscription vs immediately
Previously, when a user canceled a subscription, the access would revoke
immediately on Discourse vs. at the end of the billing period. This
commit changes the behavior to remove membership at the end of the
billing period using Stripe's `cancel_at_period_end` attribute on the
Subscription object.

This commit now requires the setup of webhooks for subscription
processing to occur correctly.
2020-08-19 14:37:47 -05:00
Justin DiRose 9491f558ea
FEATURE: Add support for 3D Secure payments (#19)
Adds an additional checkout flow to support authentication of payment methods.
2020-07-24 15:07:18 -05:00
Justin DiRose 587661fafb
FEATURE: Allow one-time purchases on products (#18)
Building off the foundation of using the Prices API, this PR adds the ability to create a one-time purchase plan for any product, which then can add a user to the specified plan group.

Some things to be aware of:

    One-time purchases cannot have trials.
    One-time purchases use the Invoice API instead of Subscriptions. Invoices are created then charged immediately.
    Users should receive emails for these invoices directly from Stripe just like subscriptions.
2020-07-22 11:06:34 -05:00
Justin DiRose c9ff55b46a
REFACTOR: Use the Prices API in place of Plans (#17)
Stripe has a newer API called Prices where you can create a price for any product and it can either be recurring or one-time. The easy part is existing Plans work with the Prices API by passing a Plan ID, but objects are returned in the slightly-different Prices API object format.

This commit is a refactor to the new API to handle the data in its new form, and lays the foundation for a one time payment plan to be added to any subscriptions product.
2020-07-15 08:44:40 -05:00
Justin DiRose fb4f50478d
REFACTOR: Use engine to load files, add constraint (#14) 2020-07-06 11:11:04 -05:00
Justin DiRose 4830468e32
DEV: Fixes for rubocop 2020-06-09 12:37:46 -05:00
Justin DiRose c30daa1b86
FIX: Couldn't dig the payments 2020-06-09 12:26:31 -05:00
Justin DiRose d360a4155d DEV: Fix tests after changes to controllers 2020-05-28 11:45:58 -05:00
Justin DiRose fb4fac197b
REFACTOR: Use models to store data (#11)
* REFACTOR: Use api to add subscribe link

* FIX: I18n subscribe link

* REFACTOR: Use models to store some data

This enables the plugin to show only subscription information which was
generated on Discourse. Subscription data storage is limited to the
external identifiers Stripe generates so we can interact with the API.

* DEV: Test/linting fixes/rake task
2020-05-22 11:20:05 -05:00
Rimian Perkins cc389d2423 add the user to the group if subscription is completing 2020-01-26 10:49:51 +11:00
Rimian Perkins ebe891c09b fix event hash for subscription 2020-01-25 15:06:05 +11:00
Rimian Perkins 83e7ae2711 spec unsubscribe webhook 2020-01-15 10:20:21 +11:00
Rimian Perkins dca6c7ddc9 deletes the customer on subscription cancel 2020-01-14 23:38:26 +11:00
Rimian Perkins 95413ee161 get the payload, signature and secret for webhook 2020-01-14 15:37:53 +11:00
Rimian Perkins 0543b3a6a3 basic hook 2020-01-13 11:10:06 +11:00
Rimian Perkins 431279a4f7 Add empty webhook url and upgrade stripe gem 2020-01-10 10:24:09 +11:00
Rimian Perkins 52db93ecd8 user payments page 2019-12-17 16:31:58 +11:00
Rimian Perkins fcfd2be41b create a customer when a payment happens 2019-12-17 10:03:00 +11:00
Rimian Perkins 7d3ca0421a rm old donation form 2019-12-16 10:59:59 +11:00
Rimian Perkins 4b334a69b5 remove subscribe index 2019-12-13 11:54:32 +11:00
Rimian Perkins 57fb508514 buttons for selecting price and one time payment 2019-12-13 10:41:14 +11:00
Rimian Perkins 831e64317b refactor models, routes and buttons 2019-12-12 12:59:26 +11:00
Rimian Perkins 80b721ddd8 rename some settings 2019-12-04 11:53:05 +11:00
Rimian Perkins b397ba5a68 name space module 2019-12-04 11:23:45 +11:00
Rimian Perkins d8a3ae5554 fix broken unauthenticated page 2019-12-03 14:31:15 +11:00
Rimian Perkins bdba7686d3 add new table 2019-12-03 13:03:10 +11:00
Rimian Perkins a95c119bcf fix paths in request specs 2019-12-03 11:48:12 +11:00
Rimian Perkins 949e32e4fb fix path to fabricators 2019-12-03 11:01:44 +11:00
Rimian Perkins 57a18f5a4e whoops did not set currency 2019-11-30 17:24:49 +11:00
Rimian Perkins a371d2baf6 fix broke test 2019-11-30 16:55:24 +11:00
Rimian Perkins 709aebb593 set the currency in the plan 2019-11-30 16:39:28 +11:00
Rimian Perkins 3b7ff90672 user removed from the group in admin 2019-11-29 10:37:32 +11:00
Rimian Perkins 36865c5ea1 remove the user from the group in user controller 2019-11-29 09:24:56 +11:00
Rimian Perkins ad77fc749b test subcription deletes 2019-11-29 08:15:46 +11:00