Skip to content

Testing

Test your payout integration end-to-end before going live.

Before you start

Make sure you have completed these setup steps:

Step 1: Configure sandbox environment

Use the TEST environment and sandbox credentials for both SDK and backend. For example:

import com.pxp.PxpCheckout
import com.pxp.checkout.models.*
import java.util.UUID

val pxpCheckout = PxpCheckout.builder()
    .withConfig(
        PxpSdkConfig(
            environment = Environment.TEST,  // Use test environment
            session = sessionData,
            ownerId = "Unity",
            ownerType = "MerchantGroup",
            clientId = "your-client-id",
            transactionData = TransactionData(
                amount = 100.0,
                currency = "USD",
                merchant = "your-merchant-id",
                entryType = EntryType.Ecom,
                intent = TransactionIntentData(paypal = PayPalIntentType.Payout),
                merchantTransactionId = UUID.randomUUID().toString(),
                merchantTransactionDate = { java.time.Instant.now().toString() }
            ),
            paypalConfig = PaypalConfig(
                payout = PayoutConfig(
                    proceedPayoutWithSdk = true
                    // Add paypalWallet for withdrawal flow tests
                )
            )
        )
    )
    .withContext(context)
    .build()

Step 2: Test core happy paths

Focus first on the main customer journeys.

Withdrawal flow (returning customers)

Confirm the returning-customer path end-to-end:

  • Initialise the SDK with a stored PayPal wallet (paypalWallet.email and payerId).
  • Render PayoutAmountComponent, PaypalPayoutReceiverComponent, and PayoutSubmissionComponent.
  • Verify:
    • Amount and receiver are correctly displayed (including masking behaviour).
    • Tapping Withdraw with PayPal triggers onPrePayoutSubmit.
    • Successful approval results in onPostPayout being called and the sandbox recipient balance increasing.

SDK-initiated and merchant-initiated

Confirm both payout modes behave as expected:

  • With proceedPayoutWithSdk = true, confirm the SDK executes the payout after onPrePayoutSubmit approves and calls onPostPayout with a transaction ID.
  • With proceedPayoutWithSdk = false, confirm:
    • The SDK calls onClick when the customer taps the button, then returns without running onPrePayoutSubmit, executing the payout, or calling onPostPayout.
    • Your app or backend uses that signal to call the payout API.

Minimal test checklist

Use this as a lightweight "must-have" list before going live:

AreaScenarioWhat to verify
Withdrawal flowReturning customer payoutStored PayPal wallet is shown (including masking), onPrePayoutSubmit and onPostPayout fire for SDK-initiated mode, and the sandbox recipient balance increases.
Validation and errorsInvalid amount or emailonError receives the right error code, and the UI shows clear, user-friendly messages.
IntegrationSDK-initiated and merchant-initiated payoutsWith proceedPayoutWithSdk = true, the SDK runs the payout after approval. With false, only onClick runs and your backend executes the payout.

Step 3: Test validation and error handling

Use targeted negative tests rather than exhaustively covering every error code.

  • Amounts: For a negative or zero amount, expect an amount validation error (see Data validation).
  • PayPal receiver: For an invalid email format or missing payer ID, expect PayPal receiver errors (PO04).
  • Configuration: For missing recipientWallet or wallet details, expect payout configuration errors.

In each case, verify that:

  • onError is called with the appropriate error code and message.
  • Your UI maps technical errors to clear, user-friendly messages.

Use an onError handler like this to map codes to shopper-facing copy:

val submitConfig = PayoutSubmissionComponentConfig(
    recipientWallet = "Paypal",
    onError = { error ->
        Log.e("Payout", "Error: ${error.errorCode} - ${error.errorReason}")
        
        // Map to user-friendly messages
        val message = when (error.errorCode) {
            "PO02" -> "Amount must be greater than zero"
            "PO03" -> "Invalid currency code"
            "PO04" -> "Invalid PayPal account details"
            "PO07" -> "Invalid transaction date"
            else -> "An error occurred. Please try again."
        }
        
        showError(message)
    }
)

Step 4: Test UI and events

Verify that core components render and behave as expected:

  • PayoutAmountComponent: correct amount, currency, and custom label or styling.
  • PaypalPayoutReceiverComponent: masking toggle, labels, and styles.
  • PayoutSubmissionComponent:
    • Button states (default, loading, disabled).
    • Event callbacks: onClick, onPrePayoutSubmit, onPostPayout, onError.

Test on multiple devices

Run the same checks across a representative device matrix:

  • Phone (5-6 inch screen)
  • Phone (6-7 inch screen)
  • Tablet (10+ inch screen)
  • Different Android versions (min SDK to latest)
  • Different screen orientations (portrait and landscape)

For detailed callback payloads, see Events.

Step 5: Moving to production

Once your sandbox tests pass, complete these live cutover steps:

  1. Switch environments. Set environment to Environment.LIVE:

    val pxpCheckout = PxpCheckout.builder()
        .withConfig(
            PxpSdkConfig(
                environment = Environment.LIVE,  // Production environment
                // ... rest of config
            )
        )
        .build()
  2. Update backend credentials to use live PayPal and Unity endpoints and secrets.

  3. Run a small live test (e.g., a $1 payout to your own PayPal account) and confirm funds, reporting, and reconciliation.

  4. Enable monitoring (error tracking, alerts on payout failures, webhook monitoring) and roll out gradually if needed.

If you encounter issues during testing, see Troubleshooting and Data validation for common problems and error codes.