0.0.5 • Published 5 years ago

react-native-webview-braintree v0.0.5

Weekly downloads
10
License
MIT
Repository
github
Last release
5 years ago

React Native Webview Braintree

A Braintree payment component with no native code for React Native apps.

npm npm npm npm

Usage

<WebViewBraintree
    clientToken={this.state.clientToken}
    nonceObtainedCallback={this.handlePaymentMethod}
    navigationBackCallback={this.navigationBackCallback}
    paymentAPIResponse={this.state.paymentAPIResponse}
/>	

This component accepts the following props

  • clientToken
  • nonceObtainedCallback
  • navigationBackCallback
  • paymentAPIResponse
NameRequiredDescription
clientTokenyesBraintree client token used to create the dropin UI
nonceObtainedCallbackyesFunction called once a Braintree payment nonce is obtained, the nonce value is passed to ehe function as the only parameter
paymentAPIResponseyesA string indicated the success of the an API to Braintree transaction API. The string should be either "PAYMENT_SUCCESS" "PAYMENT_REJECTED"
navigationBackCallbacknoFunction that can be called in order to initiate navigation. This function will be called when the user clicks on a button labeled "Return to Shop" that appears after a rejected or successful purchase

Example use of the paymentAPIResponse string

brainTreeUtils
    .postPurchase(nonce, this.props.cart.totalPrice, {})
    .then(response => {
        if (response.type === "success") {
            this.setState({ paymentAPIResponse: "PAYMENT_SUCCESS" });
            this.props.dispatch(actions.cartActions.emptyCart());
        } else {
            this.setState({ paymentAPIResponse: "PAYMENT_REJECTED" });
        }
});

Example Application

React Native Webview Braintree test application

TODOs

Integrate Paypal payments

LICENSE

MIT