-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipn.php
51 lines (41 loc) · 1.76 KB
/
ipn.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
<?php
// You can get that info by accessing you account at Merchand Services -> IPN Settings -> Generate New Shared Secret
define("IPN_SHARED_KEY","YOUR_SHARED_KEY_HERE");
$rawPostedData = file_get_contents('php://input');
// Extracting Field=Value Pairs
$i = strpos($rawPostedData, "&key=");
$fieldValuePairsData = substr($rawPostedData, 0, $i);
// Calculating Key (Notification Signature)
$calculatedKey = md5($fieldValuePairsData . IPN_SHARED_KEY);
// Verifying Notification Key (Signature)
$isValid = $_POST["key"] == $calculatedKey ? true : false;
if(!$isValid)
{
//Invalid POST request, we are closing the script execution.
die;
}
// These are all the details provided in the POST variables from paxum
$buyer_email = $_POST["buyer_email"];
$buyer_username = $_POST["buyer_username"];
$buyer_name = $_POST["buyer_name"];
$buyer_id = $_POST["buyer_id"];
$buyer_status = $_POST["buyer_status"];
$resend = $_POST["resend"];
$test = $_POST["test"];
$transaction_id = $_POST["transaction_id"];
$transaction_amount = $_POST["transaction_amount"];
$transaction_status = $_POST["transaction_status"];
$transaction_description = $_POST["transaction_description"];
$transaction_item_id = $_POST["transaction_item_id"];
$transaction_item_name = $_POST["transaction_item_name"];
$transaction_exchange_rate = $_POST["transaction_exchange_rate"];
$transaction_currency = $_POST["transaction_currency"];
$transaction_date = $_POST["transaction_date"];
$transaction_type = $_POST["transaction_type"];
$transaction_quantity = $_POST["transaction_quantity"];
$reference = $_POST["reference"];
if($transaction_status == "done") {
// Transaction is complete, do whatever you want with the given information
}else{
// Transaction is not complete, do whatever you want with the given information
}