Tokenize
Last updated
Was this helpful?
Was this helpful?
const { PaymentMethodClient } = require('hyperswitch-prism');
const paymentMethodClient = new PaymentMethodClient({
connector: 'stripe',
apiKey: 'YOUR_API_KEY',
environment: 'SANDBOX'
});const request = {
paymentMethod: {
card: {
cardNumber: { value: "4242424242424242" },
cardExpMonth: { value: "12" },
cardExpYear: { value: "2027" },
cardCvc: { value: "123" },
cardHolderName: { value: "John Doe" }
}
},
customerId: "cus_xxx"
};
const response = await paymentMethodClient.tokenize(request);{
paymentMethodId: "pm_3Oxxx...",
paymentMethodType: "card",
status: "ACTIVE",
fingerprint: "abc123...",
statusCode: 200
}// Use the token in authorize
const authResponse = await paymentClient.authorize({
merchantTransactionId: "txn_001",
amount: { minorAmount: 1000, currency: "USD" },
paymentMethod: {
paymentMethodId: "pm_3Oxxx..." // Use token instead of raw card
},
authType: "NO_THREE_DS"
});