add the amount as a combo-box

This commit is contained in:
Rimian Perkins 2017-02-23 12:48:06 +11:00
parent 08e0e47d3e
commit 551b578b21
4 changed files with 18 additions and 9 deletions

View File

@ -2,6 +2,8 @@ import { ajax } from 'discourse/lib/ajax';
export default Ember.Component.extend({
result: null,
paymentAmounts: [5, 10],
amount: null,
stripe: Stripe('pk_test_b8RmhzlL8QPizJRqOrKF3JEV'),
card: function() {
@ -28,9 +30,11 @@ export default Ember.Component.extend({
else {
var params = {
stripeToken: result.token.id,
amount: 1235
amount: self.get('amount') * 100
};
console.log(params);
ajax('/charges', { data: params, method: 'post' }).then(data => {
self.set('result', (data.status == 'succeeded' ? true : null));
}).catch((data) => {

View File

@ -1,5 +1,12 @@
<form id="payment-form" class="form-horizontal">
<div class="control-group" style="width: 550px;">
<label class="control-label" for="card-element">{{i18n 'discourse_payments.amount'}}</label>
<div class="controls controls-dropdown">
{{combo-box valueAttribute="value" content=paymentAmounts value=amount}}
</div>
</div>
<div class="control-group" style="width: 550px;">
<label class="control-label" for="card-element">{{i18n 'discourse_payments.card'}}</label>
<div id="card-element" class="controls"></div>
@ -8,12 +15,9 @@
<div class="control-group save-button">
<div class="controls">
<button {{action "submitStripeCard"}} class="btn btn-primary">{{i18n 'discourse_payments.submit'}}</button>
{{#if result}}
<span>{{i18n 'discourse_payments.success'}}</span>
{{/if}}
</div>
</div>
{{#if result}}
<div class="control-group">
<span>{{i18n 'discourse_payments.success'}}</span>
</div>
{{/if}}
</form>

View File

@ -2,6 +2,7 @@ en:
js:
discourse_payments:
title: Donate
amount: Amount
card: Credit or debit card
success: Payment Successful
success: Payment Successful!
submit: Make Payment

View File

@ -1,6 +1,6 @@
# name: discourse-payments
# about: Integrating Discourse with Stripe
# version: 1.4.0
# version: 1.5.0
# url: https://github.com/choiceaustralia/discourse-payments
# authors: Rimian Perkins