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

fastpay-react-package

v1.0.4

Published

FastPay merchant package

Downloads

7

Readme

FastPay React Native SDK

ReactNativeAndroidiOSJavaScript Maintenance Generic badge

FastPay Developers Arena

Accept payments with FastPay's APIs. Our simple and easy-to-integrate APIs allow for less effort in processing payments. This is an official support channel, but our APIs support both Android and iOS.

SDK flow

alt text

Screenshots

| Screenshot 1 | Screenshot 2 | Screenshot 3 | | :---: | :---: | :---: |

Quick Glance

Installation

dependencies:
  fastpay-react-package: ^1.0.4
  #To handle callbacks (Redirection) from fastpay wallet application.
  url-parse: ^1.5.10

Initiate FastPaySDK

  • Store ID : Merchant's Store Id to initiate transaction
  • Store Password : Merchant's Store password to initiate transaction
  • Order ID : Order ID/Bill number for the transaction, this value should be unique in every transaction
  • Amount : Payable amount in the transaction ex: "1000"
  • Environment : Payment Environment to initiate transaction
  • Call back Uri's: When the SDK redirect to the fastpay application for payment and after payment cancel or failed it throws a callback with this uri. It is used for deeplinking with the client app for catching callbacks from fastpay application. Both android and ios has platform specific call back uri's.
  • Callback( Payment Result, Payment Status, Message):* There are couple of sdk status, status message show scurrent status of the SDK and the result is fastpay SDK payment result.

Examples

  1. Initiate payment in init method of your React Native project's App.js:
import PackageStackNavigator from 'fastpay-react-package' 
        <Stack.Screen
          name="Package"
          component={PackageStackNavigator}
          options={{headerShown: false}}
        />
/*  
* 
* Add this code on init method in other page
*/

import startFunction from 'fastpay-react-package/FastPayCons';
import UrlParse from 'url-parse';
const instantiateFastPaySDK = () => {
    const values = {
      storeId: '749315_520',
      storePassword: 'Password100@',
      orderId: `Order123`,
      amount: 300,
      currency: {code: 'IQD'},
      uri_ios: 'appfpclientTestThePack',
      uri_android: 'sdk://fastpay-sdk.com/callback',
      callback: callbackFunction,
    };
  };
  1. Start the journey by navigating the app to the SDK:
/*  
* 
* Use this code to navigate to React Native SDK
*/
    startFunction({
      navigate: (screenName, params) => {
        navigation.navigate('Package', {
          screen: screenName,
          params: params,
        });
      },
      values,
      environment: 'Sandbox',
    });

SDK callback Uri

//Using url-parse
import UrlParse from 'url-parse';
useEffect(() => {
    const handleOpenURL = event => {
      console.log('Received URL:', event.url);
      const parsedUrl = new UrlParse(event.url, true);
      const params = parsedUrl.query;
      const {
        transactionStatus,
        transactionId,
        orderId,
        amount,
        currency,
        customerMobileNo,
        customerName,
        status,
        transactionTime,
      } = params;
      console.log('Received URL:', event.url);
      console.log('Transaction Status:', transactionStatus);
      console.log('Transaction ID:', transactionId);
      console.log('Order ID:', orderId);
      console.log('Amount:', amount);
      console.log('Currency:', currency);
      console.log('Customer Mobile No:', customerMobileNo);
      console.log('Customer Name:', customerName);
      console.log('Status:', status);
      console.log('Transaction Time:', transactionTime);
    };

    const handleOpenURLListener = Linking.addEventListener(
      'url',
      handleOpenURL,
    );

    Linking.getInitialURL().then(url => {
      console.log('Received URL:', url);
      if (url) {
        handleOpenURL({url});
      }
    });

    return () => {
      handleOpenURLListener.remove();
    };
  }, []);

Android setup

Add the callback uri to the AndroidManifest file as shown below.

<application
    <activity
        android:name=".MainActivity"...>
        ...
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <data android:scheme="sdk" android:host="fastpay-sdk.com" android:pathPrefix="/callback"/>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
        ...
    </activity>
      ...
</application>

IOS setup

Add the callback uri to the manifest file as shown below.

  • Create URI Create a URI with a unique name (our suggestion is to provide your app name with prefix text "appfpclient", for example, if your app name is "FaceLook", your URI should be appfpclientFaceLook)
  • Add URI to your info.plist Now add this URI to your app info.plist file
  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLSchemes</key>
      <array>
    < string>appfpclientFastpayReactNativeSdk</string>
      </array>
    </dict>
  </array>
  • Add URI to your AppDelegate.mm Now add this URI to your app info.plist file
  #import <React/RCTLinkingManager.h>

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
    options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [RCTLinkingManager application:application openURL:url options:options];
}

When FastPayRequest call open FastPay SDK then after payment return FastpayResult that contains:

Payment Result

event.url contains these params:

  • status : Payment status weather it is success / failed.
  • transactionId : If payment is successful then a transaction id will be available.
  • orderId : Unique Order ID/Bill number for the transaction which was passed at initiation time.
  • amount : Payment amount for the transaction. "1000"
  • currency : Payment currency for the transaction. (IQD)
  • customerName : Payee name for a successful transaction.
  • customerMobileNo : Number: Payee name for a successful transaction.
  • transactionTime : Payment occurrence time as the timestamp.

Callback Uri via app deeplinks results.

callback URI pattern (SUCCESS): sdk://your.website.com/further/paths?status=success&transaction_id=XXXX&order_id=XXXX&amount=XXX&currency=XXX&mobile_number=XXXXXX&time=XXXX&name=XXXX
callback URI pattern (FAILED): sdk://your.website.com/further/paths?status=failed&order_id=XXXXX