Skip to content

Commit 474a02a

Browse files
Merge pull request #50 from tolu-paystack/plugin_tracker_refactor
refactored plugin tracker as a function instead of class
2 parents b7f5c80 + 940b834 commit 474a02a

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

Controller/Payment/Webhook.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public function execute() {
7373

7474

7575
$reference = $transactionDetails->data->reference;
76-
76+
//PSTK_LOGGER HERE
77+
log_transaction_success($reference);
7778
//------------------------
7879
$order = $this->orderInterface->loadByIncrementId($reference);
7980

@@ -110,4 +111,31 @@ public function execute() {
110111
$resultFactory->setContents($finalMessage);
111112
return $resultFactory;
112113
}
114+
115+
function log_transaction_success($trx_ref){
116+
//send reference to logger along with plugin name and public key
117+
$url = "https://plugin-tracker.paystackintegrations.com/log/charge_success";
118+
$plugin_name = 'magento-2';
119+
$public_key = $this->configProvider->getPublicKey();
120+
121+
$fields = [
122+
'plugin_name' => $plugin_name,
123+
'transaction_reference' => $trx_ref,
124+
'public_key' => $public_key
125+
];
126+
127+
$fields_string = http_build_query($fields);
128+
129+
$ch = curl_init();
130+
131+
curl_setopt($ch,CURLOPT_URL, $url);
132+
curl_setopt($ch,CURLOPT_POST, true);
133+
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
134+
135+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
136+
137+
//execute post
138+
$result = curl_exec($ch);
139+
// echo $result;
140+
}
113141
}

0 commit comments

Comments
 (0)