Test your Drop-in integration in sandbox before going live.
Test your Drop-in integration in the sandbox environment before accepting real payments. The sandbox environment allows you to test all payment methods without processing actual transactions.
Set the environment to Environment.TEST when initialising Drop-in:
import com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig
import com.pxp.checkout.models.Environment
CheckoutDropInConfig(
environment = Environment.TEST, // Use sandbox
// ... rest of config
)Key points about sandbox testing:
- No real money is charged.
- Use test card numbers and sandbox accounts.
- All payment methods work the same as production.
- Backend verification still required using test API credentials.
Use these test cards in sandbox to simulate different scenarios. These PANs are for manual card form entry in Drop-in. They aren't Google Pay or Google Wallet test cards; see Test Google Pay for wallet testing.
The following test cards represent successful payment scenarios:
| Card number | Network | 3DS behaviour |
|---|---|---|
4111 1111 1111 1111 | Visa | No challenge |
5555 5555 5555 4444 | Mastercard | No challenge |
3782 822463 10005 | American Express | No challenge |
4000 0000 0000 0002 | Visa | Challenge required |
For all test cards:
- Expiry date: Any future date (e.g.,
12/30). - CVV: Any 3 digits (e.g.,
123). - Cardholder name: Any name.
The following test cards simulate payment failures:
| Card number | Network | Result |
|---|---|---|
4000 0000 0000 0077 | Visa | Insufficient funds |
4000 0000 0000 0051 | Visa | Card declined |
4000 0000 0000 0069 | Visa | Expired card |
4000 0000 0000 0101 | Visa | CVV failure |
When using the challenge test card (4000 0000 0000 0002), a 3D Secure authentication screen appears in the native Android UI:
- To pass: enter any code (e.g.,
1234). - To fail: leave empty or enter wrong code multiple times.
- To timeout: wait for authentication to timeout.
Verify that your onSuccess callback fires after successful authentication, and that your backend receives the transaction details.
Use DropInCardConfig to control which card sections appear. Confirm each scenario with cards enabled in the session:
| Configuration | Expected result |
|---|---|
showCOF and showNewCard omitted or true | Both card-on-file and new card entry appear when prerequisites are met. Saved cards appear only when tokens are available. |
showCOF = true, showNewCard = false, with a non-empty shopper id from onGetShopper | Only saved cards and the card-on-file submit button appear when tokens are available. |
showCOF = false, showNewCard = true | Only the new card form appears. Saved cards aren't shown. |
showCOF = false, showNewCard = false | The Card payment method panel is hidden. With no wallets available, Drop-in may show no payment methods. Verify that onError receives error.errorCode == "SDK1119" (SdkErrorCodes.NO_PAYMENT_METHODS_AVAILABLE) when all methods are hidden and the session exposes no wallets. |
Card-on-file also requires onGetShopper to return a shopper with a non-empty id. For configuration details, see Cards.
Store-card consent is controlled by site storeCardConsent in the Unity Portal (returned on the checkout Drop-in configurations API). Confirm each mode with showNewCard enabled and a non-empty shopper id from onGetShopper:
Site storeCardConsent | Expected result |
|---|---|
Ask | Consent checkbox appears when a shopper id is present. The card is stored only if the checkbox is checked, or if there is no checkbox and onGetConsent returns true for cards. |
DontAsk | No consent checkbox. Paying with a new card doesn't store the card through the Drop-in consent flow. |
ConsentAlreadyObtained | No consent checkbox. Paying with a new card stores the card when a shopper id is present. With showCOF enabled, the card-on-file list refreshes after a successful stored new-card payment. onGetConsent isn't required for card storage. |
For mode details, see Cards — Store-card consent.
You need a PayPal sandbox account for testing. Create one in the PayPal Developer Dashboard.
Create a personal (buyer) account for testing customer payments.
Complete a sandbox PayPal payment:
- Tap the PayPal button in the drop-in.
- Log in with your PayPal sandbox account in the web view.
- Approve the payment.
- Verify that
onSuccessfires with transaction details. - Verify your backend receives the payment notification.
Test both transaction intents:
- Purchase intent: Funds captured immediately.
- Authorisation intent: Funds authorised but not captured (capture later via backend API).
Set the intent on DropInTransactionIntentData.paypalDropInIntent (not the card intent):
transactionData = DropInTransactionData(
// ...
intent = DropInTransactionIntentData(
paypalDropInIntent = DropInPayPalIntentType.Purchase, // or .Authorisation
),
)Google Pay testing needs:
- Android 7.0 (API level 24) or higher
- Google Play Services installed
- Google Account signed in
- A way to present cards in the Google Pay sheet (see below)
Manual card-entry PANs from Test card numbers are for typing into Drop-in's card form. Google Pay uses cards from Google Wallet or the Google Pay test card suite, not those form PANs.
To test a Google Pay payment:
- Open your app on an Android device or emulator with
Environment.TEST. - Sign in to your Google Account.
- Set up Google Pay test cards using Google's documentation. For example, the Google Pay test card suite.
- Tap the Google Pay button in Drop-in.
- Select your test card in the payment sheet.
- Tap Pay.
- Verify that
onSuccessfires with transaction details.
The Google Pay button only appears when Google Play Services is available and the Google Pay sheet can present a payment method for the buyer.
To test Google Pay on an Android emulator:
- Use an emulator with Google Play (API level 24+).
- Sign in with a Google Account enrolled for Google Pay testing (see the test card suite docs above).
- Confirm test cards appear in the Google Pay sheet when your app uses the TEST environment.
- Run your app and test Google Pay integration.
Aeropay only appears when the session includes allowedFundingTypes.payByBanks.aeropay, the currency is USD, and entryType is EntryType.Ecom.
Run through this Aeropay path in sandbox:
- Confirm Aeropay is enabled in the Unity Portal and present in your session response under
payByBanks.aeropay. - Use
Environment.TEST, settransactionData.currencyto"USD", andentryTypetoEntryType.Ecom. - Set
transactionData.intent.aeropayDropInIntentto a supported intent (Authorisation,Purchase, orEstimatedAuthorisation). - Initialise Drop-in, call
create(), and composeContent()so the panel can render. Eligibility errors such asSDK0114,SDK0116,SDK1300, andSDK1125surface duringcreate(), notinitialize(). - Provide valid
onGetShopperconsumer fields when you supply values, or setmethodConfig.aeropay.userId. - Select Pay by bank via Aeropay in Drop-in.
- Complete the flow and verify
onSuccessas follows:
onSuccess = { result ->
assert(result.paymentMethod == PaymentMethod.AEROPAY)
assert(result.paymentData == null) // Aeropay Drop-in does not populate paymentData
// Verify on the backend with result.systemTransactionId and result.merchantTransactionId
}To test failure or cancellation, trigger onError or close the popup and verify methodConfig.global.onCancel.
Use approved UAT shopper data and Aeropay test credentials from your PXP or Aeropay integration contact. Don't invent sandbox bank login or OTP steps beyond what your test environment provides.
Test that your error handling works correctly by simulating failures:
Use the failed payment test cards to trigger different error types:
- Insufficient funds:
4000 0000 0000 0077 - Card declined:
4000 0000 0000 0051 - Expired card:
4000 0000 0000 0069 - CVV failure:
4000 0000 0000 0101
Verify that your onError callback receives the error and displays an appropriate message to the customer.
Test that your error handling works correctly for network failures:
Reproduce a network failure on device:
- Enable airplane mode on your device.
- Try to submit a payment.
- Verify that your
onErrorcallback receives the error. - Verify your error handling shows an appropriate network error message.
Verify that your error callback handles network failures correctly. On Android, Drop-in network failures may use either:
SDK0500viaNetworkSdkException(common on card submit, Aeropay create-user, and airplane-mode tests)SDK0550viaSdkErrorCodes.NETWORK_ERROR(used in someSdkErrormappings)
SDK0500 can also mean invalid transaction amount in other contexts. Check error.message when you need to disambiguate.
val isNetworkError =
error.errorCode == SdkErrorCodes.NETWORK_ERROR || // SDK0550
(error.errorCode == "SDK0500" && error.message?.contains("network", ignoreCase = true) == true)Callback-only unit tests can invoke onError with either code. The sample below uses SDK0550:
import com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig
import com.pxp.checkout.checkoutdropin.types.PaymentMethod
import com.pxp.checkout.exceptions.BaseSdkException
import com.pxp.checkout.exceptions.SdkErrorCodes
import com.pxp.checkout.models.Environment
import com.pxp.checkout.models.EntryType
import com.pxp.checkout.models.SessionConfig
import com.pxp.checkout.models.DropInTransactionData
import com.pxp.checkout.models.DropInTransactionIntentData
import com.pxp.checkout.models.CardIntentType
import org.junit.Assert.*
import org.junit.Test
fun mockSessionConfig(): SessionConfig = SessionConfig(
sessionId = "test-session-id",
hmacKey = "test-hmac-key",
data = "test-session-data",
encryptionKey = "test-encryption-key",
locale = "en-US"
)
fun mockTransactionData(): DropInTransactionData = DropInTransactionData(
currency = "GBP",
amount = 99.99,
entryType = EntryType.Ecom,
intent = DropInTransactionIntentData(card = CardIntentType.Authorisation),
merchant = "Demo Store",
merchantTransactionId = "test-txn-123",
merchantTransactionDate = { "2026-05-18T12:00:00Z" },
)
class NetworkErrorTest {
@Test
fun testNetworkErrorHandling() {
var errorReceived: BaseSdkException? = null
var paymentMethodReceived: PaymentMethod? = PaymentMethod.CARD // sentinel
val config = CheckoutDropInConfig(
environment = Environment.TEST,
session = mockSessionConfig(),
ownerType = "MerchantGroup",
ownerId = "MERCHANT-1",
transactionData = mockTransactionData(),
onError = { paymentMethod, error ->
paymentMethodReceived = paymentMethod
errorReceived = error
}
)
// Simulate network error (SDK error code SDK0550)
val networkError = BaseSdkException(
message = SdkErrorCodes.getMessage(SdkErrorCodes.NETWORK_ERROR),
errorCode = SdkErrorCodes.NETWORK_ERROR,
)
config.onError?.invoke(null, networkError)
// Verify error was received and has correct code
assertNull(paymentMethodReceived) // null for init or cross-method errors
assertNotNull(errorReceived)
assertEquals(SdkErrorCodes.NETWORK_ERROR, errorReceived?.errorCode)
assertTrue(errorReceived?.message?.contains("network", ignoreCase = true) == true)
}
}Test cancellation handling:
- Card (3DS): Close the 3D Secure authentication window without completing authentication. Verify that
onErrorfires with an authentication-relatedBaseSdkException(e.g.,SDK1113). Card or 3DS abandonment doesn't callonCancel. - PayPal: Close the web view without completing payment. Verify
onCancel(if configured inmethodConfig.global). - Google Pay: tap outside the payment sheet or press Back. Verify
onCancel(if configured). - Aeropay: Close the Aeropay popup without completing payment. Verify
onCancelwithPaymentMethod.AEROPAY(if configured).
DropInGlobalConfig.onCancel is (PaymentMethod, Any?) -> Unit and is wired to PayPal, Google Pay, and Aeropay. The second argument is typically null for popup close:
import com.pxp.checkout.checkoutdropin.types.DropInMethodConfig
import com.pxp.checkout.checkoutdropin.types.PaymentMethod
import com.pxp.checkout.checkoutdropin.types.methodconfigs.DropInGlobalConfig
methodConfig = DropInMethodConfig(
global = DropInGlobalConfig(
onCancel = { paymentMethod, _ ->
when (paymentMethod) {
PaymentMethod.AEROPAY -> { /* shopper closed Aeropay popup */ }
PaymentMethod.PAYPAL -> { /* PayPal web view closed */ }
PaymentMethod.GOOGLE_PAY -> { /* sheet dismissed */ }
else -> Unit
}
},
),
)Always verify payments on your backend before fulfilling orders. The frontend callbacks can be manipulated by users.
Test these critical security checks:
- Transaction exists: Query the PXP API with
systemTransactionIdto verify the transaction exists. - Amount matches: Verify the transaction amount matches your expected amount.
- Transaction succeeded: Check that the transaction state is
AuthorisedorCaptured. - Prevent replay attacks: Ensure the same transaction can't be processed twice.
Example verification:
// Backend verification endpoint (Node.js/Express example)
app.post('/api/verify-payment', async (req, res) => {
const { systemTransactionId, merchantTransactionId } = req.body;
// Get expected amount from your database
const order = await db.orders.findOne({ merchantTransactionId });
const expectedAmount = order.amount;
// Query PXP API to verify transaction
const transaction = await unityApi.getTransaction(systemTransactionId);
// Verify transaction is successful
if (transaction.state !== 'Authorised' && transaction.state !== 'Captured') {
return res.json({ success: false, error: 'Transaction not authorised' });
}
// Verify amount matches
const txnAmount = transaction.amounts?.transactionValue || transaction.amount;
if (Math.abs(txnAmount - expectedAmount) > 0.01) {
return res.json({ success: false, error: 'Amount mismatch' });
}
// Check for duplicate processing
const alreadyProcessed = await db.transactions.findOne({ systemTransactionId });
if (alreadyProcessed) {
return res.json({ success: true, orderId: alreadyProcessed.orderId });
}
// Process order
const orderId = await fulfillOrder(order);
await db.transactions.create({ systemTransactionId, orderId });
res.json({ success: true, orderId });
});Test on real Android devices to ensure the best user experience.
Test on devices that represent your user base:
- Budget device: Samsung Galaxy A series, Motorola Moto G
- Mid-range device: Google Pixel 6a, Samsung Galaxy S22
- Premium device: Google Pixel 8, Samsung Galaxy S24
- Tablet: Samsung Galaxy Tab S9
Test the following on each device:
- Card field rendering and keyboard input
- 3D Secure authentication UI
- Google Pay integration (if available)
- PayPal web view interaction
- Screen rotation handling
- Different screen sizes and densities
- Performance and responsiveness
Test your UI layout on different screen sizes using Compose previews:
// Preview different screen sizes for layout inspection
@Preview(name = "Phone", device = Devices.PHONE)
@Preview(name = "Foldable", device = Devices.FOLDABLE)
@Preview(name = "Tablet", device = Devices.TABLET)
@Composable
fun CheckoutScreenPreview() {
CheckoutScreen()
}Compose @Preview is useful for visual layout inspection during development, but it does not test runtime payment behaviour. Always run actual functional tests on emulators or physical devices to validate payment flows.
Write automated tests for your Drop-in integration:
Test your configuration and callback logic. Callback-only unit tests that invoke config.onSuccess or config.onError directly don't need a live network. Use a SessionConfig mock with the required fields: sessionId, hmacKey, data, encryptionKey, and locale.
import com.pxp.checkout.checkoutdropin.types.CheckoutDropInConfig
import com.pxp.checkout.checkoutdropin.types.DropInSubmitResult
import com.pxp.checkout.checkoutdropin.types.PaymentMethod
import com.pxp.checkout.exceptions.BaseSdkException
import com.pxp.checkout.exceptions.SdkErrorCodes
import com.pxp.checkout.models.CardIntentType
import com.pxp.checkout.models.DropInTransactionData
import com.pxp.checkout.models.DropInTransactionIntentData
import com.pxp.checkout.models.Environment
import com.pxp.checkout.models.EntryType
import com.pxp.checkout.models.SessionConfig
import org.junit.Test
import org.junit.Assert.*
fun mockSessionConfig(): SessionConfig = SessionConfig(
sessionId = "test-session-id",
hmacKey = "test-hmac-key",
data = "test-session-data",
encryptionKey = "test-encryption-key",
locale = "en-US"
)
class CheckoutConfigTest {
@Test
fun testConfigCreation() {
val config = CheckoutDropInConfig(
environment = Environment.TEST,
session = mockSessionConfig(),
ownerType = "MerchantGroup",
ownerId = "MERCHANT-1",
transactionData = DropInTransactionData(
currency = "GBP",
amount = 99.99,
entryType = EntryType.Ecom,
intent = DropInTransactionIntentData(
card = CardIntentType.Authorisation
),
merchant = "Demo Store",
merchantTransactionId = "test-txn-123",
merchantTransactionDate = { "2026-05-18T12:00:00Z" }
)
)
assertEquals(Environment.TEST, config.environment)
assertEquals("MERCHANT-1", config.ownerId)
assertEquals("GBP", config.transactionData.currency)
}
@Test
fun testCallbackExecution() {
var successCalled = false
var errorCalled = false
val config = CheckoutDropInConfig(
environment = Environment.TEST,
session = mockSessionConfig(),
ownerType = "MerchantGroup",
ownerId = "MERCHANT-1",
transactionData = DropInTransactionData(
currency = "GBP",
amount = 99.99,
entryType = EntryType.Ecom,
intent = DropInTransactionIntentData(
card = CardIntentType.Authorisation
),
merchant = "Demo Store",
merchantTransactionId = "test-txn-123",
merchantTransactionDate = { "2026-05-18T12:00:00Z" }
),
onSuccess = { result ->
successCalled = true
},
onError = { paymentMethod, error ->
errorCalled = true
}
)
// Test callbacks
config.onSuccess?.invoke(mockSuccessResult())
assertTrue(successCalled)
assertFalse(errorCalled)
config.onError?.invoke(null, mockNetworkError())
assertTrue(errorCalled)
}
}
fun mockNetworkError(): BaseSdkException = BaseSdkException(
message = SdkErrorCodes.getMessage(SdkErrorCodes.NETWORK_ERROR),
errorCode = SdkErrorCodes.NETWORK_ERROR,
)
fun mockSuccessResult(): DropInSubmitResult = DropInSubmitResult(
systemTransactionId = "sys-txn-123",
merchantTransactionId = "test-txn-123",
paymentMethod = PaymentMethod.CARD,
)Full Compose UI flow tests require more than placeholder session fields. Drop-in create() fetches Unity site configuration and wires components. Use either:
- A mocked Unity or backend test harness, or
- A valid sandbox session from your test API
Callback-only unit tests (above) are fine without network but full Compose flow tests aren't.
SDK default field labels are typically "Card Number", "Expiry Date", and "CVC" (CardCvcComponentConfig.label). Resource-backed localisation may show "Security Code" instead (DefaultStrings / R.string.cvc_label) — use substring = true, semantics matchers, or testTag when labels are customised. The submit button text is a formatted string resource (for example Pay %1$.2f %2$s), so match with substring = true. Labels are also localisable via CheckoutDropInConfig.localisation.
Assert only payment methods enabled in your test session. PayPal appears only when the session exposes allowedFundingTypes.wallets.paypal, entryType is Ecom, and PayPal components initialise successfully. A card-only sandbox session won't show PayPal. For PayPal coverage, use a session fixture with PayPal funding enabled. See Implementation.
Use Compose UI tests with matchers like this:
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createComposeRule
import org.junit.Rule
import org.junit.Test
class CheckoutFlowTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun testCardPaymentFlow() {
composeTestRule.setContent {
CheckoutScreen() // Must be backed by a mocked harness or valid sandbox session
}
// Wait for Drop-in to render
composeTestRule.waitForIdle()
// Assert only methods enabled in your test session
composeTestRule.onNodeWithText("Card").assertIsDisplayed()
// composeTestRule.onNodeWithText("PayPal").assertIsDisplayed() // only if PayPal is in the session
// Select card payment
composeTestRule.onNodeWithText("Card").performClick()
// Verify card form is displayed (default English labels)
composeTestRule.onNodeWithText("Card Number", substring = true).assertIsDisplayed()
composeTestRule.onNodeWithText("Expiry Date", substring = true).assertIsDisplayed()
composeTestRule.onNodeWithText("CVC", substring = true).assertIsDisplayed()
}
@Test
fun testPaymentSubmission() {
composeTestRule.setContent {
CheckoutScreen()
}
// Wait for Drop-in to render
composeTestRule.waitForIdle()
// Fill card details and submit
composeTestRule.onNodeWithText("Card").performClick()
composeTestRule.onNodeWithText("Card Number", substring = true)
.performTextInput("4111111111111111")
composeTestRule.onNodeWithText("Expiry Date", substring = true)
.performTextInput("12/30")
composeTestRule.onNodeWithText("CVC", substring = true)
.performTextInput("123")
composeTestRule.onNodeWithText("Pay", substring = true).performClick()
// Verify payment submission
composeTestRule.waitForIdle()
}
}Before going live, work through each checklist below.
Confirm production configuration:
- Change environment to
Environment.LIVE. - Use production API credentials.
- Verify correct
ownerIdandownerType. - Confirm currency and amount formatting.
Confirm sandbox and device coverage:
- Test all enabled payment methods.
- Test successful payments.
- Test failed payments and error handling.
- Test user cancellation scenarios (including Aeropay popup close →
onCancel). - Verify backend verification works correctly.
- Test on physical devices (not just emulators).
- For Aeropay, confirm USD +
Ecom, sessionpayByBanks.aeropay, andaeropayDropInIntent.
Confirm security controls:
- Backend verification implemented.
- Replay attack prevention in place.
- HTTPS enabled on all backend endpoints.
- No sensitive data logged.
- ProGuard or R8 obfuscation enabled for production builds.
Confirm UX quality:
- Test on different screen sizes and orientations.
- Loading states display correctly.
- Success screen implemented.
- Error messages are user-friendly.
- Accessibility features tested (TalkBack, large text).
Confirm performance:
- App startup time is acceptable.
- Payment submission is responsive.
- No memory leaks detected.
- Network timeouts configured appropriately.
Confirm code quality:
- Lint checks pass.
- Unit tests pass.
- Integration tests pass.
- Code review completed.
- Documentation updated.