@@ -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