Skip to content

Commit 74d71c9

Browse files
mrsaicharan1ritikamotwani
authored andcommitted
Add API keys, buttons for alipay frontend (#3024)
Watching properties for computed properties update
1 parent 5db35fb commit 74d71c9

File tree

11 files changed

+139
-0
lines changed

11 files changed

+139
-0
lines changed

app/components/forms/admin/settings/payment-gateway-form.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ export default Component.extend(FormMixin, {
3838
}
3939
]
4040
},
41+
alipaySecretKey: {
42+
identifier : 'alipay_secret_key',
43+
rules : [
44+
{
45+
type : 'empty',
46+
prompt : this.l10n.t('Please enter the secret key')
47+
}
48+
]
49+
},
50+
51+
alipayPublishableKey: {
52+
identifier : 'alipay_publishable_key',
53+
rules : [
54+
{
55+
type : 'empty',
56+
prompt : this.l10n.t('Please enter the publishable key')
57+
}
58+
]
59+
},
4160

4261
paypalSandboxClient: {
4362
identifier : 'sandbox_client_id',
@@ -134,6 +153,10 @@ export default Component.extend(FormMixin, {
134153
return this.get('settings.omiseTestPublic') || this.get('settings.omiseLivePublic');
135154
}),
136155

156+
isCheckedAliPay: computed('settings.alipaySecretKey', 'settings.alipayPublishableKey', function() {
157+
return this.get('settings.alipaySecretKey') && this.get('settings.alipayPublishableKey');
158+
}),
159+
137160
actions: {
138161
submit() {
139162
this.onValid(() => {
@@ -152,6 +175,12 @@ export default Component.extend(FormMixin, {
152175
'paypalClient' : null
153176
});
154177
}
178+
if (!this.isCheckedAliPay) {
179+
this.settings.setProperties({
180+
'aliPaySecretKey' : null,
181+
'aliPayPublishableKey' : null
182+
});
183+
}
155184
if (this.isCheckedOmise === false) {
156185
this.settings.setProperties({
157186
'omiseTestPublic' : null,

app/components/forms/wizard/basic-details-step.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
4848
return this.get('settings.isOmiseActivated') && find(paymentCurrencies, ['code', this.get('data.event.paymentCurrency')]).omise;
4949
}),
5050

51+
canAcceptAliPay: computed('data.event.paymentCurrency', 'settings.isAliPayActivated', function() {
52+
return this.get('settings.isAliPayActivated') && find(paymentCurrencies, ['code', this.get('data.event.paymentCurrency')]).alipay;
53+
}),
54+
5155
tickets: computed('[email protected]', '[email protected]', function() {
5256
return this.get('data.event.tickets').sortBy('position').filterBy('isDeleted', false);
5357
}),

app/controllers/orders/pending.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export default Controller.extend({
2020
return this.get('model.order.paymentMode') === 'omise';
2121
}),
2222

23+
isAliPay: computed('model.order', function() {
24+
return this.get('model.order.paymentMode') === 'alipay';
25+
}),
26+
2327
paymentAmount: computed('model.order', function() {
2428
return this.get('model.order.amount') * 100;
2529
}),
@@ -34,6 +38,18 @@ export default Controller.extend({
3438
}),
3539

3640
actions: {
41+
aliPayCheckout(order_identifier) {
42+
this.loader.post(`/create_source/${order_identifier}`)
43+
.then(charge => {
44+
if (charge.status) {
45+
this.notify.success('Payment has succeeded');
46+
this.transitionToRoute('orders.view', order_identifier);
47+
} else {
48+
this.notify.error('Payment has failed');
49+
}
50+
});
51+
52+
},
3753
processStripeToken(token) {
3854
// Send this token to server to process payment
3955
this.set('isLoading', true);

app/models/event.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default ModelBase.extend(CustomPrimaryKeyMixin, {
5858
canPayByCheque : attr('boolean', { defaultValue: false }),
5959
canPayByBank : attr('boolean', { defaultValue: false }),
6060
canPayByOmise : attr('boolean', { defaultValue: false }),
61+
canPayByAliPay : attr('boolean', { defaultValue: false }),
6162
canPayOnsite : attr('boolean', { defaultValue: false }),
6263
paymentCountry : attr('string'),
6364
paymentCurrency : attr('string', { defaultValue: 'USD' }),

app/models/setting.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export default ModelBase.extend({
3333
paypalSecret : attr('string'),
3434
paypalSandboxClient : attr('string'),
3535
paypalSandboxSecret : attr('string'),
36+
alipaySecretKey : attr('string'),
37+
alipayPublishableKey : attr('string'),
3638
omiseMode : attr('string'),
3739
omiseTestPublic : attr('string'),
3840
omiseTestSecret : attr('string'),
@@ -41,6 +43,7 @@ export default ModelBase.extend({
4143
stripeClientId : attr('string'),
4244
stripeSecretKey : attr('string'),
4345
stripePublishableKey : attr('string'),
46+
isAliPayActivated : attr('boolean'),
4447
isPaypalActivated : attr('boolean'),
4548
isStripeActivated : attr('boolean'),
4649
isOmiseActivated : attr('boolean'),

app/templates/components/forms/admin/settings/payment-gateway-form.hbs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,38 @@
3636
</div>
3737
<div class="ui hidden divider"></div>
3838
{{/if}}
39+
<div class="inline field">
40+
<label>
41+
{{t 'Enable AliPay'}}
42+
</label>
43+
{{ui-checkbox class='toggle' checked=isCheckedAliPay onChange=(action (mut isCheckedAliPay))}}
44+
</div>
45+
{{#if isCheckedAliPay}}
46+
<h3 class="ui header">
47+
{{t 'AliPay Keys(Stripe Sources)'}}
48+
<div class="sub header">
49+
{{t 'See'}}
50+
<a href="https://stripe.com/docs/dashboard" target="_blank" rel="noopener nofollow">
51+
{{t 'here'}}
52+
</a>
53+
{{t 'on how to obtain these keys.'}}
54+
</div>
55+
</h3>
56+
<div class="field">
57+
<label>
58+
{{t 'Secret Key'}}
59+
</label>
60+
{{input type='text' name='alipay_secret_key' value=settings.alipaySecretKey}}
61+
</div>
62+
<div class="field">
63+
<label>
64+
{{t 'Publishable Key'}}
65+
</label>
66+
{{input type='text' name='alipay_publishable_key' value=settings.alipayPublishableKey}}
67+
</div>
68+
<div class="ui hidden divider"></div>
69+
{{/if}}
70+
3971
<div class="inline field">
4072
<label>
4173
{{t 'Enable PayPal'}}

app/templates/components/forms/orders/order-form.hbs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@
143143
<label for="payment_mode"><img src="/images/payment-logos/omise.png" alt="omise"></label>
144144
</div>
145145
{{/if}}
146+
{{#if data.event.canPayByAliPay}}
147+
<div class="field">
148+
{{ui-radio name='payment_mode' label=(t 'AliPay') value='alipay' current=data.paymentMode
149+
onChange=(action (mut data.paymentMode))}}
150+
<label for="payment_mode"><img src="/images/payment-logos/alipay.png" alt="alipay"></label>
151+
</div>
152+
{{/if}}
146153
{{#if data.event.canPayByCheque}}
147154
<div class="field">
148155
{{ui-radio name='payment_mode' label=(t 'Cheque') value='cheque' current=data.paymentMode

app/templates/components/forms/wizard/basic-details-step.hbs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,25 @@
314314
</div>
315315
{{/if}}
316316
{{/if}}
317+
{{#if canAcceptAliPay}}
318+
<label>{{t 'Payment with AliPay'}}</label>
319+
<div class="field payments">
320+
<div class="ui checkbox">
321+
{{input type='checkbox' id='payment_by_alipay' checked=data.event.canPayByAliPay}}
322+
<label for="payment_by_alipay">
323+
{{t 'Yes, accept payment through AliPay Gateway'}}
324+
<div class="ui hidden divider"></div>
325+
<span class="text muted">
326+
{{t 'AliPay can accept Credit and Debit Cards , Net-Banking and AliPay. Find more details '}}
327+
<a href="https://stripe.com/docs/sources/alipay" target="_blank" rel="noopener noreferrer">{{t 'here'}}</a>.
328+
</span>
329+
</label>
330+
</div>
331+
</div>
332+
{{#if data.event.canPayByAliPay}}
333+
<label>{{t 'AliPay Gateway has been successfully activated'}}</label>
334+
{{/if}}
335+
{{/if}}
317336
{{#if canAcceptOmise}}
318337
<label>{{t 'Payment with Omise'}}</label>
319338
<div class="field payments">

app/templates/orders/pending.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
</form>
3131
</div>
3232
{{/if}}
33+
{{#if isAliPay}}
34+
<button class="ui button primary" {{action alipayCheckout model.order.identifier}}>{{t 'Pay with AliPay'}}</button>
35+
{{/if}}
3336
</div>
3437
<div class="row">
3538
<div class="nine wide column">

0 commit comments

Comments
 (0)