1
2
3
<script src="https://paycchainmerchant.netlify.app/sdk/paycchainSDK.js"></script>
1
2
3
npm install paycchain-button
1
2
3
import PaycchainButton from "paycchain-button/dist/components/PaycchainButton";
1
2
3
4
5
6
7
8
9
10
11
12
13
<div id="paycchain-button-container">
<script>
paycchain.button(
"paycchain-button-container",
{
amount: 1,
apiKey: "YOUR_API_KEY",
}
);
</script>
</div>
1
2
3
4
5
6
7
8
9
<PaycchainButton
orderRequest={{
amount: 1,
apiKey:
"YOUR_API_KEY",
}}
/>
elementId
string
paycchain-button-container
in this example.amount
number
USD
.taxAmount
number
0
USD
.apiKey
string
API_KEY
, can be retrieved from your dashboard in Integration section.items
Array
[]
Item Object
, used purely for display information of items purchased by customer in confirmation, Optional.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
<div id="paycchain-button-container">
<script>
paycchain.button(
"paycchain-button-container",
{
items: [
{
name: "Iphone-X",
price: 0.1,
quantity: 1,
product_id: "1122357",
},
{
name: "OnePlus-8",
price: 0.1,
quantity: 1,
product_id: "1122352",
},
{
name: "Iphone-8",
price: 0.4,
quantity: 2,
product_id: "1122351",
},
],
amount: 1,
apiKey:"YOUR_API_KEY"
}
);
</script>
</div>
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
<PaycchainButton
orderRequest={{
items: [
{
name: "Iphone-X",
price: 0.1,
quantity: 1,
product_id: "1122357",
},
{
name: "OnePlus-8",
price: 0.1,
quantity: 1,
product_id: "1122352",
},
{
name: "Iphone-8",
price: 0.4,
quantity: 2,
product_id: "1122351",
},
],
amount: 1,
apiKey:
"YOUR_API_KEY",
}}
/>
Items field is an option of your choice to provide. It consists a list of item Object
. It's only used for displaying the order details to customer and for you to track which product was purchased by customer. Prices in items will not be used for actual payment amount, they are only used for your own purpose. If not provided, your store name and amount to be paid will be showed in confirmation page.
name
string
price
number
product_id
string
product_id
for you to later track on which product was being purchased.quantity
number
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
<div id="paycchain-button-container">
<script>
paycchain.button(
"paycchain-button-container",
{
items: [
{
name: "Iphone-X",
price: 0.1,
quantity: 1,
product_id: "1122357",
},
{
name: "OnePlus-8",
price: 0.1,
quantity: 1,
product_id: "1122352",
},
{
name: "Iphone-8",
price: 0.4,
quantity: 2,
product_id: "1122351",
},
],
amount: 1,
apiKey:"YOUR_API_KEY"
},
{
onApprove: function (data) {
console.log(data);
console.log("order approved");
alert("Filled! blockHash: " + data.result.tx.transactionHash);
},
onCancel: function (data) {
console.log(data);
console.log("order cancelled");
alert("order cancelled");
},
onError: function (data) {
console.log(data);
console.log("order error");
alert("order failed");
},
}
);
</script>
</div>
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
<PaycchainButton
orderRequest={{
items: [
{
name: "Iphone-X",
price: 0.1,
quantity: 1,
product_id: "1122357",
},
{
name: "OnePlus-8",
price: 0.1,
quantity: 1,
product_id: "1122352",
},
{
name: "Iphone-8",
price: 0.4,
quantity: 2,
product_id: "1122351",
},
],
amount: 1,
apiKey:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjaGFudCI6IjYyZTg1MjU3YmNkMDM5MDAyMzc1NzEzZCIsImNyZWF0ZWRBdCI6MTY1OTM5MjU5OTAzNywiaWF0IjoxNjU5MzkyOTM0LCJleHAiOjE2OTA5Mjg5MzR9.SgNxmzuejjk3vQjBTp0auo9snfrI2N_lnqo54gCo3gg",
}}
handlers={{
onApprove: function (data) {
console.log("order approved");
console.log(data);
alert("Filled! blockHash: " + data.tx.transactionHash);
},
onCancel: function (data) {
console.log(data);
console.log("order cancelled");
alert("order cancelled");
},
onError: function (data) {
console.log(data);
console.log("order error");
alert("order failed");
},
}}
/>
Promise returning the order details, transaction hash and status in an Object
to let your site know the transaction is successful. The method is called after the buyer approves the transaction onpaycchain.com
.
When a customer cancels a payment, they typically return to the parent page. You can instead use the onCancel function to show a cancellation page or return to the shopping cart.
onError(Object)If an error prevents customer checkout, alert the user that an error has occurred with the buttons using the onError
callback:
items
array
status
string
Filled
,Failed
.tx
object
transactionHash
you can use to track the transaction on corresponding block chain.