Skip to content

Payment System

Checkout Service
Payment Gateway (trait)
├── Stripe Gateway
├── Airwallex Gateway
└── Mock Gateway
Payment Intent → Client confirms → Server verifies

All payment gateways implement the PaymentGateway trait:

#[async_trait]
pub trait PaymentGateway: Send + Sync {
fn id(&self) -> &str;
fn name(&self) -> &str;
async fn create_payment(&self, request: CreatePaymentRequest) -> Result<PaymentSession>;
async fn confirm_payment(&self, payment_id: &str) -> Result<Payment>;
async fn capture_payment(&self, payment_id: &str, amount: Option<Decimal>) -> Result<Payment>;
async fn refund_payment(&self, payment_id: &str, amount: Option<Decimal>, reason: &str) -> Result<Refund>;
async fn get_payment(&self, payment_id: &str) -> Result<Payment>;
}
  1. POST /checkout/completecreate_payment() → returns client_secret
  2. Client-side: mount payment element with client_secret
  3. User enters card details and confirms
  4. POST /checkout/confirmget_payment() → verify status
  5. If succeeded → finalize order
  • Uses Stripe Payment Intents API
  • Client-side: Stripe Elements
  • Supports: cards, Apple Pay, Google Pay, 3D Secure
  • Uses Airwallex Payment Intents API
  • Client-side: Airwallex Drop-in
  • Supports: cards, WeChat Pay, Alipay, 3D Secure
  • Amount in major currency units (not cents)

For testing. Always returns success. Useful for development and CI.

[payment]
default_gateway = "stripe"
[payment.stripe]
enabled = true
secret_key = "sk_..."
publishable_key = "pk_..."
[payment.airwallex]
enabled = true
client_id = "..."
api_key = "..."