-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathclass-paystack-plugin-tracker.php
42 lines (31 loc) · 1.09 KB
/
class-paystack-plugin-tracker.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
<?php
// Add a prefix to this class name to avoid conflict with other plugins
class pmpro_paystack_plugin_tracker {
var $public_key;
var $plugin_name;
function __construct($plugin, $pk){
//configure plugin name
//configure public key
$this->plugin_name = $plugin;
$this->public_key = $pk;
}
function log_transaction_success($trx_ref){
//send reference to logger along with plugin name and public key
$url = "https://plugin-tracker.paystackintegrations.com/log/charge_success";
$fields = [
'plugin_name' => $this->plugin_name,
'transaction_reference' => $trx_ref,
'public_key' => $this->public_key
];
$fields_string = http_build_query($fields);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
// echo $result;
}
}
?>