mt_ecommerce
v1.3.4
Published
MoneyTransfer library to connect your web store to payment API
Downloads
21
Maintainers
Readme
Money Transfer: Ecommerce Library
Integrate your website with money transfer API
Install
npm i mt_ecommerce
Usage
Using npm
// React
// Function Component
import React from 'react'
import { moneyTransfer } from 'mt_ecommerce'
const CheckoutCart = ({total, items}) => {
React.useEffect(() => {
moneyTransfer.init('ID_CONTAINER_ELEMENT', total, userCellphone, ownerCellphone)
}, [])
return (
<>
{items.map(item => (
<DetailItem item={item}/>
))}
// This is where the money transfer button will render
<div id="ID_CONTAINER_ELEMENT"></div>
</>
)
}
// Class Component
import React from 'react'
import { moneyTransfer } from 'mt_ecommerce'
class Checkout extends React.Component {
componentDidMount() {
moneyTransfer.init('ID_CONTAINER_ELEMENT', this.props.total, this.props.userCellphone, this.props.ownerCellphone)
}
render() {
return (
<>
{this.props.items.map(item => (
<DetailItem item={item}/>
))}
// This is where the money transfer button will render
<div id="ID_CONTAINER_ELEMENT"></div>
</>
)
}
}
Using CDN
Insert this in your index.html
<script src="https://unpkg.com/[email protected]/index.min.js"></script>
Then in your javascript file you will have to create an instance using MoneyTransfer
const mt = new MoneyTransfer()
mt.init('ID_CONTAINER_ELEMENT', total, userCellphone, ownerCellphone)