@malga-checkout/core
Version:
Core components for Malga Checkout
22 lines (21 loc) • 587 B
JavaScript
import { Api } from '../api';
import settings from '../../stores/settings';
import { getZeroDollar } from './cards.utils';
export class Cards {
constructor({ tokenId }) {
this.api = new Api();
this.tokenId = tokenId;
}
async create() {
const zeroDollar = getZeroDollar();
const response = await this.api.create({
endpoint: settings.sessionId ? '/sessions/cards' : '/cards',
data: Object.assign({ tokenId: this.tokenId }, zeroDollar),
});
const cardId = response.data.id;
if (!cardId) {
return;
}
return response.data.id;
}
}