All Projects → iamraphson → React Paystack

iamraphson / React Paystack

Licence: mit
ReactJS library for implementing paystack payment gateway

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to React Paystack

Open Banking Gateway
Provides RESTful API, tools, adapters, and connectors for transparent access to open banking API's (for banks that support PSD2 and XS2A as well as HBCI/FinTS)
Stars: ✭ 58 (-72.9%)
Mutual labels:  payment-gateway
Whmcs Payment Gateway Alipay
A Simple Alipay payment gateway for WHMCS
Stars: ✭ 104 (-51.4%)
Mutual labels:  payment-gateway
Mpesa Php Sdk
A PHP sdk for the new Mpesa RESTful APIs
Stars: ✭ 134 (-37.38%)
Mutual labels:  payment-gateway
Laravel Paytm Wallet
Integrate paytm wallet in your laravel application easily with this package. This package uses official Paytm PHP SDK's.
Stars: ✭ 58 (-72.9%)
Mutual labels:  payment-gateway
Midtrans Php
Official Midtrans Payment API Client for PHP | https://midtrans.com
Stars: ✭ 91 (-57.48%)
Mutual labels:  payment-gateway
Catarse
The first open source crowdfunding platform for creative projects in the world
Stars: ✭ 1,575 (+635.98%)
Mutual labels:  payment-gateway
Indipay
The Laravel Framework Package for Indian Payment Gateways. Currently Supported Gateway: CCAvenue, PayUMoney, EBS, CitrusPay ,ZapakPay (Mobikwik), Paytm, InstaMojo , Mocker
Stars: ✭ 50 (-76.64%)
Mutual labels:  payment-gateway
Manuals
Do design No code 💻📱🛒📚
Stars: ✭ 1,969 (+820.09%)
Mutual labels:  payment-gateway
Adyen Php Api Library
Adyen API Library for PHP
Stars: ✭ 93 (-56.54%)
Mutual labels:  payment-gateway
Laravel Paddle
Paddle.com API integration for Laravel with support for webhooks/events
Stars: ✭ 132 (-38.32%)
Mutual labels:  payment-gateway
Icanpay.donet
统一支付网关。支持NET46和NETSTANDARD2_0。支持支付宝,微信,银联支付渠道通过Web,App,Wap,QRCode方式支付。简化订单的创建、查询、退款跟接收网关返回的支付通知等功能
Stars: ✭ 62 (-71.03%)
Mutual labels:  payment-gateway
Openfintech
Opensource FinTech standards & payment provider data
Stars: ✭ 87 (-59.35%)
Mutual labels:  payment-gateway
Sdk Dotnet
.Net SDK for Authorize.Net API
Stars: ✭ 124 (-42.06%)
Mutual labels:  payment-gateway
Golang Payu
Golang Payu Integration
Stars: ✭ 58 (-72.9%)
Mutual labels:  payment-gateway
Go Payment
Payment Connector for Midtrans and Xendit. Sample site that is using this payment proxy is https://imrenagi.com/donate
Stars: ✭ 136 (-36.45%)
Mutual labels:  payment-gateway
React Native Midtrans
Midtrans Mobile SDK for React Native
Stars: ✭ 57 (-73.36%)
Mutual labels:  payment-gateway
Ovoid
Un-Official OVO API Wrapper
Stars: ✭ 121 (-43.46%)
Mutual labels:  payment-gateway
Laravel Ebank
🤖 电商类站内虚拟积分与聚合支付解决方案
Stars: ✭ 192 (-10.28%)
Mutual labels:  payment-gateway
Iso 8583 Socket Queue
ISO 8583 gateway
Stars: ✭ 141 (-34.11%)
Mutual labels:  payment-gateway
J2pay
Multi-gateway payment processing library for java
Stars: ✭ 125 (-41.59%)
Mutual labels:  payment-gateway

react-paystack

This is a react library for implementing paystack payment gateway

Demo

Demo

Get Started

This React library provides a wrapper to add Paystack Payments to your React application

Install

