0.5.12 • Published 5 years ago
ycs-plugin-payments v0.5.12
Installation
ycs add plugin payments
configurations
import { IContext } from '@ycs/core/lib/context';
import { IConfig, EChannel, ECurrency, IChargeDocument } from 'ycs-plugin-payments';
import { Client, EClientSignType } from '@ycnt/alipay';
export const development: IConfig = {
roles: ['payments'],
payments: [
{
path: 'order',
channels: [EChannel.alipay],
currencies: [ECurrency.cny],
charge: async (ctx: IContext): Promise<IChargeDocument> => {
const order: any = 'xxx';
return {
channel: ctx.request.fields.channel,
currency: ECurrency.cny,
client_ip: ctx.request.ip,
subject: order.subject,
body: order.body,
amount: order.price,
extra: {
orderId: order._id,
},
__auth: ctx.request.auth._id,
};
},
webhook: async (doc: IChargeDocument): Promise<void> => {
const order: any = 'xxx by doc.extra.orderId';
order.status = 'paid';
await order.save()
},
alipayClient: new Client({
appId: 'xxx',
rsaPrivate: 'xxx',
rsaPublic: 'xxx',
signType: EClientSignType.RSA2,
sandbox: true
}),
https: false
},
],
};
export const production: IConfig = {
roles: ['payments'],
payments: [
{
path: 'order',
channels: [EChannel.alipay],
currencies: [ECurrency.cny],
charge: async (ctx: IContext): Promise<IChargeDocument> => {
const order: any = 'xxx';
return {
channel: ctx.request.fields.channel,
currency: ECurrency.cny,
client_ip: ctx.request.ip,
subject: order.subject,
body: order.body,
amount: order.price,
extra: {
orderId: order._id,
},
__auth: ctx.request.auth._id,
};
},
webhook: async (doc: IChargeDocument): Promise<void> => {
const order: any = 'xxx by doc.extra.orderId';
order.status = 'paid';
await order.save()
},
alipayClient: new Client({
appId: 'xxx',
rsaPrivate: 'xxx',
rsaPublic: 'xxx',
signType: EClientSignType.RSA2,
sandbox: true
}),
https: false
},
],
};
0.5.12
5 years ago
0.5.11
6 years ago
0.5.10
6 years ago
0.5.9
6 years ago
0.5.8
6 years ago
0.5.7
6 years ago
0.5.6
6 years ago
0.5.5
6 years ago
0.5.4
6 years ago
0.5.3
6 years ago
0.5.2
6 years ago
0.5.1
6 years ago
0.5.0
6 years ago
0.4.9
6 years ago
0.4.8
6 years ago
0.4.7
6 years ago
0.4.6
6 years ago
0.4.5
6 years ago
0.4.4
6 years ago
0.4.3
6 years ago
0.4.2
6 years ago
0.4.1
6 years ago
0.4.0
6 years ago
0.3.6
6 years ago
0.3.5
6 years ago
0.3.4
6 years ago
0.3.3
6 years ago
0.3.2
6 years ago
0.3.1
6 years ago
0.3.0
6 years ago
0.2.0
6 years ago
0.1.9
6 years ago
0.1.8
6 years ago
0.1.7
6 years ago
0.1.6
6 years ago
0.1.5
6 years ago
0.1.4
6 years ago
0.1.3
6 years ago
0.1.2
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago