Skip to content

Bounceapp/react-native-paypal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@bounceapp/react-native-paypal

Package version MIT license PRs Welcome

React Native wrapper to bridge PayPal iOS and Android SDK, support only requestBillingAgreement for the moment

Platform Compatibility

Android Device Android Emulator iOS Device iOS Simulator Expo GO Web

Documentation

API Reference.

Installation

yarn add @bounceapp/react-native-paypal react-native-svg

Bare Workflow

// 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>

Expo

// app.json
{
  "expo": {
    "android": {
      "intentFilters": [
        {
          "action": "VIEW",
          "data": [
            {
              "scheme": "${applicationId}.braintree"
            }
          ],
          "category": ["BROWSABLE", "DEFAULT"]
        }
      ]
    }
  }
}

Usage example

// 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} />
}

👏 Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

The source code is made available under the MIT license. Some of the dependencies can be licensed differently, with the BSD license, for example.