Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | import { PaymentProvider } from '../payment-provider.interface';
export class MockStripeProvider implements PaymentProvider {
readonly name = 'Stripe';
async createCheckoutLink(params: {
tenantId: string;
amount: number;
currency: string;
invoiceId: string;
callbackUrl: string;
}) {
const mockIntentId = `pi_mock_${Math.random().toString(36).substr(2, 9)}`;
return {
checkoutUrl: `https://checkout.stripe.com/pay/${mockIntentId}`,
providerIntentId: mockIntentId,
};
}
async verifyWebhook(payload: any, signature: string) {
// Signature parsing is mocked for local development testing
return {
success: true,
transactionId:
payload.id || `txn_mock_${Math.random().toString(36).substr(2, 9)}`,
amountPaid: payload.amount || 0,
status: 'SUCCESS' as const,
};
}
async refund(transactionId: string, amount: number) {
return {
success: true,
refundId: `re_mock_${Math.random().toString(36).substr(2, 9)}`,
};
}
}
export class MockRazorpayProvider implements PaymentProvider {
readonly name = 'Razorpay';
async createCheckoutLink(params: {
tenantId: string;
amount: number;
currency: string;
invoiceId: string;
callbackUrl: string;
}) {
const mockIntentId = `order_mock_${Math.random().toString(36).substr(2, 9)}`;
return {
checkoutUrl: `https://api.razorpay.com/checkout/${mockIntentId}`,
providerIntentId: mockIntentId,
};
}
async verifyWebhook(payload: any, signature: string) {
return {
success: true,
transactionId:
payload.payment_id ||
`pay_mock_${Math.random().toString(36).substr(2, 9)}`,
amountPaid: payload.amount || 0,
status: 'SUCCESS' as const,
};
}
async refund(transactionId: string, amount: number) {
return {
success: true,
refundId: `ref_mock_${Math.random().toString(36).substr(2, 9)}`,
};
}
}
export class MockEasebuzzProvider implements PaymentProvider {
readonly name = 'Easebuzz';
async createCheckoutLink(params: {
tenantId: string;
amount: number;
currency: string;
invoiceId: string;
callbackUrl: string;
}) {
const mockIntentId = `ez_mock_${Math.random().toString(36).substr(2, 9)}`;
return {
checkoutUrl: `https://pay.easebuzz.in/${mockIntentId}`,
providerIntentId: mockIntentId,
};
}
async verifyWebhook(payload: any, signature: string) {
return {
success: true,
transactionId:
payload.txnid || `ez_txn_${Math.random().toString(36).substr(2, 9)}`,
amountPaid: payload.amount || 0,
status: 'SUCCESS' as const,
};
}
async refund(transactionId: string, amount: number) {
return {
success: true,
refundId: `ez_ref_${Math.random().toString(36).substr(2, 9)}`,
};
}
}
|