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

cordova-plugin-elepay

v1.0.1

Published

Cordova plugin for elepay SDK

Downloads

15

Readme

elepay-cordova

Cordova plugin for elepay SDK.

Install

cordova plugin add cordova-plugin-elepay

This plugin only wraps basic elepay native SDK(iOS/Android). As native elepay SDK(iOS/Android) may require individual dependences as the used payment methods, please refer to the offical guide for details.

iOS

The native SDK requires iOS 10 and above. Please make sure both your project and Podfile settings are correct.

Android

Cordova plugin for elepay SDK requires "minSdkVersion" being at 21 or above. You may need to adjust this value from your project's build.gradle file.

Usage

// All modules are exported to the `cordova.plugins.ElepayCordova`

// Setup elepay SDK.
//
// The parameter object could contain the following fields:
// "publicKey": String value. Required. Can be retrieved from your elepay account's dashboard page.
// "hostUrl": String value. Optional. Indicates the server url that you want to customised. Omitted to use elepay's server.
// "googlePayEnvironment": String value. "test" or "production". Used to setup Google Pay, can be omitted if Google Pay is not used.
// "languageKey": String value. Availabile values are "English", "SimplifiedChinise", "TraditionalChinese" and "Japanese". Could be omitted. elepay SDK will try to use the system language settings, and fallback to "English" if no supported languages are found.
cordova.plugins.ElepayCordova.initElepay({
  publicKey: "the public key string",
  apiUrl: "a customised url string, can be omitted",
  googlePayEnvironment: "either 'test' or 'product' if presented. Can be omitted if Google Pay is not used",
  languageKey: "one of 'English', 'SimplifiedChinise', 'TraditionalChinese', 'Janapese'. Can be omitted."
})

// Change localization of elepay UI component.
//
// Currently elepay SDK supports the following 4 languages:
//  * English
//  * Simplified Chinese
//  * Traditional Chinese
//  * Japanese
//
// Note: this method should be called **AFTER** `initElepay` and before `handlePayment`.
// Any invoking before `initELepay` won't work. But this method only required being called once.
cordova.plugins.ElepayCordova.changeLanguage({
    languageKey: 'Japanese'
});

// Process payment after charging.
//
// "payload" is a JSON object that the charge API returned. For API details, please refer to https://developer.elepay.io/reference
//
// The result is passed through the callbacks.
// The first callback is called when the payment handling is succeeded. The "response" parameter is a JSON object in a structure of:
// {
//   "state": "succeeded",
//   "paymentId": "the payment id"
// }
//
// The second callback is called when the payment handling is either cancelled or failed.
// When user cancelled the payment, the "failure" parameter is:
// {
//   "state": "cancelled",
//   "paymentId": "the payment id"
// }
// When something is wrong while processing the payment, the parameter is in a structure of:
// {
//   "state": "cancelled",
//   "paymentId": "the payment id",
//   "error": {
//     "code": "error code"
//     "reasose": "the reason of the error"
//     "message": "the detail message"
//   }
// }
cordova.plugins.ElepayCordova.handlePayment(
  payload,
  function(response) {
      // Called when payment is handled successfully.
  },
  function(failure) {
      // Called when payment handling is failed or cancelled.
  })

Callback

Some payment methods(like Line Pay, PayPay, etc.) require to process the payment out of your app. You need to setup the app with extras configurations. Please refer to the payment method settings overview page for detail.

iOS

Your app needs to be configured with URL scheme and LSApplicationQueriesSchemes. For detail configurations, please refere to elepay iOS SDK document

As the cordova's offical document suggested, in your app's JavaScript source file, add the following code to let Cordova framework invokes the callback.

function handleOpenURL(url) {
    setTimeout(function () {
        cordova.plugins.ElepayCordova.handleOpenUrl(url);
    }, 0);
}

Android

Url schemes configurations are required. Please refer to the payment method settings overview page for detail.

Miscellaneous

  1. Some payment methods may require special configs on your project. Please be sure you have read the document of elepay iOS/Android SDK.
  1. If you see the building error indicating that "SWIFT_VERSION" is missing when building for iOS, you should change the configuration of the iOS project by specifying the SWIFT_VERSION item. The configuration item can be found in the "Build Settings" tab of your iOS project if you open the project from Xcode.

  2. Because elepay SDK uses AndroidX internally, the callback Activitys uses themes defined from Theme.AppCompat. If your application has not defined themes inheriting from Theme.AppCompat, you need to add definations to the styles.xml file of your project in android platform folder and use it as the theme of the callback Activitys. Take LinePay callback Activity as example:

    <!-- in styles.xml -->
    <!-- Elepay activity theme. -->
    <style name="ElepayTheme" parent="Theme.AppCompat.Light.NoActionBar">
    </style>
<!-- in AndroidManifest.xml -->
<activity android:exported="true" android:name="jp.elestyle.androidapp.elepay.activity.linepay.LinePayActivity" android:theme="@style/ElepayTheme">
...
</activity>