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

Cash App Pay Integration Flow

1. Create a Payment#

Send the amount in USD cents (1000 = USD 10.00):
{
  "accountId": "acc-example",
  "amount": 1000,
  "type": "pull",
  "channel": "online",
  "method": "cashapp"
}

2. Read the Response#

Save the transaction id and use the returned authentication details:
{
  "id": "transaction-example",
  "status": "awaiting_authentication",
  "authentication": {
    "type": "stripe_cashapp",
    "clientSecret": "pi_example_secret_example",
    "publishableKey": "pk_test_example",
    "stripeConnectedAccountId": "acct_example"
  }
}

3. Complete Cash App Authorization#

Install the frontend dependencies:
npm install @stripe/stripe-js @stripe/react-stripe-js
Use the transaction returned in Step 2 and render CashAppPayment:
import { useState } from 'react'
import { Elements, PaymentElement, useElements, useStripe } from '@stripe/react-stripe-js'
import { loadStripe } from '@stripe/stripe-js/pure'

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

function CashAppPaymentForm() {
    const stripe = useStripe()
    const elements = useElements()
    const [submitting, setSubmitting] = useState(false)
    const [errorMessage, setErrorMessage] = useState('')

    async function confirmPayment(event) {
        event.preventDefault()
        if (!stripe || !elements) return

        setSubmitting(true)
        setErrorMessage('')

        const { error } = await stripe.confirmPayment({
            elements,
            confirmParams: {
                return_url: `${window.location.origin}/payment-result?transactionId=${encodeURIComponent(transaction.id)}`,
            },
        })

        if (error) {
            setErrorMessage(error.message || 'Unable to confirm payment')
            setSubmitting(false)
        }
    }

    return (
        <form onSubmit={confirmPayment}>
            <PaymentElement />
            {errorMessage && <p role="alert">{errorMessage}</p>}
            <button type="submit" disabled={!stripe || !elements || submitting}>
                {submitting ? 'Processing...' : 'Confirm payment'}
            </button>
        </form>
    )
}

export default function CashAppPayment() {
    return (
        <Elements stripe={stripePromise} options={{ clientSecret: authentication.clientSecret }}>
            <CashAppPaymentForm />
        </Elements>
    )
}
Implement /payment-result using Step 4. Read the Synswi transaction ID from the transactionId query parameter.

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: Complete authorization; if already completed, wait and query again.
failed: Display the failure using failureMessage or failureCode, when provided.
Previous
Card Payment 3DS Integration Flow
Next
Create a payment instrument
Built with