GitXplorerGitXplorer
j

sinpe-react

public
3 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
3c36bef1023436ef0b6f89ce1504a1b20ff787a8

setOrderOptions on separate useEffect

jjonoise committed 3 years ago
Unverified
f5bf089ac63f4c6671fcd85fbfec359afa446d7d

fix href to send sms

jjonoise committed 3 years ago
Unverified
10fb0dcc202880cf3587744d8159b347304a6dc1

update react-sinpe version

jjonoise committed 3 years ago
Unverified
1ef1eb9ba2c7396bccb42543949f952bea77fa9b

v1.0.5 fix sms link

jjonoise committed 3 years ago
Unverified
61ea3a0e7d86c18c5909005ecca96c1c1926325a

fix bug in sms

jjonoise committed 3 years ago
Unverified
efac7addb3f9e1ef2cd91b6b734b195c092465f9

add sinpe-react plugin for donations

jjonoise committed 3 years ago

README

The README file for this repository.

🚨 This package lacks TESTS

🙏 Collaborations are highly appreaciated. Feel free to fork and submit PR's ♥.

⚠🚨 This tools IS in DEVELOPMENT ⚠🚨

This tools is NOT suitable for production.

Sinpe React Component

Banner image with Sinpe-React Logo

What is Sinpe React?

Sinpe-React is a React wrapper around the SINPE Móvil flow to send money via sms. It's just an automation that provide a basic API.

Docs.

Para una versión en español y más detallada ve a la documentación.

Features

  • Send money via sms using Sinpe Móvil (Costa Rica only).
  • Connect to your backend or CMS.
  • User friendly.
  • Styling highly customizable.
  • Written in Typecript.

Quickstart

npm i sinpe-react
--OR
yarn add sinpe-react
import React from 'react';
import SinpeReact from 'sinpe-react';
import "sinpe-react/dist/sinpe-react.cjs.development.css"

function App() {
  const order={"..."}
  const myNumber={"..."}
  return (
   <SinpeReact
    vendorPhoneNumber={myNumber}
    order={order}
   />
  );
}

Using NextJS.

If using NextJS import styles in _app.js file.

// _app.js
import '../styles/globals.css'
import type { AppProps } from 'next/app'

// add this
import 'sinpe-react/dist/sinpe-react.cjs.development.css'

function MyApp({ Component, pageProps }: AppProps) {
  return <Component {...pageProps} />
}
export default MyApp

Custom Styling.

You can add custom styling to both button and modal components using btnClass and modalClass respectively as props of SinpeReact component.

import React from 'react';
import SinpeReact from 'sinpe-react';
import "sinpe-react/dist/sinpe-react.cjs.development.css"

function App() {
  const vendorOptions={"..."}
  const customerOptions={"..."}

  const styles = {
    modalClass: "myModalClass",
    btnClass: "myBtnClass"
  }

  return (
   <SinpeReact
    vendorOptions={vendorOptions}
    customerOptions={customerOptions}
    styles={styles}
   />
  );
}

API

Props Type Required Description
vendorPhoneNumber string The number that receives the transfer.
order object Options related to your customer.
callbackFunction function Fires after customer confirm order receipt number.
redirectUrl string Url you want to redirect the user after the purchase, eg: /thankyou.
styles object Custom stylings classes.

Troubleshooting

Typing error from env variable -> conf: {{api_key: process.env.SINPE_API_KEY}}

When getting an Environment Variable you need to specify the type of value that variable is.

declare var process: {
  env: {
    SINPE_API_KEY: string
  }
}

// and call the conf
conf={api_key:process.env.SINPE_API_KEY}
<SinpeReact conf={conf} />