@bounceapp/react-native-paypal
Version:
React Native wrapper to bridge PayPal iOS and Android SDK
105 lines (81 loc) • 2.74 kB
Markdown
[](https://www.npmjs.com/package/@bounceapp/react-native-paypal)
[](LICENSE)
[](https://github.com/dcangulo/@bounceapp/react-native-paypal/pulls)
React Native wrapper to bridge PayPal iOS and Android SDK,
support only `requestBillingAgreement` for the moment
| Android Device | Android Emulator | iOS Device | iOS Simulator | Expo GO | Web |
| -------------- | ---------------- | ---------- | ------------- | ------------ | --- |
| ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
[](https://bounceapp.github.io/react-native-paypal/).
```sh
yarn add @bounceapp/react-native-paypal react-native-svg
```
```xml
// android/app/src/main/AndroidManifest.xml
<activity
android:name=".MainActivity"
// ...
>
// ...
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="${applicationId}.braintree" />
</intent-filter>
</activity>
```
```ts
// app.json
{
"expo": {
"android": {
"intentFilters": [
{
"action": "VIEW",
"data": [
{
"scheme": "${applicationId}.braintree"
}
],
"category": ["BROWSABLE", "DEFAULT"]
}
]
}
}
}
```
```js
// App.tsx
import React, { useState } from "react"
import { Button } from "react-native"
import {
requestBillingAgreement,
PaypalButton,
} from "@bounceapp/react-native-paypal"
export default function App() {
const [loading, setLoading] = useState(false)
const onPress = async () => {
const res = await requestBillingAgreement({
clientToken: "CLIENT_TOKEN",
})
if (res?.error) {
console.error(res?.error)
return
}
setLoading(false)
}
return <PaypalButton onPress={onPress} disabled={loading} />
}
```
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
The source code is made available under the [MIT license](LICENSE). Some of the dependencies can be licensed differently, with the BSD license, for example.