respond to incomplete payment
This commit is contained in:
parent
95413ee161
commit
b83da467d0
30
README.md
30
README.md
|
@ -12,7 +12,16 @@ See [Screenshots](#screenshots) below.
|
||||||
|
|
||||||
* Be sure your site is enforcing https.
|
* Be sure your site is enforcing https.
|
||||||
* Follow the install instructions here: https://meta.discourse.org/t/install-a-plugin/19157
|
* 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?
|
## 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.
|
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
|
### 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.
|
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.
|
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
|
## Testing
|
||||||
|
|
||||||
Test with these credit card numbers:
|
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.
|
Visit `/s` and enter a few test transactions.
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,10 @@ module DiscourseSubscriptions
|
||||||
event = ::Stripe::Webhook.construct_event(payload, sig_header, webhook_secret)
|
event = ::Stripe::Webhook.construct_event(payload, sig_header, webhook_secret)
|
||||||
|
|
||||||
rescue JSON::ParserError => e
|
rescue JSON::ParserError => e
|
||||||
# Invalid payload
|
render_json_error e.message
|
||||||
status 400
|
|
||||||
return
|
return
|
||||||
rescue Stripe::SignatureVerificationError => e
|
rescue Stripe::SignatureVerificationError => e
|
||||||
# Invalid signature
|
render_json_error e.message
|
||||||
status 400
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default Ember.Controller.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
createSubsciption(plan) {
|
createSubscription(plan) {
|
||||||
return this.stripe.createToken(this.get("cardElement")).then(result => {
|
return this.stripe.createToken(this.get("cardElement")).then(result => {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -85,7 +85,7 @@ export default Ember.Controller.extend({
|
||||||
let transaction;
|
let transaction;
|
||||||
|
|
||||||
if (this.planTypeIsSelected) {
|
if (this.planTypeIsSelected) {
|
||||||
transaction = this.createSubsciption(plan);
|
transaction = this.createSubscription(plan);
|
||||||
} else {
|
} else {
|
||||||
transaction = this.createPayment(plan);
|
transaction = this.createPayment(plan);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,12 @@ export default Ember.Controller.extend({
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
bootbox.alert(result.error.message || result.error);
|
bootbox.alert(result.error.message || result.error);
|
||||||
} else {
|
} else {
|
||||||
|
if(result.status === "incomplete") {
|
||||||
|
this.alert(`${type}.incomplete`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.alert(`${type}.success`);
|
this.alert(`${type}.success`);
|
||||||
|
}
|
||||||
|
|
||||||
const success_route = this.planTypeIsSelected
|
const success_route = this.planTypeIsSelected
|
||||||
? "user.billing.subscriptions"
|
? "user.billing.subscriptions"
|
||||||
|
|
|
@ -32,6 +32,7 @@ en:
|
||||||
payment_button:
|
payment_button:
|
||||||
Subscribe
|
Subscribe
|
||||||
success: Thank you! Your subscription has been created.
|
success: Thank you! Your subscription has been created.
|
||||||
|
incomplete: The payment is incomplete. Your subscription will be updated when payment is complete.
|
||||||
validate:
|
validate:
|
||||||
payment_options:
|
payment_options:
|
||||||
required: Please select a subscription plan.
|
required: Please select a subscription plan.
|
||||||
|
@ -43,6 +44,7 @@ en:
|
||||||
payment_button:
|
payment_button:
|
||||||
Pay Once
|
Pay Once
|
||||||
success: Thank you!
|
success: Thank you!
|
||||||
|
incomplete: Payment is incomplete.
|
||||||
validate:
|
validate:
|
||||||
payment_options:
|
payment_options:
|
||||||
required: Please select a payment option.
|
required: Please select a payment option.
|
||||||
|
|
Loading…
Reference in New Issue