@malga-checkout/core
Version:
Core components for Malga Checkout
23 lines (22 loc) • 883 B
JavaScript
import { BaseProvider } from '../base-provider';
import { parseInstallments } from '@malga-checkout/utils';
import settings from '../../stores/settings';
import { handleAlreadyTokenizedCard, handleTokenizationFlow, } from './card.utils';
export class Card extends BaseProvider {
constructor({ card }) {
super({ customer: null, customerId: null });
this.card = card;
}
getPaymentMethod() {
var _a;
const recurrence = (_a = settings.paymentMethods.credit) === null || _a === void 0 ? void 0 : _a.recurrence;
return Object.assign({ paymentType: 'credit', installments: parseInstallments(this.card['installments']) }, (recurrence && { recurrence }));
}
async getPaymentSource() {
if (this.card['cardCvv'] &&
this.card['cardId']) {
return handleAlreadyTokenizedCard(this.card);
}
return await handleTokenizationFlow(this.card);
}
}