PayPal Web Payments native integration for React native and Expo.
npm install react-native-paypal-web-payments
Bare React Native
-
Add
onNewIntent
to the MainActivity in your app:import android.content.Intent // ... class MainActivity : ReactActivity() { // ... override fun onNewIntent(newIntent: Intent?) { super.onNewIntent(newIntent) intent = newIntent }
-
Update your app's AndroidManifest.xml with your custom URL scheme in the intent-filter
<activity android:name=".MainActivity" ...> ... <intent-filter> <action android:name="android.intent.action.VIEW" /> <data android:scheme="custom-url-scheme" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter> </activity>
Expo
- Update expo config
{ "expo": { "scheme": "custom-url-scheme", "plugins": [ "react-native-paypal-web-payments" ] } }
import {
startCheckout,
PaypalEnvironment,
PayPalWebCheckoutFundingSource,
} from 'react-native-paypal-web-payments';
import { PayPalButton } from "react-native-paypal-button";
// ...
<PayPalButton
onPress={() => {
startCheckout({
clientID: "client-id",
environment: PaypalEnvironment.sandbox,
urlScheme: "url-scheme",
orderID: "order-id",
fundingSource: PayPalWebCheckoutFundingSource.paypal,
onEvent: (result) => {
console.log(result);
},
})
}}
/>
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library