Present the drop-in
Show Pay.com's ready-made payment sheet over the app's current screen, and get the result when it closes.
checkout.presentDropIn() shows Pay.com's payment sheet over the app's current screen. The sheet lists the session's methods, including the Apple Pay or Google Pay button when you turn it on, the card form with SDK-owned fields, and redirect methods such as PayPal or iDEAL. It also shows the save-card choice, and a Pay button labeled with the amount. The customer selects a method, then pays. 3DS and redirects open over the sheet. A failure the customer can recover from, such as a decline with attempts left, shows in the sheet so they can try again. The promise resolves once the sheet closes.
The sheet is the native SDKs' own drop-in, so it matches each platform's native design (system lists, controls, and buttons on iOS, and Material 3 on Android, in light and dark mode). At checkout, a returning customer sees their saved methods first, in a carousel. In a setup session, it lists them on top, with their default selected. In a payout session, it reads as choosing where payouts go. See Let customers choose a payout method. What the customer sees describes the sheet from top to bottom, on each platform. While it's open, the SDK picks up return URLs from React Native's Linking. See Handle the return URL.
To build your own screen instead, use the card fields and checkout.pay().
const result = await checkout.presentDropIn({ merchantDisplayName: 'My Shop' })Parameters
presentDropIn() takes one options object. Every option is optional, and the sheet works without any.
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantDisplayName | string | No | Your business's name, above the total and in the save-card label, as in "Save card for future use at My Shop". |
cardholderName | 'hidden' | 'optional' | 'required' | No | Controls the cardholder name field ('hidden', 'optional', or 'required'). Default: 'optional'. |
saveCard | 'automatic' | 'hidden' | No | 'automatic' shows the save-card choice, unless the session saves the card anyway or only saves it. That's when its setup_future_usage is on_session, it's a recurring session, or it's a setup session. 'hidden' never shows it. Default: 'automatic'. |
paymentMethods | string[] | No | Shows only these API types, in the session's order, for example ['card', 'paypal']. It filters the customer's saved methods by type too, and the Apple Pay and Google Pay buttons show only when it lists applepay or googlepay. Default: every method the session accepts. |
allowsRemovingSavedPaymentMethods | boolean | No | Shows Edit over the saved methods, so the customer can remove them. Default: false. |
secureScreen | boolean | No | Prevents screenshots and screen recording of the sheet using FLAG_SECURE (Android only). Default: false. |
applePay | PayApplePayOptions | No | Shows the Apple Pay button (iOS only). See Pay with Apple Pay or Google Pay. |
googlePay | PayGooglePayOptions | No | Shows the Google Pay button (Android only). See Pay with Apple Pay or Google Pay. |
appearance | PayDropInAppearance | No | The sheet's colors, corners, text size, Pay button, and card inputs. See Style the drop-in. |
strings | Partial<PayDropInStrings> | No | The sheet's text, in English by default. See Change the drop-in's text. |
Returns
presentDropIn() returns a promise that resolves with a PayResult once the sheet closes:
status | Description |
|---|---|
'succeeded' | The customer paid, or the payment was authorized for a session created with capture: false. In a setup session, they saved or kept a method. result.ids holds the IDs. |
'processing' | The SDK didn't get a final outcome, for example for a method that's still pending. result.ids holds the IDs. Your server confirms the outcome. |
'canceled' | The customer closed the sheet. |
'failed' | The session can't be paid anymore, because it expired, was already paid, or ran out of attempts, or the sheet had no method to show. Inspect result.error.code for the failure reason, for example session_expired or unsupported. |
Once the promise resolves, checkout.savedPaymentMethods() leaves out any method the customer removed in the sheet.
Errors
presentDropIn() rejects with a PayError only when the sheet couldn't open:
| Error code | When |
|---|---|
released | The checkout was released. |
payment_in_progress | The drop-in is already showing for this checkout. |
no_screen | There's no screen to show the sheet on (no foreground activity on Android, or no view controller on iOS). |
unexpected_response | The native SDK returned a response this SDK version can't read, or the sheet hit an unexpected error on Android. |
presentDropIn() rejects with a TypeError instead, before the sheet opens, when an option has the wrong type, for example a cardholderName other than the three values, a paymentMethods that isn't an array of strings, or an allowsRemovingSavedPaymentMethods that isn't a boolean. appearance, strings, and the wallet options list their own.
What the customer sees
Each platform shows its own sheet, with the same parts, texts, and behavior.
A new customer at checkout, on iOS and on Android:
From top to bottom
The sheet stacks these parts, and shows each one only when it applies.
- The top. At checkout, your
merchantDisplayNameand the total, with Close. In a setup or payout session, "Payment" or "Payout method", with Close, and Edit when the customer can remove saved methods. - Apple Pay on iOS or Google Pay on Android, when you set it up, the session offers it, and the device can pay, with "or" under it when other methods follow.
- Saved payment methods, in setup and payout sessions. Each row has the method's logo and name, a card also its "Expires MM/YY", and the customer's default reads "Default". At checkout, a returning customer sees theirs in a carousel instead, and the methods below under Other ways to pay.
- Pay with (or Get paid with in a payout session) lists Card followed by the redirect methods in the session's order, each row with its logo. There's no list when Card is the only choice.
- Card information appears while Card is selected, showing the card number with its brand icon at the end, the expiration date and CVV side by side, and the name field (optional by default).
- The save-card switch, under the card and off by default ("Save card for future use at My Shop"). It isn't shown in a setup or recurring session, or when the session's
setup_future_usageison_session. - The failure message, after a failed attempt.
- One button, pinned above the keyboard. There's none when the wallet is the only method. Under it, the card brands the session accepts, when it lists them.
In a payout session, on iOS and on Android:
A returning customer
At checkout, a customer with saved payment methods sees them first. iOS is on the left, Android on the right.
- Your
merchantDisplayNameand the total, with Close. - Apple Pay on iOS or Google Pay on Android, when you set it up, the session offers it, and the device can pay, with "or" under it.
- The carousel of saved methods, with the chosen one in front. A card shows its card art when the card network sends it, and a drawn card otherwise. The carousel holds up to five methods, starting with the default followed by the others in the order Pay.com lists them. A method picked on Payment methods comes to the front on iOS. On Android it becomes the large one, and if it isn't among the five, it's added first.
- The chosen method's name, and a button to change it (Change payment method on iOS, Change on Android). On Android, a line under the name reads "Default" for the customer's default, or else a card's expiration date and issuer, "Bank account", or the account's email.
- A CVV field, when the session checks CVVs and Pay.com doesn't hold one for the card.
- One button labeled Pay €24.90.
The change button opens Payment methods, with every saved method that hasn't expired. When the customer can remove saved methods, Edit is there too. The last entry, Other ways to pay, opens the card form and the session's other payment methods, with their own Pay button.
On each platform
The parts are the same, and each platform draws them with its own controls.
| iOS | Android | |
|---|---|---|
| The sheet | A system page sheet, with a grabber and a navigation bar | A Material 3 bottom sheet |
| The title bar | At checkout, Close on the left, above the merchant and the total. In setup and payout sessions, the title centered, Close on the left, and Edit on the right | At checkout, the merchant on the left and Close on the right, with the total under them. In setup and payout sessions, the title on the left, Edit and Close on the right |
| The saved methods at checkout | A wrapping carousel with the chosen method in front and its neighbors behind | A non-wrapping Material carousel with the chosen method at full size and its neighbors cropped beside it |
| Payment methods | Tiles in two columns, with a checkmark on the chosen one | A list, with a radio button on each row |
| The selection | A checkmark on the selected row | A radio button on every row |
| The card | One grouped list, with placeholders for labels | Outlined fields, with floating labels |
| Paying with a wallet | Apple Pay's sheet shows the progress | The Google Pay button shows a spinner |
| Removing | A red minus on each saved row | A red delete button on each saved row, and Edit reads Done |
States
The sheet changes as the customer selects methods and pays.
| State | What the customer sees |
|---|---|
| The sheet opens | At checkout, a returning customer's default saved method, in front of the carousel. Otherwise their default saved method selected, or else the first row. |
| Another method is selected | The card form and its switch collapse, and come back with Card. |
| Card is the only method | The form, without a list. |
| The wallet is the only method | Its button alone. |
| The card details are wrong | "Card number is invalid", "Expiry date is invalid", or "CVV must be 3 or 4 digits" under the input immediately. After a tap on Pay, incomplete fields also display their validation messages, empty ones read "Required", and the first gets focus. |
| Paying | A spinner in the Pay button. Everything is disabled, and the sheet can't be closed. |
| 3DS, a redirect, or the wallet | Its screen opens over the sheet. A cancel returns to the sheet, with no message. |
| Declined | "Your payment method has been declined." The customer can try again. |
| The total changed | "The total has changed. Check the new total, then pay again." The button shows the new total, and nothing was charged. |
| Another failure | "Check your connection and try again." or "Something went wrong. Please try again." |
| The session can't be paid anymore | "You have reached the maximum number of payment attempts.", "The session has expired and payment can no longer be made.", or "This payment can no longer be completed." Everything but Close is disabled. |
| A setup or payout session | Saved methods first. Using one makes it the customer's default. |
| Removing a saved method | The customer taps Edit, then confirms "Remove Visa •••• 4242?" with Remove, or taps Cancel. Once nothing is left to select, the sheet closes as 'canceled'. |
| Removing a saved method at checkout | The customer taps Edit on Payment methods, then confirms "Remove Visa •••• 4242?" with Remove, or taps Cancel. If the chosen method is removed, the default, or else the first, takes its place. When the customer removes their last saved method, the sheet switches to the new-customer view. |
| Large text | A list replaces the carousel, with the change button under it. On iOS, from an accessibility text size, it lists every saved method under "Saved" with a checkmark on the chosen one, and Payment methods uses one column. On Android, from a 150% font size, it lists the carousel's methods with radio buttons. |
| Success | The sheet closes automatically and returns the PayResult so your app can display confirmation. |
The button
The button's label depends on the session and the selected method.
| Session and selection | The button reads |
|---|---|
| A payment | Pay €10.00, or Pay when the session has no amount or currency |
| A setup session, with a new method | Add your payment method |
| A setup session, with a saved method | Use payment method |
| A payout session, with any method | Use payment method |
Logos
The sheet shows the same logos as Pay.com.js, bundled in the native SDKs, on both platforms.
| Where | What it shows |
|---|---|
| A method's row | The method's logo, as Pay.com.js shows it. A method without a logo of its own shows its monogram, as Pay.com.js does (up to two initials of its name on a white card, for example BD for Bacs Direct Debit). |
| The Card row | A card. |
| A saved method's row | The card's brand, or the method's logo. Without either, a monogram. |
| A saved method at checkout | A card's art, when the card network sends it, or else a drawn card in the brand's color, with the issuer or brand, the last 4 digits, the expiration date, and the brand's mark. PayPal and bank accounts show their logo on a white card in light mode, and a dark gray one in dark mode. |
| The card number input | The detected card brand at the end of the field (Visa, Mastercard, American Express, or Discover), or a generic card icon. Screen readers read the brand's name. |
| Under the button | When the session takes cards and lists accepted brands, the logos for Visa, Mastercard, Discover, and American Express appear under the button. Other brands aren't shown there. Screen readers read them as "Accepted cards: Visa, Mastercard". |
A redirect method's row reads the method's name, as Pay.com.js shows it, unless you set one in strings.methodNames. Its monogram takes its initials from the name the row shows.
When the amount changes
The drop-in checks the session's total when the sheet opens and again before it charges.
- When the sheet opens, it reads the session's total again, for up to 5 seconds. If it can't, it opens with the total it has, and still checks before it charges.
- When your server changes the total, nothing is charged at the old one. The Pay button shows the new total, under "The total has changed. Check the new total, then pay again.", and the customer taps again.
- Apple Pay and Google Pay open with the new total. If the total changes while the wallet's sheet is open, nothing is charged and the drop-in shows the same message.
presentDropIn() doesn't resolve with amount_changed. The customer pays again or closes the sheet. After that, checkout.session has the total the sheet last read. See When the amount changes for the check itself.
Example
import { Alert } from 'react-native'
import { PayCheckout, PayError } from '@pay-com/react-native'
export async function payWithDropIn(orderId: string) {
// Your own server creates the session and returns only its client_secret.
const clientSecret = await fetchClientSecret(orderId)
const checkout = await PayCheckout.create(clientSecret, { returnUrl: 'myshop://pay' })
try {
const result = await checkout.presentDropIn({
merchantDisplayName: 'My Shop',
cardholderName: 'required',
})
switch (result.status) {
case 'succeeded':
case 'processing':
// A hint for your UI. Your server confirms the payment before you fulfill the order.
showOrderPlaced(orderId)
break
case 'canceled':
break // the customer closed the sheet: keep their cart
case 'failed':
// The session can't be paid anymore: your server creates a new one to try again.
Alert.alert('This payment can no longer be completed.')
break
}
} catch (error) {
// The sheet didn't open, for example error.code is 'no_screen'.
if (error instanceof PayError) console.warn(error.code, error.message)
} finally {
checkout.release()
}
}Next steps
- Pay with Apple Pay or Google Pay: Add the wallet button to the sheet.
- Style the drop-in: Match the sheet to your app.
- Change the drop-in's text: Translate the sheet.
- Retrieve a payment session: Confirm the payment on your server.