Vulcan/packages/vulcan-payments/lib/modules/charges/schema.js

103 lines
1.5 KiB
JavaScript
Raw Normal View History

import moment from 'moment';
2017-05-31 10:25:13 +09:00
const schema = {
// default properties
_id: {
type: String,
optional: true,
viewableBy: ['guests'],
},
createdAt: {
type: Date,
optional: true,
viewableBy: ['guests'],
onInsert: (document, currentUser) => {
return new Date();
},
2017-05-31 10:25:13 +09:00
},
userId: {
type: String,
optional: true,
viewableBy: ['guests'],
},
// custom properties
associatedCollection: {
type: String,
optional: true,
},
associatedId: {
type: String,
optional: true,
},
2017-05-31 10:25:13 +09:00
tokenId: {
type: String,
optional: false,
},
productKey: {
type: String,
optional: true,
},
type: {
type: String,
optional: false,
},
test: {
type: Boolean,
optional: true,
},
data: {
type: Object,
2018-01-02 13:05:34 +09:00
viewableBy: ['guests'],
2017-05-31 10:25:13 +09:00
blackbox: true,
},
properties: {
type: Object,
blackbox: true,
},
ip: {
type: String,
optional: true,
},
// GraphQL only
createdAtFormatted: {
type: String,
optional: true,
2018-01-02 13:05:34 +09:00
viewableBy: ['guests'],
resolveAs: {
type: 'String',
resolver: (charge, args, context) => {
return moment(charge.createdAt).format('dddd, MMMM Do YYYY');
}
}
},
stripeChargeUrl: {
type: String,
optional: true,
2018-01-02 13:05:34 +09:00
viewableBy: ['guests'],
resolveAs: {
type: 'String',
resolver: (charge, args, context) => {
return `https://dashboard.stripe.com/payments/${charge.data.id}`;
}
}
},
2017-05-31 10:25:13 +09:00
};
export default schema;