Slide 55
Slide 55 text
simalexan
const pubsubRepository = require('./pubsub-repository'),
paymentProcessorRepository = require('./payment-processor'),
TOPIC_ARN = process.env.TOPIC_ARN;
module.exports = async function chargeCustomer(
secretKey,
token,
email,
amount,
currency,
description = 'Charge Description',
paymentProcessor = paymentProcessorRepository,
pubsub = pubsubRepository,
subject = TOPIC_ARN
){
const createdCharge = await paymentProcessor.createCharge(secretKey, token,
amount, currency, description);
createdCharge.email = email;
await pubsub.publish(createdCharge, subject);
return createdCharge;
}