"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCustomer = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const config_1 = require("./config");
const lib_1 = require("../../lib");
exports.createCustomer = {
    key: 'createCustomer',
    category: extensions_core_1.Category.BILLING,
    title: 'Create customer',
    description: 'Create a customer in Stripe',
    fields: config_1.fields,
    previewable: true,
    dataPoints: config_1.dataPoints,
    onActivityCreated: async (payload, onComplete, onError) => {
        const { fields: input, stripe, patient, } = await (0, lib_1.validateAndCreateStripeSdk)({
            fieldsSchema: config_1.FieldsValidationSchema,
            payload,
        });
        const res = await stripe.customers.create({
            email: input.email,
            name: input.name,
            metadata: {
                awellPatientId: patient.id,
            },
        });
        await onComplete({
            data_points: {
                customerId: res.id,
            },
        });
    },
};
//# sourceMappingURL=createCustomer.js.map