forked from razorpay/razorpay-whmcs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
razorpay.php
executable file
·80 lines (67 loc) · 3.1 KB
/
razorpay.php
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
function razorpay_config() {
$configarray = array(
"FriendlyName" => array("Type" => "System", "Value" => "Razorpay (Credit Card/Debit Card/Net Banking)"),
"KeyId" => array("FriendlyName" => "Key Id", "Type" => "text", "Size" => "50", "Description" => "Enter your Razorpay Key Id here",),
"KeySecret" => array("FriendlyName" => "Key Secret", "Type" => "text", "Size" => "50", "Description" => "Enter your Razorpay Key Secret here",),
);
return $configarray;
}
function razorpay_link($params) {
# Gateway Specific Variables
$key_id = $params['KeyId'];
$key_secret = $params['KeySecret'];
# Invoice Variables
$order_id = $params['invoiceid'];
$description = $params["description"];
$amount = $params['amount']*100;
$currency = $params['currency'];
# Client Variables
$customer_name = $params['clientdetails']['firstname']." ".$params['clientdetails']['lastname'];
$customer_email = $params['clientdetails']['email'];
$customer_phone = $params['clientdetails']['phonenumber'];
# System Variables
$name = $params['companyname'];
$companyname = 'razorpay';
$checkoutURL = 'https://checkout.razorpay.com/v1/checkout.js';
$callbackURL = $params['systemurl'].'/modules/gateways/callback/razorpay.php';
$html = '<form name="razorpay-form" id="razorpay-form" action="'.$callbackURL.'" method="POST" onSubmit="if(!razorpay_open) razorpaySubmit(); return razorpay_submit;">
<input type="hidden" name="razorpay_payment_id" id="razorpay_payment_id" />
<input type="hidden" name="merchant_order_id" id="order_id" value="'.$order_id.'"/>
<input type="button" value="Click Here to Pay" onClick="razorpaySubmit()"/>
</form>';
$js = '<script src="'.$checkoutURL.'"></script>';
$js .= "<script>
var razorpay_open = false;
var razorpay_submit = false;
var razorpay_options = {
'key': '".$key_id."',
'amount': '".$amount."',
'currency': '".$currency."',
'name': '".$name."',
'description': '".$description."',
'handler': function (transaction) {
razorpay_submit = true;
document.getElementById('razorpay_payment_id').value = transaction.razorpay_payment_id;
document.getElementById('razorpay-form').submit();
},
'prefill': {
'name': '".$customer_name."',
'email': '".$customer_email."',
'contact': '".$customer_phone."'
},
notes: {
'whmcs_order_id': '".$order_id."'
},
netbanking: true
};
function razorpaySubmit(){
var rzp1 = new Razorpay(razorpay_options);
rzp1.open();
razorpay_open = true;
rzp1.modal.options.backdropClose = false;
}
</script>";
return $html.$js;
}
?>