npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-payfast-plugin

v1.0.3

Published

A react native component to integrate with PayFast via a webview/API calls.

Downloads

65

Readme

React Native Payfast Plugin

React Native Payfast Plugin is a React Native library for Payfast payment gateway integration. It allows you to integrate the Payfast payment gateway into your React Native app with ease. It provides a simple interface to accept in-app payments, generate payment links, and tokenize & update card details.

npm npm GitHub issues [GitHub stars] [GitHub license] Twitter [GitHub contributors] [GitHub last commit] [GitHub pull requests] [GitHub pull requests] [GitHub forks] [GitHub stars] [GitHub watchers]

This is not a Payfast official library.

Check out my other libraries

Table of contents

Getting started

Installation

npm install react-native-payfast-plugin

Expo?

expo install react-native-payfast-plugin

Supported transactions:

  • [x] Once of payment
  • [x] Recurring payment
  • [x] Tokenization

Features:

  • In-app payment
  • Generate payment link
  • Update card details (for tokenized cards)
  • Split payment (coming soon)
  • Charge tokenized card (coming soon)

Usage

In-app payment

import Payfast from 'react-native-payfast-plugin';

...
        <PayFast
            data={{
                merchantDetails: {
                    merchant_id: "10031584",
                    merchant_key: "5n52c1qu5501c",
                    notify_url: "https://webhook.site/f30e4b32-15b5-44e6-ae0b-c75486b8797d",
                },
                customerDetails: {
                    name_first: "First Name",
                    name_last: "Last Name",
                    email_address: "[email protected]",
                    cell_number: "0885....",
                },
                transactionDetails: {
                    m_payment_id: "1234",
                    amount: "10.00",
                    item_name: "Item Name",
                    item_description: "Item Description",
                },
                transactionOptions: {
                    email_confirmation: 0,
                    confirmation_address: "[email protected]",
                },
            }}

            sandbox={true}
            passphrase="thisisatestforthe"

            onCancel={(data) => {
                console.log("Payment cancelled: ", data.transaction_id);
            }}

            onMessage={(message) => {
                console.log(message);
            }}

            onSuccess={({ data, transaction_id }) => {
                console.log(transaction_id);
            }}

            onClose={() => {
                console.log("Payment closed");
            }}
        />
        ...

Generate payment link

import { LinkPayment } from "react-native-payfast-plugin";

const link = new LinkPayment(
  {
    merchantDetails: {
      merchant_id: "10031584",
      merchant_key: "5n52c1qu5501c",
      notify_url: "https://webhook.site/f30e4b32-15b5-44e6-ae0b-c75486b8797d",
    },
    customerDetails: {
      name_first: "First Name",
      name_last: "Last Name",
      email_address: "[email protected]",
      cell_number: "088...",
    },
    transactionDetails: {
      m_payment_id: "1234",
      amount: "10.00",
      item_name: "Item Name",
      item_description: "Item Description",
    },
    transactionOptions: {
      email_confirmation: 0,
      confirmation_address: "[email protected]",
    },
  },
  true,
  "thisisatestforthe"
);

// Optional - change to your own urls defaults to https://payfast.io/
link.cancel_url = "https://www.google.com/search?q=cancel";
link.return_url = "https://www.google.com/search?q=success";

const handleLink = async () => {
  link.getLink().then((link) => {
    setLink(link);
  });
};


// In your render function

...
  <Button title="Generate Link" onPress={handleLink} />
  <Text>{link}</Text>
...

Update card details

import { UpdateCard } from "react-native-payfast-plugin";

...
    <UpdateCard
        token="...e90c2-....-....-9ccb-...."
        onComplete={(data) => console.log(data)}
        sandbox={true}
    />
....

Tokenize card details


// Use the same PayFast component as in-app payment on the data prop add the following

    recurringBilling: {
        subscription_type: "2",
    },

Props

PayFast

| Prop | Type | Description | | ---------- | -------- | ---------------------------------------------- | | data | object | Data object for in-app payment | | sandbox | boolean | Set to true for sandbox mode | | passphrase | string | Passphrase for sandbox mode | | onCancel | function | Callback function when payment is cancelled | | onMessage | function | Callback function when payment is in progress | | onSuccess | function | Callback function when payment is successful | | onClose | function | Callback function when payment is closed | | onComplete | function | Callback function when card update is complete |

data

| Prop | Type | Description | | ------------------ | ------ | -------------------------------------------------------------------------------------------------------------------------------------- | | merchantDetails | object | Merchant details. See | | customerDetails | object | Customer details See | | transactionDetails | object | Transaction details See | | transactionOptions | object | Transaction options See | | recurringBilling | object | Recurring billing options See |

LinkPayment

Same as PayFast data

UpdateCard

| Prop | Type | Description | | ---------- | -------- | ---------------------------------------------- | | token | string | Token for card to be updated | | sandbox | boolean | Set to true for sandbox mode | | onComplete | function | Callback function when card update is complete |

License

MIT

Author

Axole Maranjana

Twitter Follow GitHub followers Instagram LinkedIn

Help Wanted!

This project is open for contributions. All contributions must be made via pull requests. Feel free to create issues and pull requests.

Credits

Support

Upcoming features and versions

  • [ ] Charge tokenized card v1.1.0
  • [ ] Get subscription details v1.2.0
  • [ ] Cancel subscription v1.3.0
  • [ ] Pause subscription v1.4.0
  • [ ] Resume subscription v1.5.0
  • [ ] Split payment v1.6.0