Integrate Card Widget to Your React Native App
Integrate Card widget to your React Native App using Pesaswap-nodeThis feature is currently in Beta.** For access, please contact us at info@pesaswap.com
Pesaswap recommends using the PaymentSheet instead of the Card Widget. Using only the Payment Element, you can accept multiple payment methods.
1. Build Card Widget on the Client
1.1 Add HyperProvider to Your React Native App
UseHyperProvider to ensure that you stay PCI compliant by sending payment details directly to the Pesaswap server.
1.2 Use HyperProvider
To initialize Pesaswap in your React Native app, wrap your payment screen with theHyperProvider component. Only the API publishable key in publishableKey is required. The following example shows how to initialize Pesaswap using the HyperProvider component:
1.3 Fetch the PaymentIntent Client Secret
Make a network request to the backend endpoint you created in the previous step. TheclientSecret returned by your endpoint is used to complete the payment:
1.4 Render Your Card Widget
Use the PesaswapCardField component to display a text field to securely collect card details. By using CardField, you guarantee that sensitive card details never touch your server:
1.5 Initiate Payment Session
Pass the PaymentIntent’sclientSecret to the initPaymentSession() function. The Pesaswap SDK automatically collects the card details from the CardField component:
1.6 Confirm the Payment
To confirm the payment, integrate a “Pay Now” button within the checkout page, which, when clicked, invokes theconfirmWithCardForm() function. This function will return an asynchronous payment response with various payment statuses: