New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-native-braintree-sdk

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-braintree-sdk

A small wrapper to access Braintree's most recent iOS/Android SDK on React Native

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

react-native-braintree-sdk

A small wrapper to access Braintree's most recent iOS/Android SDK on React Native

Installation

npm install react-native-braintree-sdk

Usage

import * as Braintree from "react-native-braintree-sdk";

// ...
const App = () => {
  const [isApplePayAvailable, setIsApplePayAvailable] = React.useState(false);

  useEffect(() => {
    const setup = async () => {
      await Braintree.setup('clientToken');
      Braintree.isApplePayAvailable()
        .then(setIsApplePayAvailable)
        .catch(showError);
    }
  }, []);
  const onPressApplePay = React.useCallback(async () => {
    try {
      const result = await Braintree.authorizeApplePay({
        merchantId: 'test-merchant-id',
        lineItems: [
          {
            label: 'Total',
            amount: 10,
          },
        ],
        contactFields: ['postalAddress'],
        supportedNetworks: ['AmEx', 'Visa', 'MasterCard'],
      });

      Alert.alert('Apple Pay Result', `Nonce: ${result.nonce}`);
    } catch (error) {
      showError(error);
    }
  }, []);

  return (
    <View>
      {isApplePayAvailable && <Button title='Pay with Venmo' onPress={onPressApplePay} />}
    </View>
  );
}

API

setup ⇒ void

Sets up the native Braintree client

ParamTypeDescription
clientAuthorizationstringSee Braintre's Docs

isVenmoAvailable ⇒ Promise<boolean>

Checks if the device can launch Venmo on iOS, on Android always returns true

Returns: Promise - Promise resolving to the status

authorizeVenmo ⇒ Promise<VenmoResponse>

Asks the user to start a Venmo request, if the user approves, returns a nonce to use for a transaction

Returns: Promise.<VenmoResponse> - Promise resolving to nonce and the user's venmo username

ParamTypeDescription
paramsAuthorizeVenmoParamsSee Braintre's Docs to find out more on the use / vaulting options

isGooglePayAvailable ⇒ Promise<boolean>

Checks if the device can use Google Pay. Always returns false on iOS devices

Returns: Promise - Promise resolving to the status

authorizeGooglePay ⇒ Promise<NonceResponse>

Presents the Google Pay popup, if the user approves, returns a nonce to use for a transaction

Returns: Promise.<NonceResponse> - Promise resolving to nonce

ParamTypeDescription
paramsAuthorizeGooglePayParamsThe price for the transaction that the nonce will be used with

isApplePayAvailable ⇒ Promise<boolean>

Checks if the device can use Apple Pay. Always returns false on Android devices

Returns: Promise - Promise resolving to the status

authorizeApplePay ⇒ Promise<NonceResponse>

Presents the Apple Pay popup, if the user approves, returns a nonce to use for a transaction

Returns: Promise.<NonceResponse> - Promise resolving to nonce

ParamTypeDescription
paramsAuthorizeGooglePayParamsSee Braintre's Docs to learn more about the Apple Pay payment request options

getCardNonce ⇒ Promise<CardResponse>

Creates a nonce for a card

Returns: Promise.<CardResponse> - Promise resolving to nonce and card informatiom

ParamTypeDescription
cardCardDetailsThe card details you collect on the device

Contributing

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

License

MIT

Keywords

react-native

FAQs

Package last updated on 13 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts