React JS
The Ippopay Payments plugin allows you to accept credit card, UPI, Netbanking and debit card payments via Ippopay payment gateway in your React JS.
IppoPay Payment Gateway for your Online Business.
with npm
npm install --save react-ippopay
IppoPay Payment Gateway uses sensible defaults, so only minimal configuration via props is necessary.
How to do configuration in your React Project?
Initialize the Ippopay Payment like below.
import {Ippopay} from 'react-ippopay';
class App extends Component {
state = {
ippopayOpen: false,
order_id:'YOUR_ORDER_ID',
public_key:'YOUR_PUBLIC_KEY'
};
ippopayHandler(e){
if(e.data.status == 'success'){
console.log(e.data)
}
if(e.data.status == 'failure'){
console.log(e.data)
}
}
componentDidUpdate(){
window.addEventListener('message', this.ippopayHandler);
}
ippopayOpen(){
this.setState({ippopayOpen: true});
}
render() {
return (
<div>
<span onClick={e => this.ippopayOpen(e)}>IppoPay</span>
<Ippopay ippopayOpen={this.state.ippopayOpen} ippopayClose={true} order_id={this.state.order_id} public_key={this.state.public_key}
/>
</div>
);
}
}
Create order from Server side using below API and get the Order id. Click here to know how to create a order.
When you click place order button our popup will be loaded so you can use below test card credentials to complete the order.
Card Number 4111 1111 1111 1111
Expiry 05/20
CVV 123
Card Number 4242 4242 4242 4242
Expiry 05/23
CVV 123
React IppoPay default props to provide a dynamic experience to open a payment widget and allow user to make a payment via Credit/Debit Card.
ippopayOpen
- Boolean - toggles the popup open state (see above example)ippopayClose
- Boolean - Enables the popup close option state (see above example)order_id
- String - sets the Order ID as order_id statepublic_key
- String - sets your Public Key as public_key state (Check your API Settings in IppoPay Merchant Panel to know the Public Key)
React IppoPay gives you the handlers for Payment status and details.
After Payment done, the below line sends the Payment details and status to ippopayHandler function.
window.addEventListener('message', this.ippopayHandler);
You can get the Payment status in the below function, it may be success or error.
ippopayHandler(e){
if(e.data.status == 'success'){
console.log(e.data)
}
if(e.data.status == 'failure'){
console.log(e.data)
}
}
Last modified 2yr ago