First Payment
Non-PCI Stripe flow: get the payment_method_id first
payment_method_id first1. Create a client authentication token on your backend
const {
MerchantAuthenticationClient,
IntegrationError,
ConnectorError,
NetworkError,
types,
} = require("hyperswitch-prism");
// Reuse stripeConfig from installation.md
const authClient = new MerchantAuthenticationClient(stripeConfig);
async function createClientAuthenticationToken() {
try {
const response = await authClient.createClientAuthenticationToken({
merchantClientSessionId: "client_session_001",
payment: {
amount: {
minorAmount: 1000,
currency: types.Currency.USD,
},
},
testMode: true,
});
const clientSecret =
response.sessionData?.connectorSpecific?.stripe?.clientSecret?.value;
console.log("Client secret:", clientSecret);
return clientSecret;
} catch (error) {
if (error instanceof IntegrationError) {
console.error(
"Integration error:",
error.errorCode,
error.message,
);
} else if (error instanceof ConnectorError) {
console.error(
"Connector error:",
error.errorCode,
error.message,
);
} else if (error instanceof NetworkError) {
console.error("Network error:", error.errorCode, error.message);
} else {
console.error(
"Client auth token creation failed:",
error.message || error,
);
}
throw error;
}
}2. Use the client_secret in Stripe.js / Stripe Elements
client_secret in Stripe.js / Stripe ElementsAuthorize with Payment Method ID
Authorize with Raw Card Details (PCI Compliant)
Complete Payment Flow
Error Scenarios
Declined Card
Network Timeout
Business Use Cases
E-commerce: Two-Step Flow
SaaS: Immediate Capture
Marketplace: Partial Refund
Key Takeaways
Last updated
Was this helpful?

