Authorization always runs through the Payment Widget — for both new and already-authorized accounts. The widget collects Braintree device data and submits it with the transaction, which PayPal uses for fraud and risk analysis.
Prerequisites
- The user has completed onboarding, has the
paypal-withdrawalscapability enabled, and has a verified phone number. - A funded account to debit the funds from.
- Your app has integrated the Payment Widget SDK.
- Your API client has the required scopes:
core.transactions:create— to create quotes and transactionswidgets.payment.sessions:create— to create widget sessions
Walkthrough
The diagram shows a first-time authorization. For an already-authorized account, skip the sign-in — the widget only collects device data and reuses the stored authorization.Check available rails
Call List rails to verify PayPal withdrawal is available.Check capabilities
Call List capabilities to confirm the user has thepaypal-withdrawals capability enabled with no unmet requirements.
Select source account
withdrawals can be sourced from any account. If the selected account is not in the account’s currency, the balance will be converted at the time of the transaction using Uphold’s prevailing rate. Make sure the origin asset has the necessary features enabled. Call List accounts to retrieve the user’s accounts and let them pick the one to withdraw from.Create a quote
Call Create quote with the user’s account as the origin and PayPal as the destination. There are two ways to specify the PayPal destination:-
apmshortcut — usetype: "apm"withmethod: "paypal". This is always accepted, whether or not the user already has a linked PayPal account. -
external-accountreference — if the user already has a linked PayPal account, you can reference it directly withtype: "external-account"and itsid(from List external accounts):
apm shortcut.
requirements array. If it contains authorize:paypal, the user must authorize PayPal before the transaction can be created.
Authorize and create the transaction
After the user confirms the PayPal deposit quote, hand off to the Payment Widget Authorize flow. It creates the transaction, runs the PayPal authorization, and polls until a terminal status is reached — so the same flow works for both new and already-authorized accounts.Create an authorize session
Call Create widget session withflow: "authorize", the quoteId and with the requirements array containing authorize:paypal.
Set up the widget
Initialize the widget with the session. The widget interacts with PayPal, creates the transaction, and polls until a terminal status is reached. For a new account the user signs in to PayPal to authorize; for an already-authorized account they do not sign in again — the widget only collects device data and reuses the stored authorization.For native apps using a WebView, you’ll need a bridge for events as outlined in Installation & setup.
Handle the complete event
transaction.statusDetails.reason:
| Reason | Description |
|---|---|
apm-authorization-failed | The PayPal authorization could not be completed |
apm-payment-method-declined | PayPal declined the payment method |
apm-account-holder-data-mismatch | The account holder details did not match |
apm-missing-account-holder-data | Required account holder details were missing |
insufficient-funds | The origin account has insufficient funds |
provider-maximum-limit-exceeded | The transaction exceeds provider limits |
velocity | The transaction was blocked by velocity rules |
unspecified-error | The transaction failed for an unspecified reason |
Handle cancellations
Thecancel event fires when the user navigates back without completing authorization.
Handle errors
Theerror event fires for critical unrecoverable errors.
event.detail.error.code:
| Code | Description |
|---|---|
entity_not_found | The quote was not found or has expired |
insufficient_balance | The origin has insufficient balance |
operation_not_allowed | The operation is not permitted |
user_capability_failure | The user lacks the required capability for this operation |
Monitor for settlement
transactions remain inprocessing while the payment settles. Monitor until the transaction reaches a terminal state.
- Webhook events (recommended):
- core.transaction.created —
status: processing→ transaction created, pending settlement - core.transaction.status-changed —
status: completed→ funds settled;status: failed→ irrecoverable error
- core.transaction.created —
- Polling (fallback): Get transaction
Sample transaction
In a successful PayPal withdrawal, the origin is the user’saccount and the destination is the external account representing the user’s PayPal account.
Notify the user
After the transaction completes, display the transaction details to the user so they can confirm the withdrawal succeeded. It must include the PayPal logo and the PayPal account email used. Here’s an example:
You now support PayPal withdrawals via the REST API together with the Payment Widget.