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

# APM deposit (End-to-end)

> Support Apple Pay, Google Pay, PayPal and Venmo deposits in a single Payment Widget session that handles account selection, payment method selection, quoting, authorization and transaction status.

The Payment Widget's `transaction:deposit-e2e` flow handles the entire APM deposit in one session: the user picks the destination Uphold account, selects the payment method, enters the amount, reviews a live quote, authorizes the payment with the APM and sees the status of the transaction — all without your backend creating a quote or a `transaction:authorize` session.

> [!NOTE]
>
> If you need to build the amount entry and review screens yourself, see the per-method guides instead, for example [Apple Pay](https://developer.uphold.com/developer-guides/apm-transfers/deposit/via-payment-widget/hybrid-flow/apple-pay.md), [Google Pay](https://developer.uphold.com/developer-guides/apm-transfers/deposit/via-payment-widget/hybrid-flow/google-pay.md), [PayPal](https://developer.uphold.com/developer-guides/apm-transfers/deposit/via-payment-widget/hybrid-flow/paypal.md) or [Venmo](https://developer.uphold.com/developer-guides/apm-transfers/deposit/via-payment-widget/hybrid-flow/venmo.md). To compare all flows, see [Flows](https://developer.uphold.com/widgets/payment/flows.md).

## Prerequisites

* The user has [completed onboarding](https://developer.uphold.com/developer-guides/user-onboarding/introduction.md) and has the required capabilities enabled.
* The Payment Widget is set up in your frontend. See [Installation and setup](https://developer.uphold.com/widgets/payment/installation-and-setup.md).
* `@uphold/enterprise-payment-widget-web-sdk` is on a version that supports the end-to-end flows.
* The additional requirements of each APM you offer are met, such as those for [Apple Pay](https://developer.uphold.com/developer-guides/apm-transfers/introduction.md#apple-pay) and [Venmo](https://developer.uphold.com/developer-guides/apm-transfers/introduction.md#venmo).
* The target browser or platform [supports the APM](https://developer.uphold.com/developer-guides/apm-transfers/introduction.md#browser-and-platform-compatibility-payment-widget).

## Walkthrough

```mermaid theme={null}
sequenceDiagram
  autonumber
  participant Usr as User
  participant U as Your App
  participant B as Your Backend
  participant P as Payment Widget
  participant A as Uphold

  Usr->>U: Start deposit
  U->>B: Create widget session
  B->>A: Create widget session (deposit)
  A-->>B: { session }
  B-->>U: { session }
  U->>P: Initialize widget
  Usr->>P: Select destination account and APM, enter amount, review quote, confirm
  Usr->>P: Authorize with the APM
  P->>A: Create transaction
  A-->>P: { transaction }
  A-->>B: webhook: transaction.created (processing)
  P-->>U: complete { transaction, trigger }

  A-->>B: webhook: transaction.status-changed (completed/failed)
  B-->>Usr: Notify the user
```

***

## Complete the deposit in the widget

The widget session takes the user from account and payment method selection through the amount, quote and APM authorization.

### Create a widget session

Call [Create widget session](https://developer.uphold.com/rest-apis/widgets-api/payment/create-session.md) to start the `transaction:deposit-e2e` flow. No `data` is required — the widget gathers everything from the user. Use `options` to customize the Widget's `theme` and `layout`, as well as the flow itself. See the example [here](https://developer.uphold.com/widgets/payment/installation-and-setup.md#1-create-a-session-on-your-backend) and the [SDK reference](https://developer.uphold.com/widgets/payment/sdk-reference.md#options) for all available options.

By default, the end-to-end flows offer every payment method: bank, card, crypto and APMs. To offer APMs only, set `paymentMethods` to the APMs you want:

```http theme={null}
POST /widgets/payment/sessions
{
  "flow": "transaction:deposit-e2e",
  "options": {
    "paymentMethods": [
      { "type": "apple-pay" },
      { "type": "google-pay" },
      { "type": "paypal" }
    ],
    "initialSelection": { "destination": { "asset": "USD" } }
  }
}
```

> [!NOTE]
>
> The widget creates the `transaction:authorize` session for the APM itself, so you don't create one.
>
> * **Apple Pay:** don't pass a `domain`. The widget determines the domain of the top-level page and uses it to validate the merchant with Apple Pay. For production, that domain must still be [registered with Apple Pay](https://developer.uphold.com/developer-guides/apm-transfers/introduction.md#apple-pay).
> * **Headless mode:** not currently supported in the end-to-end flows. The widget always shows its own authorization screens, even if `authorize.mode` is set to `headless`.
> * **Venmo:** on iOS Safari, Venmo is not available in the end-to-end flows.

The response contains a `session` object with a `url` field that loads the widget. Return `response.session` to your frontend as is.

```jsonc theme={null}
{
  "session": {
    "url": "https://payment-widget.enterprise.uphold.com/?sessionToken=..."
    // ...
  }
}
```

### Set up the widget

```typescript Web SDK [expandable] theme={null}
import { PaymentWidget } from '@uphold/enterprise-payment-widget-web-sdk';

const initializeDepositWidget = async (session) => {
  const widget = new PaymentWidget<'transaction:deposit-e2e'>(session, { debug: true });

  widget.on('complete', (event) => {
    console.log('Complete', JSON.stringify(event.detail.value));
    widget.unmount();
  });

  widget.on('cancel', () => {
    console.log('Cancelled');
    widget.unmount();
  });

  widget.on('error', (event) => {
    console.error('Error', event.detail.error);
    widget.unmount();
  });

  widget.mountIframe(document.getElementById('payment-container'));
};
```

```html Without SDK [expandable] theme={null}
<div id="payment-container"></div>

<script>
  // session is `response.session` from your backend
  async function initializeDepositWidget(session) {
    const container = document.getElementById('payment-container');
    const sessionOrigin = new URL(session.url).origin;

    const iframe = document.createElement('iframe');
    iframe.src = session.url;
    iframe.setAttribute('allow', "clipboard-write 'src'; clipboard-read 'src'; payment 'src';");
    iframe.style.width = '100%';
    iframe.style.height = '100%';
    iframe.style.border = 'none';

    function teardown() {
      window.removeEventListener('message', onMessage);
      iframe.remove();
    }

    function onMessage(event) {
      if (event.origin !== sessionOrigin) return;

      switch (event.data?.type) {
        case 'load':
          iframe.contentWindow.postMessage({ options: {}, type: 'init' }, sessionOrigin);
          break;
        case 'ready':
          break;
        case 'complete':
          console.log('Complete', JSON.stringify(event.data.value));
          teardown();
          break;
        case 'cancel':
          console.log('Cancelled');
          teardown();
          break;
        case 'error':
          console.error('Error', event.data.error);
          teardown();
          break;
      }
    }

    window.addEventListener('message', onMessage);
    container.appendChild(iframe);
  }
</script>
```

> [!NOTE]
>
> Both examples above are for web applications — either creating the iframe yourself or letting the SDK do it. For native apps using a WebView, see [Native apps with the Web SDK](https://developer.uphold.com/widgets/payment/installation-and-setup.md#native-apps-with-the-web-sdk) for the SDK's native-bundling pattern, or [Setup without the SDK](https://developer.uphold.com/widgets/payment/installation-and-setup.md#setup-without-the-sdk) for the no-SDK approach that loads the session `url` directly as the WebView's top-level page. In an iOS WKWebView, PayPal also needs popup handling, see [Platform implementation](https://developer.uphold.com/widgets/payment/installation-and-setup.md#platform-implementation).

> [!NOTE]
>
> Apple Pay and Google Pay need the `payment` permission. The Web SDK's `mountIframe()` grants it. Without the SDK, keep `payment 'src'` in the iframe `allow` attribute, as in the example above.

### Handle the complete event

The `complete` event fires when the user closes the terminal status screen. Its value is the authorization result — the transaction plus what triggered the completion, as for card deposits.

> [!NOTE]
>
> The handlers below assume a session that only offers APMs or cards. If your session also offers bank or crypto, those deposits complete with `via: "deposit-method"` and no `trigger` — handle that case first. See [Bank deposit (End-to-end)](https://developer.uphold.com/developer-guides/bank-transfers/deposit/via-payment-widget/end-to-end.md#handle-the-complete-event) and [Crypto deposit (End-to-end)](https://developer.uphold.com/developer-guides/crypto-transfers/deposit/via-payment-widget/end-to-end.md#handle-the-complete-event).

```javascript Web SDK theme={null}
widget.on('complete', (event) => {
  const { transaction, trigger } = event.detail.value;

  if (trigger.reason === 'transaction-status-changed') {
    if (transaction.status === 'completed') {
      // Funds have settled
      handleDepositCompleted(transaction);
    } else if (transaction.status === 'failed') {
      handleDepositFailed(transaction);
    }
  } else if (trigger.reason === 'max-retries-reached') {
    // Polling timed out — the transaction may still be processing
    handleDepositPending(transaction);
  }

  widget.unmount();
});
```

```javascript Without SDK theme={null}
// Inside the onMessage switch from Set up the widget
case 'complete': {
  const { transaction, trigger } = event.data.value;

  if (trigger.reason === 'transaction-status-changed') {
    if (transaction.status === 'completed') {
      handleDepositCompleted(transaction);
    } else if (transaction.status === 'failed') {
      handleDepositFailed(transaction);
    }
  } else if (trigger.reason === 'max-retries-reached') {
    handleDepositPending(transaction);
  }

  teardown();
  break;
}
```

> [!WARNING]
>
> `complete` is only emitted once the user closes the status screen. A user who abandons the widget there leaves a real transaction behind that your app never hears about. Treat webhooks as the source of truth and `complete` as a UX signal.

### Handle cancellations

The `cancel` event fires when the user closes the widget before authorizing. No transaction exists at that point.

```javascript theme={null}
widget.on('cancel', () => {
  widget.unmount();
  // Return the user to the previous screen
});
```

### Handle errors

> [!WARNING]
>
> The Payment Widget handles most errors internally. For unrecoverable errors, the widget fires an `error` event. It is the host application's responsibility to handle these events, present an error message to the user, and unmount the widget.

The widget recovers from quote and authorization failures internally by returning the user to the review screen with an appropriate action — change the amount, change the payment method, or try again. This includes the APM authorization: when Apple Pay or Google Pay is not available on the device, the user is asked to change the payment method, and when the authorization fails, the user can try again or change the payment method. The `error` event is reserved for failures the widget cannot recover from.

***

## Monitor for settlement

APM deposit transactions remain in `processing` while the payment settles. Monitor until the transaction reaches a terminal state.

* **Webhook events** (recommended):
  * [core.transaction.created](https://developer.uphold.com/rest-apis/core-api/transactions/webhooks/transaction-created.md) — `status: processing` → transaction created, pending settlement
  * [core.transaction.status-changed](https://developer.uphold.com/rest-apis/core-api/transactions/webhooks/transaction-status-changed.md) — `status: completed` → funds settled; `status: failed` → irrecoverable error
* **Polling** (fallback): [Get transaction](https://developer.uphold.com/rest-apis/core-api/transactions/get-transaction.md)

## Sample transaction

> [tab] Apple Pay
>
> In a successful Apple Pay deposit, the origin is represented as an `apm` node with the method as `{apmMethod}`. The destination is the user's `account`.
>
> ```json [expandable] theme={null}
> {
>   "transaction": {
>     "id": "9b2f4a17-5e3c-4d77-a8e1-9bcdef2c0a42",
>     "origin": {
>       "asset": "USD",
>       "amount": "50.00",
>       "node": {
>         "type": "apm",
>         "method": "apple-pay"
>       }
>     },
>     "destination": {
>       "asset": "USD",
>       "amount": "50.00",
>       "node": {
>         "type": "account",
>         "id": "71e9fd4b-dfcd-4643-a5b0-51fd33e50a8d",
>         "ownerId": "48e40cb2-6c34-44ce-b2f1-6adac459bb37"
>       }
>     },
>     "status": "completed",
>     "quotedAt": "2025-06-18T00:55:39Z",
>     "createdAt": "2025-06-18T00:56:39Z",
>     "updatedAt": "2025-06-18T00:57:08Z",
>     "denomination": {
>       "asset": "USD",
>       "amount": "50.00",
>       "target": "origin"
>     },
>     "fees": []
>   }
> }
> ```

> [tab] Google Pay
>
> In a successful Google Pay deposit, the origin is represented as an `apm` node with the method as `{apmMethod}`. The destination is the user's `account`.
>
> ```json [expandable] theme={null}
> {
>   "transaction": {
>     "id": "9b2f4a17-5e3c-4d77-a8e1-9bcdef2c0a42",
>     "origin": {
>       "asset": "USD",
>       "amount": "50.00",
>       "node": {
>         "type": "apm",
>         "method": "google-pay"
>       }
>     },
>     "destination": {
>       "asset": "USD",
>       "amount": "50.00",
>       "node": {
>         "type": "account",
>         "id": "71e9fd4b-dfcd-4643-a5b0-51fd33e50a8d",
>         "ownerId": "48e40cb2-6c34-44ce-b2f1-6adac459bb37"
>       }
>     },
>     "status": "completed",
>     "quotedAt": "2025-06-18T00:55:39Z",
>     "createdAt": "2025-06-18T00:56:39Z",
>     "updatedAt": "2025-06-18T00:57:08Z",
>     "denomination": {
>       "asset": "USD",
>       "amount": "50.00",
>       "target": "origin"
>     },
>     "fees": []
>   }
> }
> ```

> [tab] PayPal
>
> In a successful PayPal deposit, the origin is the external account representing the user's PayPal account and the destination is the user's `account`.
>
> ```json [expandable] theme={null}
> {
>   "transaction": {
>     "id": "9b2f4a17-5e3c-4d77-a8e1-9bcdef2c0a42",
>     "origin": {
>       "asset": "USD",
>       "amount": "50.00",
>       "node": {
>         "type": "external-account",
>         "via": "apm",
>         "id": "90acb64a-510d-f9d1-b542-d44e6c53eb5d",
>         "ownerId": "48e40cb2-6c34-44ce-b2f1-6adac459bb37"
>       }
>     },
>     "destination": {
>       "asset": "USD",
>       "amount": "48.75",
>       "node": {
>         "type": "account",
>         "id": "71e9fd4b-dfcd-4643-a5b0-51fd33e50a8d",
>         "ownerId": "48e40cb2-6c34-44ce-b2f1-6adac459bb37"
>       }
>     },
>     "status": "completed",
>     "quotedAt": "2025-06-18T00:55:39Z",
>     "createdAt": "2025-06-18T00:56:39Z",
>     "updatedAt": "2025-06-18T00:57:08Z",
>     "denomination": {
>       "asset": "USD",
>       "amount": "50.00",
>       "target": "origin"
>     },
>     "fees": []
>   }
> }
> ```

> [tab] Venmo
>
> In a successful Venmo deposit, the origin is the external account representing the user's Venmo account and the destination is the user's `account`.
>
> ```json [expandable] theme={null}
> {
>   "transaction": {
>     "id": "9b2f4a17-5e3c-4d77-a8e1-9bcdef2c0a42",
>     "origin": {
>       "asset": "USD",
>       "amount": "50.00",
>       "node": {
>         "type": "external-account",
>         "via": "apm",
>         "id": "90acb64a-510d-f9d1-b542-d44e6c53eb5d",
>         "ownerId": "48e40cb2-6c34-44ce-b2f1-6adac459bb37"
>       }
>     },
>     "destination": {
>       "asset": "USD",
>       "amount": "48.75",
>       "node": {
>         "type": "account",
>         "id": "71e9fd4b-dfcd-4643-a5b0-51fd33e50a8d",
>         "ownerId": "48e40cb2-6c34-44ce-b2f1-6adac459bb37"
>       }
>     },
>     "status": "completed",
>     "quotedAt": "2025-06-18T00:55:39Z",
>     "createdAt": "2025-06-18T00:56:39Z",
>     "updatedAt": "2025-06-18T00:57:08Z",
>     "denomination": {
>       "asset": "USD",
>       "amount": "50.00",
>       "target": "origin"
>     },
>     "fees": []
>   }
> }
> ```

## Notify the user

Display an in-app confirmation when the transaction is `completed`, and send an email if applicable.

> [!TIP]
>
> You now support end-to-end APM deposits via the Payment Widget.
