@lomray/microservice-payment-stripe
Version:
Stripe payment microservice based on NodeJS & inverted json.
37 lines (33 loc) • 1.16 kB
JavaScript
;
var tslib = require('tslib');
var microserviceHelpers = require('@lomray/microservice-helpers');
var classValidator = require('class-validator');
var stripe = require('../../services/payment-gateway/stripe.js');
class SetupIntentInput {
}
tslib.__decorate([
classValidator.Length(1, 36),
classValidator.IsString(),
tslib.__metadata("design:type", String)
], SetupIntentInput.prototype, "userId", void 0);
class SetupIntentOutput {
}
tslib.__decorate([
microserviceHelpers.IsNullable(),
classValidator.IsString(),
tslib.__metadata("design:type", Object)
], SetupIntentOutput.prototype, "clientSecretToken", void 0);
/**
* Setup intent and return client token to get access to adding payment method
*/
const setupIntent = microserviceHelpers.Endpoint.custom(() => ({
input: SetupIntentInput,
output: SetupIntentOutput,
description: 'Setup intent and return client secret key',
}), ({ userId }) => tslib.__awaiter(void 0, void 0, void 0, function* () {
const service = yield stripe.init();
return {
clientSecretToken: yield service.setupIntent(userId),
};
}));
module.exports = setupIntent;