Skip to main content

Card Payment UI Sample

A reference HTML sample for UI designers and UI developers to test the card payment flow, callback redirects, and integration with the Villa Payment API.


Quick Start​

Option A: Open directly in browser

# From project root
open debug/cardpayment-mock.html

Option B: Serve locally (recommended for CORS)

npx serve debug/
# Open http://localhost:3000/cardpayment-mock.html

What the Sample Includes​

SectionPurpose
For DesignersFlow diagram, redirect URL format, test card numbers
For DevelopersParameter table, code snippets, links to full docs
Test ControlsPreset callback buttons, bypass_order checkbox, editable orderId/grandTotal

Manual Test Steps​

  1. Open debug/cardpayment-mock.html (via open or npx serve debug/)
  2. Set callback to e.g. https://example.com or yourapp://payments
  3. Leave bypass_order checked (skips order verification)
  4. Click Load KBank payment form
  5. Enter KBank test card (see Credit Card Payments)
  6. Complete 3DS if prompted
  7. Redirect target: {callback}/thankyou?orderId=...&status=...&amount=...

Automated Integration Tests​

Run the HTTP integration tests (POST to dev cardpayment API):

python -m pytest tests/cardtoken/test_cardpayment_http_integration.py -v

Tests cover:

  • Basic success flow
  • Callback parameter (app deep link)
  • bypass_order parameter
  • Callback + bypass_order combined
  • Invalid token
  • Missing orderId