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-opanet-http-over-ussd

v1.0.16

Published

Send Http request over USSD

Downloads

194

Readme

react-native-opanet-http-over-ussd

  1. Enable Mobile Applications (Android) to securely send Http Request real-time without internet access.
  2. Receive mobile payments real-time without a centralized payment gateway, making payments faster, more secure and convenient, with lower transaction charges.

Poor internet service in rural areas (emerging markets) makes IOS & Android Apps not reliable. USSD Menus provides a solution however, USSD menus are unable to leverage the rich user experience that Smart phones offer.

Opanet Android SDKs enable developers to leverage the connectivity of USSD and the rich user experience of Smart phones.

1. Installation

npm install react-native-opanet-http-over-ussd

2. Link native-module

Add the following to settings.gradle (Android folder)

include ':app',':react-native-opanet-http-over-ussd'

Add the following to build.gradle (android/app folder)

implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.0.0")
implementation fileTree(dir: "../../node_modules/react-native-opanet-http-over-ussd/android/build/outputs/aar", include: ["*.aar"])

Add the OpanetHttpOverUssdPackage to PackageList in MainApplication (android/app/src/main folder)

// ... Java ...
import com.opanethttpoverussd.OpanetHttpOverUssdPackage;
//
Listpackages = new PackageList(this).getPackages();
packages.add(new OpanetHttpOverUssdPackage());
// ... Kotlin ...
import com.opanethttpoverussd.OpanetHttpOverUssdPackage
//
PackageList(this).packages.apply {
add(OpanetHttpOverUssdPackage())
}

3. Configure AndroidManifest

Add the following permissions to AndroidManifest (android/app/src/main folder)

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />

Add the following to AndroidManifest (android/app/src/main folder) under application

<service
android:name="com.opanethttpoverussd.USSDService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:exported="false">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" ></action>
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/ussd_service" />
</service>
<service
android:name="com.opanethttpoverussd.OverlayShowingService"
android:exported="false" ></service>
<service
android:name="com.opanethttpoverussd.SplashLoadingService"
android:exported="false" ></service>
<activity
android:name="com.opanethttpoverussd.DialerActivity"
android:launchMode="standard">
</activity>

4. Http Usage

import { http, Pay, PendingCallbacks } from 'react-native-opanet-http-over-ussd';

// ...

http(
"*000#",
{
type:"POST",
url:"https://yourdomain/api",
data:{ myData:"This is my data"},
headers: { "custome-header":"somevalue" }
},
x=>{console.log(x)},
x=>{console.log(x.message)}
);

opanet.send(ussdCode, httpRequest, successHandler, failureHandler) Send HttpRequest.

ussdCode Type: STRING. Ussd code provided by ussd-gateway. HttpRequest Type: OBJECT. HttpRequest Object.

successHandler Type: Function(response). A function to execute when a request is successful. Response is JSON failureHandler Type: Function(response). A function to execute when a request fails.

Limitations

Support only "application/json" content type.
Timeout is 120 seconds
Throughput is 100 bytes/second

5. Mobile Payment Usage

import { http, Pay, PendingCallbacks } from 'react-native-opanet-http-over-ussd';

// ...

<Pay
ussdCode="*000#"
recipient="233241****89"
amount="1.00"
reference="PO012031"
thirdPartyTransactionId="1234567890"
onPaymentSuccess={(x) =>{console.log(x.transactionId)}}
onPaymentFailure={(x)=>{console.log(x.message)}}
onCallbackSuccess={(x)=>{console.log(x.transactionId);}} 
onCallbackFailure={(x)=>{console.log(x.message)}}
/>

Receive payment. A bill prompt is sent to mobile subscriber to enter PIN. Payment notification is sent to your callback Url.

ussdCode Type: STRING. Ussd code provided by ussd-gateway. recipient Type: STRING. Mobile number to receive payment. Payment is made real-time to recipient.

amount Type: FLOAT. Amount to receive.

reference Type: STRING. Reference.

thirdPartyTransactionId Type: STRING. unique id you assign to transaction.

onPaymentSuccess Type: Function(response). A function to execute when a payment is successful.

onPaymentFailure Type: Function(response). A function to execute when a payment fails.

onCallbackSuccess Type: Function(response). A function to execute when your callback Url returns a response.

onCallbackFailure Type: Function(response). A function to execute when your callback Url fails.

Configure callbackUrl(Your endpoint to receive payment notification)

sign-up on Opanet and create a project. The create project form requires you to enter a url to receive payment notification.

Sample payment notification

{
type:"POST",    
url:"https://yourdomain/api",
headers: { 
    opanet_appId:"provided when you created a project",
    opanet_appKey:"provided when you created a project",
    Content-Type:"application/Json"
     },
data:{
    sender:"233548****10", 
    recipient:"233241****89", 
    amount:1.00, 
    reference:"123456789", 
    transactionId:"40958665648"
    }
}

Sample notification response

{
    error:"00", 
    message:"successfull"
}

Pending Callbacks

import { http, Pay, PendingCallbacks } from 'react-native-opanet-http-over-ussd';

// ...

<PendingCallbacks
ussdCode="*000#"
/>

Payment notifications that failed to reach your callback Url. This occurs when your Url is down. Mobile subscriber can click to resend notification.

ussdCode Type: STRING. Ussd code provided by ussd-gateway.

License

MIT