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

4.2.1 • Public • Published

JudoKit-ReactNative

npm version License: MIT React Native install size CircleCI

NPM

A React Native module for the Judopay native JudoKit-iOS and JudoKit-Android to process payments on iOS and Android.

Installation

yarn add judokit-react-native

Usage

import JudoPay, {JudoTransactionType} from 'judokit-react-native';

const judoKit = new JudoPay({
  token: 'your-judo-token',
  paymentSession: 'your-payment-session',
});

judoKit
  .invokeTransaction(JudoTransactionType.Payment, {
    judoId: '123456',
    amount: {
      value: '1.5',
      currency: 'GBP',
    },
    reference: {
      paymentReference: 'your-payment-reference',
      consumerReference: 'your-consumer-reference',
    },
  })
  .then(
    response => {
      console.log(response);
    },
    error => {
      console.error(error);
    },
  );

Example

Below is a simple example to showcase the basic usage of the library.

import JudoPay, {
  JudoAmount,
  JudoAuthorization,
  JudoConfiguration,
  JudoReference,
  JudoTransactionType,
} from 'judokit-react-native';
import React from 'react';
import {Button, StyleSheet, View} from 'react-native';

const authorization: JudoAuthorization = {
  token: 'your-judo-token',
  paymentSession: 'your-payment-session',
};

const judoKit = new JudoPay(authorization);

function App(): React.JSX.Element {
  const invokeJudoKit = () => {
    const amount: JudoAmount = {value: '1.5', currency: 'GBP'};
    const reference: JudoReference = {
      paymentReference: 'your-payment-reference',
      consumerReference: 'your-consumer-reference',
    };

    const configuration: JudoConfiguration = {
      amount,
      judoId: '123456',
      reference,
    };

    judoKit.invokeTransaction(JudoTransactionType.Payment, configuration).then(
      response => {
        console.log(response);
      },
      error => {
        console.error(error);
      },
    );
  };

  return (
    <View style={styles.container}>
      <Button title="Invoke JudoKit" onPress={invokeJudoKit} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default App;

Contributing

If you want to contribute to this project, follow instructions from CONTRIBUTING file.

See also

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i judokit-react-native

Weekly Downloads

12

Version

4.2.1

License

MIT

Unpacked Size

266 kB

Total Files

68

Last publish

Collaborators

  • judo_devteam
  • davidpollock
  • judopay-ci