Socket
Book a DemoInstallSign in
Socket

@adrianha/react-native-midtrans

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adrianha/react-native-midtrans

Unofficial Midtrans SDK for React Native

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

@adrianha/react-native-midtrans

Getting started

$ npm install @adrianha/react-native-midtrans --save

Mostly automatic installation

$ react-native link @adrianha/react-native-midtrans

Manual installation

iOS using Cocoapods

  • Add pod 'ReactNativeMidtrans', :path => '../node_modules/@adrianha/react-native-midtrans' on your Podfile
  • Run pod install
  • Run your project (Cmd+R)

iOS

  • In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  • Go to node_modules@adrianha/react-native-midtrans and add ReactNativeMidtrans.xcodeproj
  • In XCode, in the project navigator, select your project. Add libReactNativeMidtrans.a to your project's Build PhasesLink Binary With Libraries
  • Run your project (Cmd+R)

Android

  • Open up android/build.gradle
  • Add maven { url "http://dl.bintray.com/pt-midtrans/maven" } on allproject.repositories scope
  • Add maven { url "https://jitpack.io" } on allproject.repositories scope
  • Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.adrianha.midtrans.ReactNativeMidtransPackage; to the imports at the top of the file
  • Add new ReactNativeMidtransPackage() to the list returned by the getPackages() method
  • Append the following lines to android/settings.gradle:
    include ':@adrianha/react-native-midtrans'
    project(':@adrianha/react-native-midtrans').projectDir = new File(rootProject.projectDir, 	'../node_modules/@adrianha/react-native-midtrans/android')
    
  • Insert the following lines inside the dependencies block in android/app/build.gradle:
    implementation project(':@adrianha/react-native-midtrans')
    

Usage

  • Create Midtrans instance
import Midtrans from '@adrianha/react-native-midtrans';

const midtrans = new Midtrans({
  clientKey: 'CLIENT_KEY',
  baseUrl: 'BASE_URL',

  /** iOS only: Midtrans.ENVIRONMENT_SANDBOX | Midtrans.ENVIRONMENT_PRODUCTION */
  environment: Midtrans.ENVIRONMENT_SANDBOX,

  /** android only */
  colorTheme: {
    primaryColor: '#000000',
  },
});
  • Pay with SNAP token
try {
  const result = await midtrans.startPaymentWithSnapToken('SNAP_TOKEN');
  console.log({ result });
} catch (e) {
  console.log(e);
}

Keywords

react-native

FAQs

Package last updated on 21 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.