-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
51 lines (47 loc) · 1.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { Component } from "react";
import RazorPay from "./src/app";
import axios from "axios";
class Cart extends Component {
state = {
orderId: ""
};
componentDidMount() {
// This will generate the Order Id
axios({
method: "POST",
url: "https://api.razorpay.com/v1/orders",
headers: {
"content-type": "application/json",
Authorization: "Basic YOUR_AUTH_CODE" // Generate your Auth code by using key id and key secret in postman
},
data: JSON.stringify({
amount: 100,
currency: "INR",
receipt: "receipt81",
payment_capture: 1
})
})
.then(res => {
console.warn(res);
this.setState({
orderId: res.data.id // Extracting the OrderId from razorpay response data
});
})
.catch(err => {
console.warn(err);
});
}
render() {
return (
<RazorPay
amount={100}
name="MrRoom" // The Company name will appear on the payment page
contact_name="Ali" // Payer name
email="irizviali@gmail.com" // Payer email id
contact="XXXXXXXXXXX" // Payer mobile Number
orderId={this.state.orderId}
/>
);
}
}
export default Cart;