MediaWiki fundraising/REL1_35
conversion_log.body.php
Go to the documentation of this file.
1<?php
2
3use SmashPig\PaymentData\ValidationAction;
4
6
7 protected static $instance;
8
13 protected function post_process() {
14 // if the trxn has been outright rejected, log it
15 if ( $this->gateway_adapter->getValidationAction() == ValidationAction::REJECT ) {
16 $this->log(
17 $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Rejected'
18 );
19 return true;
20 }
21
22 $response = $this->gateway_adapter->getTransactionResponse();
23 // make sure the response property has been set (signifying a transaction has been made)
24 if ( !$response ) {
25 return false;
26 }
27
28 $responseData = $response->getData();
29 if ( isset( $responseData['cardNumber'] ) ) {
30 unset( $responseData['cardNumber'] );
31 }
32 if ( isset( $responseData['expiryDate'] ) ) {
33 unset( $responseData['expiryDate'] );
34 }
35 $this->log(
36 $this->gateway_adapter->getData_Unstaged_Escaped(
37 'contribution_tracking_id'
38 ),
39 "Gateway response: " . addslashes(
40 $response->getTxnMessage()
41 ), '"' . addslashes( json_encode( $responseData ) ) . '"'
42 );
43 return true;
44 }
45
46 public static function onPostProcess( GatewayType $gateway_adapter ) {
47 if ( !$gateway_adapter->getGlobal( 'EnableConversionLog' ) ) {
48 return true;
49 }
50 $gateway_adapter->debugarray[] = 'conversion log onPostProcess!';
51 return self::singleton( $gateway_adapter )->post_process();
52 }
53
54 protected static function singleton( GatewayType $gateway_adapter ) {
55 if ( !self::$instance ) {
56 self::$instance = new self( $gateway_adapter );
57 }
58 return self::$instance;
59 }
60
61}
static singleton(GatewayType $gateway_adapter)
post_process()
Logs the response from a transaction.
static onPostProcess(GatewayType $gateway_adapter)
An abstract class for gateway 'extras'.
GatewayType $gateway_adapter
log( $id='', $status='', $data='', $log_level=LogLevel::INFO)
Writes message to the log.
GatewayType Interface.
static getGlobal( $varname)
This function is important.