1. Guides
Synswi
  • Guides
    • Getting Started With the API
    • Card Payment 3DS Integration Flow
    • Cash App Pay Integration Flow
  • API Reference
    • Payment instruments
      • Create a payment instrument
      • Get payment instruments
      • Get a payment instrument by id
      • Create a Payment Instrument
    • Transactions
      • Get a transaction by id
      • Get transactions
      • Create a transaction
      • Update a transaction
      • Refund a transaction
      • Create a cash-app transaction
    • Fees
      • Get current fee profile
    • Programs
      • Accounts
    • Events
      • Get Events
  1. Guides

Card Payment 3DS Integration Flow

1. Create a Card Payment#

Use your Synswi API base URL and access token:
Send the amount in USD cents (1000 = USD 10.00):
{
  "accountId": "acc-example",
  "paymentInstrumentId": "payment-instrument-example",
  "amount": 1000,
  "type": "pull",
  "channel": "online",
  "method": "card"
}

2. Read the Response#

Save the transaction id. If the status is awaiting_authentication and authentication.type is stripe_three_d_secure, continue to Step 3. Otherwise, handle the returned status as described in Step 4.
{
  "id": "transaction-example",
  "status": "awaiting_authentication",
  "authentication": {
    "type": "stripe_three_d_secure",
    "clientSecret": "pi_example_secret_example",
    "publishableKey": "pk_test_example",
    "stripeConnectedAccountId": "acct_example"
  }
}

3. Complete 3DS Authentication#

Install the frontend dependency:
npm install @stripe/stripe-js
Use the transaction returned in Step 2:
const { authentication } = transaction
const { loadStripe } = await import('@stripe/stripe-js/pure')

const stripe = await loadStripe(authentication.publishableKey, {
    stripeAccount: authentication.stripeConnectedAccountId,
    locale: 'en',
})

if (!stripe) {
    throw new Error('Unable to load Stripe')
}

const { error } = await stripe.handleNextAction({
    clientSecret: authentication.clientSecret,
})

if (error) {
    throw new Error(error.message || 'Payment authentication failed')
}
Display any thrown error to the payer. After authentication completes, continue to Step 4.

4. Check the Transaction Status#

Query using the Synswi transaction id from Step 2:
succeeded: Complete the order.
pending: Wait and query again.
awaiting_authentication: Authentication has not completed or the result has not yet synchronized. If Stripe already reports success, wait and query again.
failed: Display failureMessage or failureCode, when provided.
Previous
Getting Started With the API
Next
Cash App Pay Integration Flow
Built with