Learn about PXP's PayPal payout components for iOS.
PayPal payouts enable you to easily send money to your users' PayPal accounts.
With the PayPal payout components, you can benefit from:
- Flexible payout execution: Choose between SDK-managed payouts for simplicity or backend-managed payouts for custom workflows.
- Secure credential management: PayPal account credentials are securely stored on your backend and provided to the SDK at initialization.
- Customizable approval flows: Implement custom merchant approval logic before payout execution.
- Native iOS integration: Built with SwiftUI for modern iOS app development with proper lifecycle management.
- Real-time status updates: Receive immediate confirmation when payouts complete successfully.
- Read-only display components: Show users their payout amount and destination email with optional masking for privacy.
PayPal payouts require a verified PayPal Business account. Recipients must have a PayPal account to receive funds, though PayPal will send an invitation if they don't have one.
The PayPal payout components enable various business scenarios where you need to send money to users:
- Gig economy and marketplaces: Pay freelancers, drivers, delivery personnel, or sellers for completed work or sales.
- Rewards and loyalty programmes: Distribute cashback, loyalty points converted to cash, or promotional rewards.
- Refunds: Return money to customers for returned items, cancelled services, or dispute resolutions.
- Affiliate commissions: Pay partners, influencers, or affiliates for referrals and sales.
- Contests and sweepstakes: Distribute prize money to winners of contests, tournaments, or raffles.
- Revenue sharing: Split payments among multiple parties in revenue-sharing arrangements.
- Expense reimbursements: Reimburse employees or contractors for business expenses.
PayPal payout credentials (email and payer ID) must be collected and stored by your backend system. The iOS SDK receives these credentials at initialization time and uses them to display payout information and execute transactions.
Your backend is responsible for:
- Collecting PayPal account information from users through your own UI or processes
- Securely storing the email address and payer ID
- Providing these credentials to the iOS app when initializing the SDK
The payer ID is a unique identifier for a PayPal account. You can obtain this through your backend integration with PayPal's APIs or by having users provide their PayPal account details through your own account management system.
The PayPal payout components support two execution modes, allowing you to choose the approach that fits your business requirements:
- SDK-managed payouts: A streamlined flow where the SDK handles payout execution after merchant approval. Best for simple implementations with minimal backend logic.
- Backend-managed payouts: A flexible flow where your backend controls payout execution. Use this when you need custom business logic, compliance checks, or complex workflows.
- Your backend provides PayPal credentials (email and payer ID) to the iOS app.
- The user initiates a payout request in your app.
- SDK triggers
onPrePayoutSubmitcallback for merchant approval. - Merchant shows approval dialog and returns approval status.
- SDK executes payout transaction via Unity API.
- SDK triggers
onPostPayoutcallback with transaction details. - The funds are transferred to the user's PayPal account.
Configuration:
let paypalConfig = PayPalConfig(
payout: PayPalPayoutConfig(
paypalWallet: PayPalWallet(
email: "user@example.com", // From your backend
payerId: "PAYERID123ABC", // From your backend
proceedPayoutWithSdk: true // SDK manages payout
)
)
)With backend-managed payouts, the onPrePayoutSubmit and onPostPayout callbacks are not triggered since the SDK doesn't execute the payout. Your backend handles the entire payout execution flow.
When you initiate a payout transaction, you must provide key information in the transactionData object:
- The amount and currency of the payout.
- The entry type (
EntryType), which describes the origin of the transaction. For payouts, use.ecomfor e-commerce transactions. - The intent (
PayPalIntentType), which must be.payoutfor payout transactions. This indicates that money flows from you to the user. - A merchant transaction identifier of your choosing, which uniquely identifies this specific payout.
- The merchant transaction date.
let transactionData = TransactionData(
amount: Decimal(100.00),
currency: "USD",
entryType: .ecom,
intent: TransactionIntentData(
card: nil,
paypal: .payout // Critical: Must use .payout intent
),
merchantTransactionId: "payout-\(UUID().uuidString)",
merchantTransactionDate: { Date() }
)PayPal payouts support only one intent: PayPalIntentType.payout. It transfers funds from your PayPal Business account to the recipient's PayPal account.
Using the wrong intent (.authorisation or .purchase) will cause payout transactions to fail. These intents are for receiving payments, not sending payouts.
PayPal payouts for iOS provides display and submission components for users with stored PayPal credentials:
| Component | Type | Description |
|---|---|---|
PayoutAmountComponent | .payoutAmount | Displays the payout amount (read-only). |
PayPalPayoutReceiverComponent | .paypalPayoutReceiver | Displays the recipient email with optional masking. Configure with PayPalPayoutReceiverComponentConfig: applyMask (default: true) to mask email as j***@****.com, showMaskToggle (default: true) to show/hide toggle button, and receiverType (must be .email). |
PayoutSubmissionComponent | .payoutSubmission | Submit button to execute the payout. |
For detailed configuration of payout components, see the Withdrawal flow guide.
Here's a complete example showing how to implement PayPal payouts with stored credentials:
// Configure with stored credentials from your backend
let paypalConfig = PayPalConfig(
payout: PayPalPayoutConfig(
paypalWallet: PayPalWallet(
email: "user@example.com", // From your backend
payerId: "PAYERID123ABC", // From your backend
proceedPayoutWithSdk: true
)
)
)
let pxpCheckout = try PxpCheckout.initialize(config: checkoutConfig)
// Create amount display component
let amountConfig = PayoutAmountComponentConfig(
label: "Payout Amount"
)
let amountComponent = try pxpCheckout.create(.payoutAmount, componentConfig: amountConfig)
// Create receiver display component
let receiverConfig = PayPalPayoutReceiverComponentConfig(
label: "PayPal Account",
applyMask: true,
showMaskToggle: true
)
let receiverComponent = try pxpCheckout.create(.paypalPayoutReceiver, componentConfig: receiverConfig)
// Create submission component
let submissionConfig = PayoutSubmissionComponentConfig(
submitText: "Withdraw to PayPal",
onClick: {
print("Withdraw button clicked")
},
onPrePayoutSubmit: {
let approved = await showApprovalDialog()
guard approved else { return nil }
return PrePayoutSubmitResult(isApproved: true)
},
onPostPayout: { result in
print("Payout completed: \(result.merchantTransactionId)")
},
onError: { error in
print("Error: \(error.errorMessage)")
}
)
let submissionComponent = try pxpCheckout.create(.payoutSubmission, componentConfig: submissionConfig)
// Render in SwiftUI
VStack(spacing: 16) {
amountComponent.buildContent()
receiverComponent.buildContent()
submissionComponent.buildContent()
}PayPal has the following limits on payout transactions:
| Limit type | Value |
|---|---|
| Minimum amount | $1.00 USD (varies by currency). |
| Maximum single payout | $60,000 USD (varies by account status). |
| Daily limit | Varies based on account verification level. |
| Payer ID length | Maximum 13 characters. |
| Receiver email length | Maximum 127 characters. |
Contact your PayPal account manager to increase limits for high-volume payout operations.
- Standard payouts: Typically within minutes.
- International payouts: May take 1-3 business days.
- New recipients: First payout may take longer due to fraud checks.
PayPal charges fees for payouts. Check your PayPal Business account for current rates:
- Domestic payouts: ~2% (varies by country).
- International payouts: Higher fees apply.
- Volume discounts may be available.
- Backend storage only: PayPal email addresses and payer IDs must be securely stored on your backend.
- Use HTTPS: All backend API calls must use HTTPS with valid SSL certificates.
- Secure transmission: When providing credentials to the iOS app, use secure API calls over HTTPS.
- Validate credentials: Verify email and payer ID formats before storing and transmitting.
- Validate payer ID: Always validate the payer ID format (max 13 characters, alphanumeric).
- Verify amounts: Ensure payout amounts are positive, valid numbers before processing.
- Implement rate limiting: Protect against abuse by limiting payout frequency per user.
- Audit logging: Log all payout attempts, successes, and failures for compliance and debugging.
The SDK performs extensive validation and provides specific error codes to help you handle different failure scenarios. All validation exceptions extend BaseSdkException and can be caught in onError callbacks.
| Error | Description |
|---|---|
PayoutAmountInvalidException | Amount is NaN (Not a Number) or infinite. |
PayoutAmountNotPositiveException | Amount is zero or negative. Payouts must be positive values. |
| Error | Description |
|---|---|
PayoutCurrencyRequiredException | Currency code is empty or missing. |
PayoutCurrencyLengthInvalidException | Currency code is not exactly 3 characters (ISO 4217 format). |
PayoutCurrencyCodeInvalidException | Currency code is not a valid ISO 4217 code. |
| Error | Description |
|---|---|
PaypalPayoutReceiverRequiredException | Receiver email is empty or missing. |
PaypalPayoutEmailInvalidException | Email address format is invalid. |
PayoutEmailMaxLengthException | Email address exceeds 127 characters. |
PaypalPayoutReceiverTypeEmailOnlyException | Receiver type is not .email (only email is currently supported). |
| Error | Description |
|---|---|
PayoutPayerIdMaxLengthException | Payer ID exceeds 13 characters. |
PayoutPayerIdInvalidException | Payer ID contains non-alphanumeric characters. Only letters and numbers are allowed. |
let config = PayoutSubmissionComponentConfig(
submitText: "Withdraw to PayPal",
onError: { error in
// Handle specific error types
switch error {
case is PayoutAmountNotPositiveException:
showError("Payout amount must be greater than zero")
case is PayoutEmailMaxLengthException:
showError("Email address is too long (max 127 characters)")
case is PayoutPayerIdMaxLengthException:
showError("Payer ID is too long (max 13 characters)")
case is PaypalPayoutEmailInvalidException:
showError("Please enter a valid email address")
default:
showError("An error occurred: \(error.localizedDescription)")
}
}
)Ready to implement PayPal Payouts? Follow these guides in order:
- PayPal onboarding: Configure your PayPal Developer account.
- Withdrawal flow: Implement payout components with stored credentials.
- Testing: Test your payout integration in sandbox mode.