// tslint:disable:no-console import * as moment from 'moment'; import * as mongoose from 'mongoose'; import * as redis from 'redis'; import { chevre } from '../../../lib/index'; const project = { id: String(process.env.PROJECT_ID) }; // tslint:disable-next-line:max-func-body-length async function main() { const client = redis.createClient({ host: process.env.REDIS_HOST, port: Number(process.env.REDIS_PORT), password: process.env.REDIS_KEY }); await mongoose.connect(process.env.MONGOLAB_URI, { autoIndex: false }); const accountingReportRepo = new chevre.repository.AccountingReport(mongoose.connection); const actionRepo = new chevre.repository.Action(mongoose.connection); const productRepo = new chevre.repository.Product(mongoose.connection); const projectRepo = new chevre.repository.Project(mongoose.connection); const sellerRepo = new chevre.repository.Seller(mongoose.connection); const taskRepo = new chevre.repository.Task(mongoose.connection); const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection); const eventRepo = new chevre.repository.Event(mongoose.connection); const personRepo = new chevre.repository.Person({ userPoolId: 'xxx' }); const transactionNumberRepo = new chevre.repository.TransactionNumber(client); const { transactionNumber } = await transactionNumberRepo.publishByTimestamp({ startDate: new Date() }); const transaction = await chevre.service.assetTransaction.pay.start({ project: { id: project.id, typeOf: chevre.factory.organizationType.Project }, typeOf: chevre.factory.assetTransactionType.Pay, transactionNumber: transactionNumber, agent: { typeOf: chevre.factory.personType.Person, name: 'サンプル決済者名称', id: '' }, expires: moment() .add(1, 'minute') .toDate(), object: { typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard, id: '5f9a6986cc98a1eb13a90285', paymentMethod: { amount: 1, // paymentMethodId?: string; typeOf: 'CreditCard', method: '1', creditCard: { memberId: 'a7909268-a584-425e-8212-d7d10f344093', cardSeq: 91 // cardPass?: string; } } }, recipient: { typeOf: chevre.factory.organizationType.Corporation, id: '5d0abf30ac3fb200198ebb2c', name: 'xx' } })({ accountingReport: accountingReportRepo, action: actionRepo, event: eventRepo, person: personRepo, product: productRepo, project: projectRepo, seller: sellerRepo, assetTransaction: assetTransactionRepo, task: taskRepo }); console.log(transaction); console.log('transaction started'); } main() .then(() => { console.log('success!'); }) .catch(console.error);