npm install react-paystack --save

or with yarn

yarn add react-paystack

Usage

This library can be implemented into any react application in 3 different ways:

  1. By using hooks provided by the library
  2. By using a button provided by the library
  3. By using a context consumer provided by the library

Note that all 3 implementations produce the same results.

1. Using the paystack hook

  import React from 'react';
  import logo from './logo.svg';
  import { usePaystackPayment } from 'react-paystack';
  import './App.css';
  
  const config = {
      reference: (new Date()).getTime(),
      email: "[email protected]",
      amount: 20000,
      publicKey: 'pk_test_dsdfghuytfd2345678gvxxxxxxxxxx',
  };
  
  // you can call this function anything
  const onSuccess = (reference) => {
    // Implementation for whatever you want to do with reference and after success call.
    console.log(reference);
  };

  // you can call this function anything
  const onClose = () => {
    // implementation for  whatever you want to do when the Paystack dialog closed.
    console.log('closed')
  }

  const PaystackHookExample = () => {
      const initializePayment = usePaystackPayment(config);
      return (
        <div>
            <button onClick={() => {
                initializePayment(onSuccess, onClose)
            }}>Paystack Hooks Implementation</button>
        </div>
      );
  };
  
  function App() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
        <PaystackHookExample />
      </div>
    );
  }
  
  export default App;

2. Using the paystack button

  import React from 'react';
  import logo from './logo.svg';
  import { PaystackButton } from 'react-paystack';
  import './App.css';
  
  const config = {
    reference: (new Date()).getTime(),
    email: "[email protected]",
    amount: 20000,
    publicKey: 'pk_test_dsdfghuytfd2345678gvxxxxxxxxxx',
  };
  
  function App() {
    // you can call this function anything
    const handlePaystackSuccessAction = (reference) => {
      // Implementation for whatever you want to do with reference and after success call.
      console.log(reference);
    };

    // you can call this function anything
    const handlePaystackCloseAction = () => {
      // implementation for  whatever you want to do when the Paystack dialog closed.
      console.log('closed')
    }

    const componentProps = {
        ...config,
        text: 'Paystack Button Implementation',
        onSuccess: (reference) => handlePaystackSuccessAction(reference),
        onClose: handlePaystackCloseAction,
    };

    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
        <PaystackButton {...componentProps} />
      </div>
    );
  }
  
  export default App;

3. using the Paystack consumer

import React from 'react';
import logo from './logo.svg';
import { PaystackConsumer } from 'react-paystack';
import './App.css';
  
  const config = {
      reference: (new Date()).getTime(),
      email: "[email protected]",
      amount: 20000,
      publicKey: 'pk_test_dsdfghuytfd2345678gvxxxxxxxxxx',
  };
  
  // you can call this function anything
  const handleSuccess = (reference) => {
    // Implementation for whatever you want to do with reference and after success call.
    console.log(reference);
  };

  // you can call this function anything
  const handleClose = () => {
    // implementation for  whatever you want to do when the Paystack dialog closed.
    console.log('closed')
  }

  function App() {
      const componentProps = {
          ...config,
          text: 'Paystack Button Implementation',
          onSuccess: (reference) => handleSuccess(reference),
          onClose: handleClose
      };
  
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
        <PaystackConsumer {...componentProps} >
          {({initializePayment}) => <button onClick={() => initializePayment(handleSuccess, handleClose)}>Paystack Consumer Implementation</button>}
        </PaystackConsumer>
      </div>
    );
  }
  
  export default App;

Please checkout Paystack Documentation for other available options you can add to the tag

Deployment

REMEMBER TO CHANGE THE KEY WHEN DEPLOYING ON A LIVE/PRODUCTION SYSTEM

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b feature-name
  3. Commit your changes: git commit -am 'Some commit message'
  4. Push to the branch: git push origin feature-name
  5. Submit a pull request 😉😉

How can I thank you?

Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or Any Social Media? Spread the word!

Don't forget to follow me on twitter!

Thanks! Ayeni Olusegun.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].