react-native-trust-payment
TypeScript icon, indicating that this package has built-in type declarations

0.1.29 • Public • Published

react-native-trust-payment

NPM pkg for access the native ios/android TPM libs for payment

Installation For iOS

npm install react-native-trust-payment

Update your iOS Project Pod File with below code first , in llast of pod file , Need to replace :project => "TpmGateWayApp", with :project => {{PROJECT__NAME}},

plugin 'cocoapods-keys', {
    :project => {{PROJECT__NAME}},
    :keys => [
      "JWTSecret",
      "MERCHANT_USERNAME",
      "MERCHANT_SITEREFERENCE"
   ]
}

Usage

import { TrustPaymentView } from 'react-native-trust-payment';

Replace These Keys in TrustPaymentView Class

JWTSecret;
MERCHANT_USERNAME;
MERCHANT_SITEREFERENCE;

Add Following Import

import { NativeEventEmitter } from 'react-native';
import { ReactNativeEventEmitter } from 'react-native-trust-payment';

After Add Above 2 Imports need to setup Event Listener. You can add it in component Constructor or use UseEffect Also on RN VIEW call this setupDataPayment() to setup and call the payment view. setupDataPayment can setup and send the keys to sdk and amount to charge

useEffect(() => {
  ///Oder Code Here
  var eventEmitter = new NativeEventEmitter(ReactNativeEventEmitter);
  // After Order Failed, You will get a Event with onPaymentFailed
  eventEmitter.addListener('onPaymentFailed', (data) => {
    console.log(data);
    // Data will contain the Failed Reason
    console.log('Payment Failed');
  });
  // After Oder Success, You will get a Event with onPaymentSuccess
  eventEmitter.addListener('onPaymentSuccess', (data) => {
    console.log(data);
    // Data will contain the Transection ID
    console.log('Payment Success');
  });
});
function setupDataPayment() {
  // playerRef?.
  const jsonObject = {
    mMerchantName: 'NAME FOR MERCHANGE',
    mERCHANT_USERNAME: 'jwt@integercomputersllp.com',
    mERCHANT_SITEREFERENCE: 'test_integercomputersllp121446',
    jWTSecret:
      '55-021017fcde1ff4f3f6d3da2ef37b34cfbd4c17bcfd53d8906a59caeb2e61aa51',
    paymentValue: '1100',
    isForApple: 'YES',
    isDirectPayment: 'true',
    appleObject: appleObject,
    isProduction: 'false',
    // Add more key-value pairs as needed
  };

  // console.log(jsonObject, 'HOST JOINING BROADCAST')
  // Convert the object to a JSON-encoded string
  const jsonString = JSON.stringify(jsonObject);
  UIManager.dispatchViewManagerCommand(
    findNodeHandle(playerRef.current),
    UIManager.TrustPaymentView.Commands.setupPayment,
    [jsonString]
  );
}

After Setup Event Listner we need to Init the Trust Payment View on Any Button Click or any Action.

<TrustPaymentView color="white" ref={playerRef} style={styles.sectionTitle} />

This view will setup UI For now, We Will upate the Direcct Evvent in next verision's no worries!

Waooooooo! Yoou are Good To Go!

Contributing

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

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i react-native-trust-payment

Weekly Downloads

28

Version

0.1.29

License

MIT

Unpacked Size

181 kB

Total Files

63

Last publish

Collaborators

  • atif-gulzar