Payment API Reference
The Payment module provides comprehensive payment processing functionality with support for multiple payment providers including Stripe, Klarna, and Vipps.
Overview
The Payment API allows you to:
- Get available payment methods
- Create Stripe payment intents and checkout sessions
- Initialize Klarna payments and retrieve orders
- Process Vipps mobile payments
- Validate payment statuses
import SdkService from '../services/SdkService';
// Access payment methods
const payment = SdkService.sdk.payment;
Methods
getAvailableMethods()
Retrieves all available payment methods for the current channel.
getAvailableMethods(): Promise<GetAvailablePaymentMethodsDto[]>
Example
const paymentMethods = await SdkService.sdk.payment.getAvailableMethods();
paymentMethods.forEach(method => {
console.log(`Payment Method: ${method.name}`);
console.log(`Provider: ${method.provider}`);
console.log(`Supported: ${method.is_active}`);
});
Response
interface GetAvailablePaymentMethodsDto {
id: string;
name: string;
provider: 'STRIPE' | 'KLARNA' | 'VIPPS';
is_active: boolean;
configuration: Record<string, any>;
}
Stripe Integration
stripeIntent()
Creates a Stripe Payment Intent for secure card processing.
stripeIntent(params: {
checkout_id: string;
return_ephemeral_key?: boolean;
}): Promise<PaymentIntentStripeDto>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
checkout_id | string | Yes | The checkout session ID |
return_ephemeral_key | boolean | No | Whether to return an ephemeral key for mobile SDKs |
Example
const paymentIntent = await SdkService.sdk.payment.stripeIntent({
checkout_id: 'checkout_123',
return_ephemeral_key: true
});
console.log('Client Secret:', paymentIntent.client_secret);
console.log('Payment Intent ID:', paymentIntent.id);
// Use with Stripe React Native SDK
import { useStripe } from '@stripe/stripe-react-native';
const { confirmPayment } = useStripe();
const handlePayment = async () => {
const { error } = await confirmPayment(paymentIntent.client_secret, {
paymentMethodType: 'Card',
});
if (error) {
console.error('Payment failed:', error);
} else {
console.log('Payment successful!');
}
};
Response
interface PaymentIntentStripeDto {
id: string;
client_secret: string;
status: string;
amount: number;
currency: string;
ephemeral_key?: string;
customer?: string;
}