respond to incomplete payment

This commit is contained in:
Rimian Perkins 2020-01-14 18:46:48 +11:00
parent 95413ee161
commit b83da467d0
4 changed files with 34 additions and 15 deletions

View File

@ -12,7 +12,16 @@ See [Screenshots](#screenshots) below.
* Be sure your site is enforcing https.
* Follow the install instructions here: https://meta.discourse.org/t/install-a-plugin/19157
* Add your Stripe public and private keys in settings and set the currency to your local value.
##Settings:
You'll need to get some info from your Stripe account to complete the steps below: https://dashboard.stripe.com/
* Add your Stripe public and private keys
* Set the currency to your local value.
* Add your Stripe webhook secret.
See webhook info below.
## What are Subscriptions?
@ -34,6 +43,14 @@ Firstly, you'll need an account with the [Stripe](https://stripe.com) payment ga
When you get a moment, take a look at Stripe's documentation. But for now, you can set up an account in test mode and see how it all works without making any real transactions. Then, if you're happy with how everything works, you can start taking real transactions. See below for test credit card numbers.
### Enable Webhooks in your Stripe account
You'll need to tell Stripe where your end points are. You can enter this in your Stripe dashboard.
The address for webhooks is: `[your server address]/s/hooks`
Also: Add the webhook secret in settings (above).
### Set up your User Groups in Discourse
When a user successfully subscribes to your Discourse application, after their credit card transaction has been processed, they are added to a User Group. By assigning users to a User Group, you can manage what your users have access to on your website. User groups are a core functionality of Discourse and this plugin does nothing with them except and and remove users from the group you associated with your Plan.
@ -52,17 +69,14 @@ In the admin, add a new Product. Once you have a product saved, you can add plan
If you take a look at your [Stripe Dashboard](https://dashboard.stripe.com), you'll see all those products and plans are listed. Discourse Subscriptions does not create them locally. They are created in Stripe.
## Enable Webhooks
You'll need to tell Stripe where your end points are. You can enter this in your Stripe dashboard.
The address for webhooks is: `/s/hooks`
## Testing
Test with these credit card numbers:
* 4111 1111 1111 1111
* 4111 1111 1111 1111 (no authentication required)
* 4000 0027 6000 3184 (authentication required)
For more test card numbers: https://stripe.com/docs/testing
Visit `/s` and enter a few test transactions.

View File

@ -13,12 +13,10 @@ module DiscourseSubscriptions
event = ::Stripe::Webhook.construct_event(payload, sig_header, webhook_secret)
rescue JSON::ParserError => e
# Invalid payload
status 400
render_json_error e.message
return
rescue Stripe::SignatureVerificationError => e
# Invalid signature
status 400
render_json_error e.message
return
end

View File

@ -49,7 +49,7 @@ export default Ember.Controller.extend({
});
},
createSubsciption(plan) {
createSubscription(plan) {
return this.stripe.createToken(this.get("cardElement")).then(result => {
if (result.error) {
return result;
@ -85,7 +85,7 @@ export default Ember.Controller.extend({
let transaction;
if (this.planTypeIsSelected) {
transaction = this.createSubsciption(plan);
transaction = this.createSubscription(plan);
} else {
transaction = this.createPayment(plan);
}
@ -95,7 +95,12 @@ export default Ember.Controller.extend({
if (result.error) {
bootbox.alert(result.error.message || result.error);
} else {
if(result.status === "incomplete") {
this.alert(`${type}.incomplete`);
}
else {
this.alert(`${type}.success`);
}
const success_route = this.planTypeIsSelected
? "user.billing.subscriptions"

View File

@ -32,6 +32,7 @@ en:
payment_button:
Subscribe
success: Thank you! Your subscription has been created.
incomplete: The payment is incomplete. Your subscription will be updated when payment is complete.
validate:
payment_options:
required: Please select a subscription plan.
@ -43,6 +44,7 @@ en:
payment_button:
Pay Once
success: Thank you!
incomplete: Payment is incomplete.
validate:
payment_options:
required: Please select a payment option.