// List payment methods response
const { paymentMethods } = await monei.paymentMethod.getAll('sub-wallet-id');
paymentMethods.forEach(pm => {
console.log(pm.id); // Payment method ID
console.log(pm.type); // 'card' | 'bank_account'
console.log(pm.last4); // Last 4 digits
console.log(pm.expiryMonth); // Expiry month (for cards)
console.log(pm.expiryYear); // Expiry year (for cards)
console.log(pm.bankName); // Bank name (for bank accounts)
console.log(pm.isDefault); // Whether it's the default method
console.log(pm.createdAt); // Creation date
});
// Create payment method response
const pm = await monei.paymentMethod.create({
type: 'card',
cardNumber: '4111111111111111',
expiryMonth: '12',
expiryYear: '2027',
cvv: '123',
subWalletId: 'sub-wallet-id',
});
console.log(pm.id); // Payment method ID
console.log(pm.type); // Payment method type
console.log(pm.last4); // Last 4 digits of card
console.log(pm.expiryMonth); // Expiry month
console.log(pm.expiryYear); // Expiry year
console.log(pm.isDefault); // Default status
// Get payment method details response
const pm = await monei.paymentMethod.get('pm-id');
console.log(pm.id); // Payment method ID
console.log(pm.type); // Payment method type
console.log(pm.last4); // Last 4 digits
console.log(pm.expiryMonth); // Expiry month (for cards)
console.log(pm.expiryYear); // Expiry year (for cards)
console.log(pm.bankName); // Bank name (for bank accounts)
console.log(pm.accountName); // Account name (for bank accounts)
console.log(pm.isDefault); // Default status
console.log(pm.createdAt); // Creation date
// Set default response (no data returned, just success)
await monei.paymentMethod.setDefault('pm-id');
console.log('Default payment method updated successfully');
// Delete response (no data returned, just success)
await monei.paymentMethod.delete('pm-id');
console.log('Payment method deleted successfully');