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-klasha-webview

v0.0.1

Published

This package allows you to accept payment in your react native project using Klasha

Downloads

5

Readme

react-native-klasha-webview

The package allows you accept payment using Klasha and guess what , it doesn't require any form of linking, just install and begin to use .

Installation

Add react-native-klasha-webview to your project by running;

npm install react-native-klasha-webview

or

yarn add react-native-klasha-webview

One more thing

To frontload the installation work, let's also install and configure dependencies used by this project, being react-native-webview

run

yarn add react-native-webview

for IOS: cd iOS && pod install && cd ..

for expo applications run;

expo install react-native-webview

and that's it, you're all good to go!

Usage 1

import React from "react";
import KlashaWebView from "react-native-klasha-webview";
import { View } from "react-native";

function Pay() {
  return (
    <View style={{ flex: 1 }}>
      <KlashaWebView
        buttonText="Pay Now"
        showPayButton={false}
        merchantKey="your-merchantKey"
        businessId="your-businessId"
        amount={120000}
        customerEmail="[email protected]"
        customerPhoneNumber="08143108254"
        customerFullname="Dansteve Adekanbi"
        callbackUrl=""
        countryCode="NGN"
        sourceCurrency="NGN"
        paymentType=""
        ActivityIndicatorColor="green"
        SafeAreaViewContainer={{ marginTop: 5 }}
        SafeAreaViewContainerModal={{ marginTop: 5 }}
        callBack={(res) => {
          // handle response here
          console.log(res);
        }}
        autoStart={false}
      />
    </View>
  );
}

Usage 2 - Custom Pay Button

Make use of a custom payment trigger button. See example below;

import React from 'react';
import KlashaWebView from 'react-native-klasha-webview';
import { View } from 'react-native';

function Pay() {
  return (
    <View style={{flex: 1}}>
      <KlashaWebView
        buttonText="Pay Now"
        showPayButton={false}
        merchantKey="your-merchantKey"
        businessId="your-businessId"
        amount={120000}
        customerEmail="[email protected]"
        customerPhoneNumber="08143108254"
        customerFullname="Dansteve Adekanbi"
        callbackUrl=""
        countryCode="NGN"
        sourceCurrency="NGN"
        paymentType=""
        tx_ref={uuid()} // this is only for cases where you have a reference number generated
        ActivityIndicatorColor="green"
        SafeAreaViewContainer={{marginTop: 5}}
        SafeAreaViewContainerModal={{marginTop: 5}}
        handleWebViewMessage={(e) => {
          // handle the message
        }}
        callBack={(e) => {
          // handle response here
          console.log(res);
        }}
        autoStart={false}
        renderButton={(onPress) => {
          <Button onPress={onPress}>
            Pay Now
          </Button>
        }}
      />
    </View>
  );
}

Usage 3 - Using Refs

Make use of a ref to start transaction. See example below;

import React, { useRef } from 'react';
import KlashaWebView from 'react-native-klasha-webview';
import { View, TouchableOpacity,Text } from 'react-native';

function Pay(){
  const KlashaWebViewRef = useRef();

  return (
    <View style={{flex: 1}}>
      <KlashaWebView
        showPayButton={false}
        merchantKey="your-merchantKey"
        businessId="your-businessId"
        amount={120000}
        customerEmail="[email protected]"
        customerPhoneNumber="08143108254"
        customerFullname="Dansteve Adekanbi"
        callbackUrl=""
        countryCode="NGN"
        sourceCurrency="NGN"
        paymentType=""
        ActivityIndicatorColor="green"
        SafeAreaViewContainer={{marginTop: 5}}
        SafeAreaViewContainerModal={{marginTop: 5}}
        tx_ref={KlashaWebViewRef}
        callBack={(res) => {
          // handle response here
          console.log(res);
        }}
      />

        <TouchableOpacity onPress={()=> KlashaWebViewRef.current.StartTransaction()}>
          <Text>Pay Now</Text>
        </TouchableOpacity>
      </View>
  );
}

Note:

You can also make use of the new props autoStart to initiate payment once the screen mounts. Just see autoStart={true}. This is set to false by default.

API's

| Name | use/description | extra | | :----------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ---------------------------------------------------------: | | buttonText | Defines text on the button | default: Pay Now | | textStyles | Defines styles for text in button | nill | | btnStyles | Defines style for button | nill | | merchantKey | merchantKey(visit Klasha.com to get yours) | nill | | businessId | businessId | 1 | | amount | Amount to be paid | nill | | callbackUrl | callbackUrl | nill | | countryCode(required by Klasha) | countryCode | nill | | sourceCurrency | sourceCurrency | countryCode | | ActivityIndicatorColor | color of loader | default: green | | customerEmail(required by Klasha) | Customer email | default: nill | | customerPhoneNumber(required by Klasha) | Customer mobile | default: nill | | customerFullname(required by Klasha) | Customer Name | default: nill | | callBack | callback function | default: nill | | autoStart | Auto start payment once page is opened | default: false | | SafeAreaViewContainer | style for SafeAreaView containter | default: nill | | SafeAreaViewContainerModal | style for SafeAreaView for modal | default: nill | | showPayButton | Control the Pay Now button visibility | default: true | | tx_ref | Reference number, if you have already generated one | default: ''+Math.floor((Math.random() * 1000000000) + 1) | | renderButton | Render your own Pay Now button, should be used when showPayButton is true | default: null | | handleWebViewMessage | Will be called when a WebView receives a message | default: true |

For more information checkout klasha's documentation

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

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 anywhere? Spread the word!

Don't forget to follow me on twitter!

Thanks! Dansteve Adekanbi.

License

The MIT License (MIT). Please see License File for more information.