**Last updated**: 20 November 2025 | [**Change log**](/products/checkout/react-native/changelog/)
# Create a session to pay with a card
Use our React Native SDK to secure your customer's card details by creating a `session`.
Full Sample Integration
You can see an example of the session generation [here](https://github.com/Worldpay/access-checkout-react-native/tree/master/demo-app).
## Set your views
When you create your checkout form, you must set the views that your customers use to enter and submit their card details.
Here's an example of how you would set your view configurations.
JavaScript
import React, {useState} from 'react';
import {Button, TextInput, View} from 'react-native';
export default function CardFlow() {
const [pan, setPan] = useState ('');
const [expiryDate, setExpiryDate] = useState ('');
const [cvc, setCvc] = useState ('');
function createSession() {
...
}
return (
);
}
TypeScript
import React, {useState} from 'react';
import {Button, TextInput, View} from 'react-native';
export default function CardFlow() {
const [pan, setPan] = useState ('');
const [expiryDate, setExpiryDate] = useState ('');
const [cvc, setCvc] = useState ('');
function createSession() {
...
}
return (
);
}
## Validate card details
You can optionally validate your customer's card details. You can find instructions [here](/products/checkout/react-native/v2/card-validator).
## Create a session
### Initialize the AccessCheckout client
You must now initialize the `AccessCheckout`.
To do this, you must provide your `baseUrl` and `merchantId` (checkout ID).
Here's an example of how to initialize it.
import {
AccessCheckout,
} from '@worldpay/access-worldpay-checkout-react-native-sdk';
const accessCheckout = new AccessCheckout({
baseUrl: 'https://try.access.worldpay-bsh.securedataplatform.com/',
merchantId: 'YOUR_CHECKOUT_ID',
});
### Parameters
| Parameter | Description |
| --- | --- |
| `baseUrl` | For testing use: `https://try.access.worldpay-bsh.securedataplatform.com/`For live use: `https://access.worldpay-bsh.securedataplatform.com/` |
| `merchantId` | Your unique checkout ID. |
### Generate CARD session
You must pass the customer's card details and the `CARD` session type to the `generateSessions` method of the `AccessCheckout` instance.
Here's an example of what you should do when your customer submits their card details.
JavaScript
import {
...
CARD,
} from '@worldpay/access-worldpay-checkout-react-native-sdk';
...
function createSession() {
const sessionTypes = [CARD];
const cardDetails = {
pan,
expiryDate,
cvc,
};
accessCheckout.generateSessions(cardDetails, sessionTypes)
.then((sessions) => {
const cardSession = sessions.card;
// do something with the card session ...
})
.catch((error) => {
// do something in case of error
});
}
TypeScript
import {
...
CARD,
CardDetails,
Sessions,
} from '@worldpay/access-worldpay-checkout-react-native-sdk';
...
function createSession() {
const sessionTypes: Array = [CARD];
const cardDetails: CardDetails = {
pan,
expiryDate,
cvc,
};
accessCheckout.generateSessions(cardDetails, sessionTypes)
.then((sessions: Sessions) => {
const cardSession = sessions.card;
// do something with the card session ...
})
.catch((error) => {
// do something in case of error
});
}
### Full code sample
Here's the full code sample of the steps above.
JavaScript
import React, { useState } from 'react';
import { Button, TextInput, View } from 'react-native';
import {
AccessCheckout,
CARD,
} from '@worldpay/access-worldpay-checkout-react-native-sdk';
export default function CardFlow() {
const [pan, setPan] = useState('');
const [expiryDate, setExpiryDate] = useState('');
const [cvc, setCvc] = useState('');
const accessCheckout = new AccessCheckout({
baseUrl: 'https://try.access.worldpay-bsh.securedataplatform.com/',
merchantId: 'YOUR_CHECKOUT_ID',
});
function createSession() {
const sessionTypes = [CARD];
const cardDetails = {
pan,
expiryDate,
cvc,
};
accessCheckout.generateSessions(cardDetails, sessionTypes)
.then((sessions) => {
const cardSession = sessions.card;
// do something with the card session ...
})
.catch((error) => {
// do something in case of error
});
}
return (
);
}
TypeScript
import React, { useState } from 'react';
import { Button, TextInput, View } from 'react-native';
import {
AccessCheckout,
CARD,
CardDetails,
Sessions,
} from '@worldpay/access-worldpay-checkout-react-native-sdk';
export default function CardFlow() {
const [pan, setPan] = useState('');
const [expiryDate, setExpiryDate] = useState('');
const [cvc, setCvc] = useState('');
const accessCheckout = new AccessCheckout({
baseUrl: 'https://try.access.worldpay-bsh.securedataplatform.com/',
merchantId: 'YOUR_CHECKOUT_ID',
});
function createSession() {
const sessionTypes: Array = [CARD];
const cardDetails: CardDetails = {
pan,
expiryDate,
cvc,
};
accessCheckout.generateSessions(cardDetails, sessionTypes)
.then((sessions: Sessions) => {
const cardSession = sessions.card;
// do something with the card session ...
})
.catch((error) => {
// do something in case of error
});
}
return (
);
}
Caution
Do **not** validate the structure or length of the session resources. We follow HATEOS standard to allow us the flexibility to extend our APIs with non-breaking changes.
Important
The CARD `session` has a lifespan of **one minute** and you can use it **only once**. If you do not create a token within that time, you must create a new CARD `session` value.
**Next steps**
**Using the Payments API**
- Apply the session in the [payment request](/products/payments)
**Using our Modular APIs**
- Create a [verified token](/products/verified-tokens/create-verified-token)