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

rave-cordova-sdk

v1.0.1

Published

Cordova extension to add Rave Pay Button into your Cordova app builds

Downloads

3

Readme

Cordova Rave

This Cordova extension let's you add Rave Pay Button into your Cordova/Phonegap apps builds.

Installation

The Rave Cordova extension adds support for spinning up the Rave modal on IOS and Android. It uses the Rave Standard endpoint and has done all the hard work for you. All you need to is add the necessary file and call the appropriate functions.

  1. Follow the official Rave documentation on how to create an account if you don't have one yet.
  2. Create a dummy project. For example cordova create RaveTest com.test.ravetest "RaveTest"
  3. Install the sdk and add platforms
$ cd RaveTest
$ npm install --save rave-cordova-sdk
$ cd node_modules/rave-cordova-sdk
$ npm start - installs the necessary dependencies and injects a file ```rave.js``` in www/js
# go back to your project folder
$ cordova platform add ios
$ cordova platform add android
  1. See App Integration below

App Integration

<script type="text/javascript" src="js/rave.js"></script>

The Rave Cordova extension exposes a class Rave. You can create an instance of Rave by passing in your public key and a boolean true or false specifying whether you want to be live or on staging. See example below

var rave = new Rave("YOUR_PUBLIC_KEY", false)

Now that you've done that, you can now call its methods

  1. init(payload) - This method creates a payment object for you. However, you must pass in an object containing the necesssary payment details. Go here for details on what parameters to have in the object. A sample init(payload) call is shown below.
var payment_obj = rave.init({
    customer_email: "[email protected]",
    amount: 10,
    customer_phone: "234099940409",
    currency: "NGN",
    txref: "MD-10000",
    meta: [{
        metaname: "flightID",
        metavalue: "AP1234"
    }]
})

Depending on whether the payload you passed in is correct or not, payment_obj would hold your valid payload or an error object if any issue is found.

**HINT: customer_email, amount, customer_phone, txref and the public key you passed when creating the instace of Rave are all compulsory. Omitting any one of them would result in and error object being returned instead of your payload.

  1. preRender(payment_obj, callback) - This method gets a secure link which you can then use to spin up the Rave modal with your payment details. The secure link can be accessed by the callback function you passed in (See Example below). In case you didn't call init(payload) before calling this method, An error will be returned instead of a secure link. An example is shown below
rave.preRender(payment_obj, function(err, link) {
    if(err) console.log(`error: ${err}`)
    // open up link
})
  1. render(link) - All this method does is spin up the Rave modal in your inappbrowser. The only parameter it requires is the secure link that the preRender method got for you. A sample call is shown below. Note that this method should be called inside the preRender callback
rave.preRender(payment_obj, function(err, link) {
    if(err) console.log(`error: ${err}`)
    rave.render(link)
})

Calling the render() method is optional. You can just handle the secure link the way you want.

Basic Example of the App

  1. A complete example code can be checked here
  2. In /www/index.html add the following lines after <div id="deviceready" class="blink"><p class="event listening">Connecting to Device</p> <p class="event received">Device is Ready</p></div>
<button class="btn btn-primary" type="button" onclick="pay()">Pay Now</button>
  1. Still in /www/index.html add the following lines after <script type="text/javascript" src="js/rave.js"></script>
<script>
    var rave = new Rave("REPLACE_WITH_YOUR_PUBLIC_KEY", true)
    function pay(){
        var payment_obj = rave.init({
            customer_email: "[email protected]",
            amount: 10,
            customer_phone: "234099940409",
            currency: "NGN",
            txref: "MD-10000",
            meta: [{
                metaname: "flightID",
                metavalue: "AP1234"
            }]
        })
    
        rave.preRender(payment_obj, function(err, link) {
            if(err) console.log(`error: ${err}`)
            rave.render(link)
        })
    }
</script>
  1. Add the Cordova InAppBrowser plugin. Read more about it here
cordova plugin add cordova-plugin-inappbrowser
  1. In /www/js/index.js, add this line to the onDeviceReady function
window.open = cordova.InAppBrowser.open;
  1. Add <allow-navigation href="*" /> to your config.xml file

  2. Replace the Content-Security-Policy meta tag in /www/index.html with this one:

<meta http-equiv="Content-Security-Policy" content="font-src 'self' data:; img-src * data:; default-src gap://ready file://* *; script-src 'self' 'unsafe-inline' 'unsafe-eval' * ; style-src 'self' 'unsafe-inline' *">
  1. Excecute cordova run browser or cordova run android. To deploy to the ios simulator, follow steps here

License

Released under MIT License

Contributions

Pull requests and new issues are welcome. See CONTRIBUTING.md for details.