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-inai-sdk

v0.1.12

Published

React Native Wrapper for Inai Checkout

Downloads

5

Readme

react-native-inai-sdk

React Native Wrapper for Inai Checkout SDK

Installation

npm install react-native-inai-sdk --save

Initialization

Inai Checkout has different methods that can be used to execute different types of operations related to payments. Let's discuss them in detail. Import the InaiCheckout as given below:


import  InaiCheckout  from  "react-native-inai-sdk";

Config Parameters

InaiConfig object is required to be passed onto the interfaces. InaiConfig takes the following parameters.

| Variables | Description | | :-------- | :-------------------------------------------------------------------------------------------- | | token | The client username can be obtained from the dashboard: Settings > Credentials | | orderId | The orderId refers to the inai order created by the merchant backend. | | countryCode | The countryCode should be specified as an ISO 3166-1 alpha-3 country code. | | styles | The optional styles object can be used to customize various UI elements on the checkout page. | | locale | This adds localization to the SDK method that is being called. e.g "en" for English, "fr" for french. |


  let styles = {
    container: { backgroundColor: "#fff" },
    cta: { backgroundColor: "#123456" },
    errorText: { color: "#000000" }
  };

 let inaiConfig = {
    token: "token",
    orderId: "orderId",
    countryCode: "countryCode",
    styles: styles,
    locale: locale
  };  
  

Drop-In Checkout

Present Checkout

Inai Checkout presents the customer with a list of configured payment method options for the country of checkout.


InaiCheckout.presentCheckout(inaiConfig).then((response) => {
    // Handle Success
}).catch((err) => {
    // Handle Failure
});

Present Add Payment Method

The addPaymentMethod interface presents the customers a view with a list of configured payment method options for the country of checkout which enables them to save it. Once saved, payment_method_id that gets returned from the addPaymentMethod call can be used for subsequent payments eliminating the need for the customer to re-enter the payment details for each payment request.


InaiCheckout.addPaymentMethod(inaiConfig, "card").then((response) => {
  // Handle Success
  // Store response["payment_method_id"] 
}).catch((err) => {
  // Handle Failure
});
  

Present Pay with Saved Payment Method

When a customer has saved a payment method, the payment_method_id of the same can be used to invoke the presentPayWithPaymentMethod interface. This enables the customers to leverage saved payment_method_ids for faster checkout.


InaiCheckout.payWithPaymentMethod(inaiConfig, <paymentMethodId>).then((response) => {
  // Handle Success
}).catch((err) => {
  // Handle Failure
});

For additional information regarding Drop-In Checkout, please check the link.

Headless Checkout

Validate Fields

This interface is used to validate payment details entered by the customer.

validateFields takes 3 parameters -

  • inaiConfig represents the inaiConfig object that we declared initially
  • paymentMethodOption represents the payment method option the user chose to complete the payment.
  • paymentDetails represents the payment details that are required to complete the payment for the payment method option specified. For Payment Method Options with empty form_fields, this must be set as an empty object {} A promise will be returned that will resolve or reject based on the input validation or payment status. Appropriate success/error messages can be presented to the customer based on the response.
let paymentMethodOption = "card"

let paymentDetails = {
  "fields": [{
    "name": "number",
    "value": "5123456789012346"
  },{
    "name": "cvc",
    "value": "123"
  },{
    "name": "expiry",
    "value": "12/25"
  },{
    "name": "holder_name",
    "value": "John Doe"
  },{
    "name": "contact_number",
    "value": "01010101010"
  },{
    "name": "first_name",
    "value": "John"
  },{
    "name": "last_name",
    "value": "Doe"
  },{
    "name": "contact_email",
    "value": "[email protected]"
  }]
}

InaiCheckout.validateFields(inaiConfig, paymentMethodOption, paymentDetails
).then((response) => {
  // Handle Success
}).catch((err) => {
  // Handle Failure
});

Make Payment

This interface is used to do headless payments.

makePayment takes 3 parameters -

  • inaiConfig represents the inaiConfig object that we declared initially
  • paymentMethodOption represents the payment method option the user chose to complete the payment.
  • paymentDetails represents the payment details that are required to complete the payment for the payment method option specified. For Payment Method Options with empty form_fields, this must be set as an empty object {} A promise will be returned that will resolve or reject based on the input validation or payment status. Appropriate success/error messages can be presented to the customer based on the response.

InaiCheckout.makePayment(inaiConfig, <paymentMethodOption>, paymentDetails).then((response) => {
    // Handle Success
  }).catch((err) => {
    // Handle Failure
  });

For additional information regarding Headless Checkout, please check the link.