-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from lukman008/master
added plugin metrics tracker
- Loading branch information
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
paystack/controllers/front/class-paystack-plugin-tracker.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
// Add a prefix to this class name to avoid conflict with other plugins | ||
class presta_1_7_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; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters