mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-12 09:03:27 +00:00
show the payment on the thankyou page
This commit is contained in:
parent
5d94ed8974
commit
ad5961a4c5
@ -3,6 +3,7 @@
|
|||||||
module DiscoursePatrons
|
module DiscoursePatrons
|
||||||
class PatronsController < ::ApplicationController
|
class PatronsController < ::ApplicationController
|
||||||
skip_before_action :verify_authenticity_token, only: [:create]
|
skip_before_action :verify_authenticity_token, only: [:create]
|
||||||
|
before_action :set_api_key
|
||||||
|
|
||||||
def index
|
def index
|
||||||
result = { email: '' }
|
result = { email: '' }
|
||||||
@ -15,14 +16,12 @@ module DiscoursePatrons
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
result = { }
|
result = Stripe::PaymentIntent.retrieve(params[:pid])
|
||||||
|
|
||||||
render json: result
|
render json: result
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
::Stripe.api_key = SiteSetting.discourse_patrons_secret_key
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
response = ::Stripe::PaymentIntent.create(
|
response = ::Stripe::PaymentIntent.create(
|
||||||
@ -55,6 +54,10 @@ module DiscoursePatrons
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_api_key
|
||||||
|
::Stripe.api_key = SiteSetting.discourse_patrons_secret_key
|
||||||
|
end
|
||||||
|
|
||||||
def param_currency_to_number
|
def param_currency_to_number
|
||||||
params[:amount].to_s.sub('.', '').to_i
|
params[:amount].to_s.sub('.', '').to_i
|
||||||
end
|
end
|
||||||
|
7
assets/javascripts/discourse/routes/patrons-show.js.es6
Normal file
7
assets/javascripts/discourse/routes/patrons-show.js.es6
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
|
||||||
|
export default Discourse.Route.extend({
|
||||||
|
model(params) {
|
||||||
|
return ajax(`/patrons/${params.pid}`, { method: "get" });
|
||||||
|
}
|
||||||
|
});
|
@ -20,7 +20,11 @@
|
|||||||
{{payment.username}}
|
{{payment.username}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</td>
|
</td>
|
||||||
<td>{{{stripe-payment-link payment}}}</td>
|
<td>
|
||||||
|
{{#link-to "patrons.show" payment.payment_intent_id}}
|
||||||
|
{{{payment.payment_intent_id}}}
|
||||||
|
{{/link-to}}
|
||||||
|
</td>
|
||||||
<td>{{payment.receipt_email}}</td>
|
<td>{{payment.receipt_email}}</td>
|
||||||
<td>{{{format-duration payment.created_at_age}}}</td>
|
<td>{{{format-duration payment.created_at_age}}}</td>
|
||||||
<td class="amount">{{payment.amount_currency}}</td>
|
<td class="amount">{{payment.amount_currency}}</td>
|
||||||
|
@ -6,6 +6,21 @@
|
|||||||
{{cook-text siteSettings.discourse_patrons_success_page}}
|
{{cook-text siteSettings.discourse_patrons_success_page}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{{#if model}}
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Payment ID</td>
|
||||||
|
<td>{{model.id}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Amount</td>
|
||||||
|
<td>{{model.amount}}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
{{#d-button action="goBack" class="btn btn-primary"}}
|
{{#d-button action="goBack" class="btn btn-primary"}}
|
||||||
{{i18n 'discourse_patrons.buttons.success'}}
|
{{i18n 'discourse_patrons.buttons.success'}}
|
||||||
{{/d-button}}
|
{{/d-button}}
|
||||||
|
@ -40,6 +40,6 @@ en:
|
|||||||
table:
|
table:
|
||||||
head:
|
head:
|
||||||
user: User
|
user: User
|
||||||
payment_intent: Payment Intent
|
payment_intent: Payment ID
|
||||||
receipt_email: Receipt Email
|
receipt_email: Receipt Email
|
||||||
amount: Amount
|
amount: Amount
|
||||||
|
@ -29,9 +29,15 @@ module DiscoursePatrons
|
|||||||
|
|
||||||
describe 'show' do
|
describe 'show' do
|
||||||
it 'responds ok' do
|
it 'responds ok' do
|
||||||
|
::Stripe::PaymentIntent.expects(:retrieve)
|
||||||
get :show, params: { pid: '123' }, format: :json
|
get :show, params: { pid: '123' }, format: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'requests the payment intent' do
|
||||||
|
::Stripe::PaymentIntent.expects(:retrieve).with('abc-1234')
|
||||||
|
get :show, params: { pid: 'abc-1234' }, format: :json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'create' do
|
describe 'create' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user