> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pushcash.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apple Pay Withdrawals

<div className="Goal">
  ## Goal

  Enable a returning user to withdraw funds to the debit card they previously used to deposit via Apple Pay.
</div>

<Note>
  This flow builds on the [Apple Pay Integration](./integration-apple-pay) guide. Users must have completed an initial deposit through the Apple Pay flow before they can withdraw to their Apple Pay debit card. Complete that integration first.
</Note>

## Steps

***

## Step 1: Display stored credentials and enable selection

<div className="What">
  <p className="bold-header">What you need to do</p>

  Display the debit cards a user previously used with Apple Pay and allow them to select one to withdraw to.
</div>

#### How to do it

1. Call the [list-user-credentials](./apireference/user/list-user-credentials) endpoint with the user’s ID.
2. Filter the returned credentials for those with type `apple_pay_debit`. Only these credentials can be used for withdrawals to a debit card stored via Apple Pay.
3. Render the filtered credentials in your UI so they are easily identifiable, and allow the user to select which card they would like to withdraw to.

<Note>
  For `apple_pay_debit` credentials, the `card_last4` field contains the last four digits of the user’s **FPAN** (the funding primary account number — i.e. the physical card number), not the last four of the device-specific card token (DPAN) generated by Apple. Display `card_last4` so the user can recognize their physical card.
</Note>

## Step 2: Submit the withdrawal for authorization

<div className="What">
  <p className="bold-header">What you need to do</p>

  Submit the withdrawal using the credential selected by the user.
</div>

#### How to do it

1. Call the [authorize-payment](./apireference/authorization/authorize-payment) endpoint with the selected `credential_id`, `direction` set to `cash_out`, and the `amount`.
2. On a `200` response, the withdrawal was approved. Display the result to the user.
3. Handle the `401` response. In a small number of edge cases the user’s debit card does not support **OCT** (Original Credit Transactions), which are required to push funds to the card. When this occurs, prompt the user to withdraw to a different card.

<Note>
  A `401` indicates the selected card cannot receive funds via OCT. This is determined by the card issuer and is not something the user can resolve for that card — guide them to select or add another debit card to complete the withdrawal.
</Note>

<RequestExample>
  ```bash List User Credentials theme={null}
  curl --request GET \
    --url https://sandbox.pushcash.com/user/{id}/credentials \
    --header 'Authorization: Bearer <token>'
  ```

  ```bash Authorize Withdrawal With Credential ID theme={null}
  curl --request POST \
    --url https://sandbox.pushcash.com/authorize \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '
  {
    "user_id": "user_lVpbPL0K1XIiHx0DxipRbD",
    "credential_id": "cred_sandbox_123",
    "amount": 2500,
    "currency": "USD",
    "direction": "cash_out"
  }
  '
  ```
</RequestExample>

<ResponseExample>
  ```json List User Credentials - 200 OK theme={null}
  {
    "data": [
      {
        "id": "cred_7YlA9IiSl8UZvNwNSbFajV",
        "created_at": "2023-05-24T20:15:18.158Z",
        "card_last4": "4444",
        "authenticated": true,
        "type": "apple_pay_debit",
        "account_last4": null,
        "bank_name": null
      },
      {
        "id": "cred_8ZlB0JjTm9VZaOxOTcGbkW",
        "created_at": "2023-05-25T10:20:30.123Z",
        "card_last4": "1234",
        "authenticated": true,
        "type": "apple_pay",
        "account_last4": null,
        "bank_name": null
      }
    ]
  }
  ```
</ResponseExample>

## Integration checklist

* Create a stored `apple_pay_debit`-type credential by performing a deposit with a debit card from your Apple Pay wallet
  * Verify that the credential is displayed with `card_last4`
  * Test submitting a withdrawal transaction using the stored credential
* Create a stored `apple_pay`-type credential by performing a deposit with a credit card from your Apple Pay wallet, verify the credential is not presented for withdrawals.
* Test an OCT-decline by submitting a transaction with an `apple_pay_debit`-type credential for the amount of \$22.00

## Next steps

Enable withdrawals to be reviewed manually ahead of posting funds to the user's account. Refer to the [manual review](/manual-review) guide for details.
