Home

Awesome

React Native Midtrans Payment gateway example

SNAP Midtrans payment gateway example on client side (this is not the best way to do this, better all the midtrans API processed on a cloud functions for better performance *I think)

Preview

./midtrans.gif

Problems

Unfortunately midtrans npm package not supported for Expo projects

Solutions

I found the way to use snap midtrans payment gateway using their HTTP API, full docs here

SNAP midtrans gives response a url for the payment gateway you can use react-native-webview or open the url on a browser, but I use react-native-webview for better UX 😛

Package used

"dependencies": {
   "base-64": "^1.0.0",
    "expo": "^41.0.0",
    "expo-status-bar": "~1.0.4",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
    "react-native-web": "~0.13.12",
    "react-native-webview": "11.2.3"
}

Transactions

midtrans() to get the payment gateway url

Status

getStatus() to check status of the transaction

if you find these useful don't forget to give it a star ⭐ and share it to your friends ❤️

Reach me on twitter