MediaWiki fundraising/REL1_35
GatewayAdapter Class Reference

GatewayAdapter. More...

Inheritance diagram for GatewayAdapter:
Collaboration diagram for GatewayAdapter:

Public Member Functions

 __construct ( $options=[])
 Constructor.
 
 addRequestData ( $dataArray)
 A helper function to let us stash extra data after the form has been submitted.
 
 addResponseData ( $dataArray)
 Add data from the processor to staged_data and run any unstaging functions.
 
 addStandardMessageFields ( $transaction)
 For making freeform queue messages.
 
 buildOrderIDSources ()
 buildOrderIDSources: Uses the 'alt_locations' array in the order id metadata, to build an array of all possible candidates for order_id.
 
 buildRequestParams ()
 Build the parameters sent with the next request.
 
 calculateKeyMashScore ( $stringToCheck)
 
 cancel ()
 Cancel payment based on adapter and set status to cancelled.
 
 checkTokens ()
 Checks the edit tokens in the user's session against the one gathered from populated form data.
 
 createDonorReturnParams ()
 Takes normalized data and creates adapter specific params for processDonorReturn.
 
 defineDataTransformers ()
 Sets up the $data_transformers array.
 
 definePaymentMethods ()
 Sets up the $payment_methods array.
 
 do_transaction ( $transaction)
 Performs a transaction through the gateway.
 
 finalizeInternalStatus ( $status)
 Sets the final payment status.
 
 findCodeAction ( $transaction, $key, $code)
 findCodeAction
 
 formatStagedData ()
 Format staged data.
 
 generateOrderID ( $dataObj=null)
 Default orderID generation This used to be done in DonationData, but gateways should control the format here.
 
 getAccountConfig ( $key)
 Get globals-based configuration setting.
 
 getAvailableSubmethods ()
 Get metadata for all available submethods, given current method / country TODO: A PaymentMethod should be able to list its child options.
 
 getClientSideValidationRules ()
 Returns an array of rules used to validate data before submission.
 
 getConfig ( $key=null)
 Get settings loaded from adapter's config directory.
 
 getCoreDataTransformers ()
 
 getCurrencies ( $options=[])
 
 getCurrentTransaction ()
 Gets the currently set transaction name.
 
 getData_Unstaged_Escaped ( $val='')
 This is the ONLY getData type function anything should be using outside the adapter.
 
 getDataConstraints ( $field)
 Get any known constraints on the field's value.
 
 getDataSources ()
 
 getDataTransformers ()
 FIXME: Not convinced we need this.
 
 getDonationRules ()
 Add donation rules for the users country & currency combo.
 
 getErrorMap ( $code, $options=[])
 getErrorMap
 
 getErrorMapByCodeAndTranslate ( $code)
 getErrorMapByCodeAndTranslate
 
 getErrorState ()
 Return any errors that prevent this transaction from continuing.
 
 getFinalStatus ()
 If it has been set: returns the final payment status in the $final_status member variable.This is the one we care about for switching on overall behavior. Otherwise, returns false.

Returns
mixed Final Transaction results status, or false if not set. Should be one of the constants defined in
See also
FinalStatus

 
 getFormFields ( $knownData=null)
 Build list of form fields TODO: Determine if this ever needs to be overridden per gateway, or if all the per-country / per-gateway cases can be expressed declaratively in payment method / submethod metadata.
 
 getGatewayAdapterClass ()
 
 getLogDebugJSON ()
 Returns some useful debugging JSON we can append to loglines for increased debugging happiness.
 
 getLogMessagePrefix ()
 Get the log message prefix: $contribution_tracking_id .
 
 getMerchantID ()
 For places that might need the merchant ID outside of the adapter.
 
 getMonthlyConvertAmounts ()
 Add the suggested monthly donation amounts for each donation level according to the currency saved in session for this donation attempt.
 
 getOrderIDMeta ( $key=false)
 Returns information about how to manage the Order ID, either a specific value or the whole associative array.
 
 getPaymentMethod ()
 Get the payment method.
 
 getPaymentMethodMeta ( $payment_method=null)
 Get metadata for the specified payment method as set in.
 
 getPaymentMethods ()
 Define payment methods.
 
 getPaymentSubmethod ()
 Get the name of the currently selected payment submethod.
 
 getPaymentSubmethodMeta ( $payment_submethod=null)
 Get metadata for the specified payment submethod.
 
 getPaymentSubmethods ()
 Get the entire list of payment submethod definitions.
 
 getRequestProcessId ( $requestValues)
 Gateways which return true from isReturnProcessingRequired must override this with logic to get an ID from the request which will identify repeated attempts to process the same payment.
 
 getRequiredFields ( $knownData=null)
 
 getResponseType ()
 Default response type to be the same as communication type.
 
 getScoreCountryMap ()
 This custom filter function checks the global variable:
 
 getScoreEmailDomainMap ()
 This custom filter function checks the global variable:
 
 getScoreName ()
 This custom filter function checks the global variable: wgDonationInterfaceNameFilterRules Each entry in that array has keys KeyMapA, KeyMapB: define keyboard zones GibberishWeight: threshold fraction of name letters in a single zone Score: added to the total fraud score when this threshold is exceeded.
 
 getScoreUtmCampaignMap ()
 This custom filter function checks the global variable:
 
 getScoreUtmMediumMap ()
 This custom filter function checks the global variable:
 
 getScoreUtmSourceMap ()
 This custom filter function checks the global variable:
 
 getTransactionData ()
 Returns the FORMATTED data harvested from the reply, or false if it is not set.
 
 getTransactionMessage ()
 
 getTransactionResponse ()
 Returns the response object with the details of the latest transaction, or null if the adapter has not yet performed one.
 
 getTransactionSpecificValue ( $gateway_field_name)
 This function is used exclusively by the two functions that build requests to be sent directly to external payment gateway servers.
 
 getTransactionStatus ()
 Returns the transaction communication status, or false if not set present.
 
 getValidationAction ()
 Returns the current validation action.
 
 isBatchProcessor ()
 Lets the outside world (particularly filters that accumulate points scores) know if we are a batch processor.
 
 isReturnProcessingRequired ()
 Whether donation processing depends on additional processing on-wiki at the donor's return from a payment processor.
 
 loadConfig ( $variant=null)
 
 localizeGlobal ( $varname)
 Gets a global variable according to.
 
 logFinalStatus ( $status)
 Easily-child-overridable log component of setting the final transaction status, which will only ever be set at the very end of a transaction workflow.
 
 logPending ()
 Dump info about a transaction in logs and pending queues before sending the donor off to complete it.
 
 normalizeOrderID ( $override=null, $dataObj=null)
 This function is meant to be run by the DonationData class, both before and after any communication has been done that might retrieve an order ID.
 
 processDonorReturn ( $requestValues)
 Default implementation sets status to complete.
 
 rectifyOrphan ()
 Looks at message to see if it should be rectified Allows exit if the adapter should not rectify the orphan Then tries to see if the orphan can be matched.
 
 regenerateOrderID ()
 
 runAntifraudFilters ()
 Runs all the fraud filters that have been enabled and configured in donationdata.php and/or LocalSettings.php This function is most likely to be called through executeFunctionIfExists, early on in do_transaction.
 
 sendFinalStatusMessage ( $status)
 Build and send a message to the payments-init queue, once the initial workflow is complete.
 
 session_addDonorData ()
 Removes any old donor data from the session, and adds the current set.
 
 session_ensure ()
 session_ensure Ensure that we have a session set for the current user.
 
 session_getData ( $key, $subkey=null)
 Retrieve data from the session if it's set, and null if it's not.
 
 session_hasDonorData ()
 Checks to see if we have donor data in our session.
 
 session_killAllEverything ()
 This should kill the session as hard as possible.
 
 session_resetForNewAttempt ( $force=false)
 For those times you want to have the user functionally start over without, you know, cutting your entire head off like you do with session_unsetAllData().
 
 session_setDonorBackupData (array $donorData)
 Saves a backup of the Donor Data in session.
 
 session_unsetAllData ()
 Destroys the session completely.
 
 session_unsetDonorData ()
 Unsets the session data, in the case that we've saved it for gateways like GlobalCollect that require it to persist over here through their iframe experience.
 
 setCurrentTransaction ( $transaction_name)
 Sets the transaction you are about to send to the payment gateway.
 
 setHash ( $hashval)
 Set a value used to determine whether data has changed.
 
 setOrderIDMeta ( $key, $value)
 sets more orderID Meta, so we can remember things about what we chose to go with in later logic.
 
 setRiskScore ( $score)
 Set the adapter's fraud score.
 
 setValidationAction ( $action, $reset=false)
 Sets the current validation action.
 
 shouldRectifyOrphan ()
 Allows adapters to specify logic as to whether an orphan can be rectified.
 
 showMonthlyConvert ()
 
 token_getSaltedSessionToken ()
 Establish an 'edit' token to help prevent CSRF, etc.
 
 unsetHash ()
 Clear the data hash value.
 
 unstageKeys ( $processor_data, $key_map=null)
 Change the keys on this data from processor API names to normalized names.
 
 validate ()
 Check donation data for validity and set errors.
 
 validatedOK ()
 
- Public Member Functions inherited from GatewayType
 doPayment ()
 Attempt the default transaction for the current DonationData.
 
 getCommunicationType ()
 Data format for outgoing requests to the processor.
 

Static Public Member Functions

static getEnabledGateways (Config $mwConfig)
 Return an array of all the currently enabled gateways.
 
static getGatewayName ()
 Gets the name of the payment processor, e.g.
 
static getGlobal ( $varname)
 This function is important.
 
static getGlobalPrefix ()
 
static getIdentifier ()
 Get a general purpose identifier for this processor, e.g.
 
static getLogIdentifier ()
 Get a tag to use to identify this adapter in logs, e.g.
 
static token_generateToken ( $padding='')
 token_generateToken Generate a random string to be used as an edit token.
 

Public Attributes

string[] $debugarray
 
bool $log_outbound = false
 This should be set to true for gateways that don't return the request in the response.
 
bool $posted = false
 A boolean that will tell us if we've posted to ourselves.
 
const COMPLETED_PREFACE = 'Completed donation: '
 
const DONOR = 'Donor'
 
const DONOR_BKUP = 'Donor_BKUP'
 
const GATEWAY_NAME = 'Donation Gateway'
 
const GLOBAL_PREFIX = 'wgDonationGateway'
 
const IDENTIFIER = 'donation'
 
const REDIRECT_PREFACE = 'Redirecting for transaction: '
 Don't change these strings without fixing cross-repo usages.
 

Protected Member Functions

 addCodeRange ( $transaction, $key, $action, $lower, $upper=null)
 addCodeRange is used to define ranges of response codes for major gateway transactions, that let us know what status bucket to sort them into.
 
 addContactMessageFields ( $message)
 IMPORTANT: only add the contact_id to a message if the contact_hash is preset.
 
 appendNodeIfValue ( $value, &$node)
 appendNodeIfValue is a helper function for buildTransactionNodes, which is used by buildRequestXML to construct an XML transaction.
 
 buildRequestArray ()
 
 buildRequestNameValueString ()
 Builds a set of transaction data in name/value format *)The current transaction must be set before you call this function.
 
 buildRequestXML ( $rootElement='XML', $encoding='UTF-8')
 Builds a set of transaction data in XML format *)The current transaction must be set before you call this function.
 
 buildTransactionNodes ( $structure, &$node)
 buildRequestXML helper function.
 
 cleanTransactionStructureForLogs ( $structure, $never_log)
 Recursively sink through a transaction structure array to remove all nodes that we can't have showing up in the server logs.
 
 curl_errno ( $ch)
 Wrapper for the real curl_errno so we can override with magic for unit tests.
 
 curl_exec ( $ch)
 Wrapper for the real curl_exec so we can override with magic for unit tests.
 
 curl_getinfo ( $ch)
 Wrapper for the real curl_getinfo so we can override with magic for unit tests.
 
 curl_transaction ( $data)
 Sends a curl request to the gateway server, and gets a response.
 
 curlResponseIsValidFormat ( $curl_response)
 Allows adapters to specify curl response format requirements (e.g.
 
 defineAccountInfo ()
 defineAccountInfo needs to set up the $accountInfo array.
 
 defineDataConstraints ()
 TODO: see comment on definePaymentMethods.
 
 defineErrorMap ()
 Define the message keys used to display errors to the user.
 
 defineOrderIDMeta ()
 Sets up the $order_id_meta array.
 
 defineReturnValueMap ()
 defineReturnValueMap sets up the $return_value_map array.
 
 defineTransactions ()
 defineTransactions will define the $transactions array.
 
 defineVarMap ()
 defineVarMap needs to set up the $var_map array.
 
 doQueueTransaction ()
 Sends a queue message to the configured server and queue, based on the outcome of our current transaction.
 
 ensureUniqueOrderID ()
 
 executeIfFunctionExists ( $function_name, $parameter=null)
 Executes the specified function in $this, if one exists.
 
 fallbackToDefaultCurrency ()
 Called when a currency code error exists.
 
 findAccount ()
 Determine which account to use for this session.
 
 formatXmlString ( $xml)
 To avoid reinventing the wheel: taken from http://recursive-design.com/blog/2007/04/05/format-xml-with-php/.
 
 getCurlBaseHeaders ()
 
 getCurlBaseOpts ()
 
 getData_Staged ( $val='')
 Returns staged data from the adapter object, or null if a key was specified and no value exists.
 
 getFailedValidationResponse ()
 
 getFormattedResponse ( $rawResponse)
 Take the entire response string, and strip everything we don't care about.
 
 getProcessorUrl ()
 Return the base URL to use for the current transaction.
 
 getQueueContactMessage ()
 
 getQueueDonationMessage ()
 Collect donation details and normalize keys for pending or donations queue.
 
 getTransactionRequestStructure ()
 Returns the current transaction request structure if it exists, otherwise returns false.
 
 incrementNumAttempt ()
 Adds one to the 'numAttempt' field we use to keep track of how many times a donor has attempted a payment, in a session.
 
 incrementSequenceNumber ()
 Some payment gateways require a distinct identifier for each API call or for each new payment attempt, even if retrying an attempt that failed validation.
 
 isMonthlyConvertCountry ()
 Check if currency is in the list for $wgDonationInterfaceMonthlyConvertCountries.
 
 logCompletedPayment ()
 
 logPaymentDetails ( $preface=self::REDIRECT_PREFACE)
 
 parseResponseCommunicationStatus ( $response)
 Check the response for general sanity - e.g.
 
 parseResponseData ( $response)
 Harvest the data we need back from the gateway.
 
 parseResponseErrors ( $response)
 Parse the response to get the errors in a format we can log and otherwise deal with.
 
 postProcessDonation ()
 Runs all the post-process logic that has been enabled and configured in donationdata.php and/or LocalSettings.php, including the queue message.
 
 processResponse ( $response)
 Process the API response obtained from the payment processor and set properties of transaction_response.
 
 pushMessage ( $queue, $contactOnly=false)
 NOTE: Adyen Checkout has it's own pushMessage that does not push recurring iDEALs to the donations queue.
 
 refreshGatewayValueFromSource ( $val)
 Instead of pulling all the DonationData back through to update one local value, use this.
 
 runSessionVelocityFilter ()
 
 sendPendingMessage ()
 
 session_resetOnSwitch ()
 Check to see if donor is making a repeated attempt that is incompatible with the previous attempt, such as a gateway changes.
 
 setGatewayDefaults ( $options=[])
 Called in the constructor, this function should be used to define pieces of default data particular to the gateway.
 
 stageData ()
 Run any staging DataTransformers configured for the adapter.
 
 stripXMLResponseHeaders ( $rawResponse)
 
 token_checkTokens ()
 token_checkTokens The main function to check the salted and MD5'd token we should have saved and gathered from the request, against the clear-text token we should have saved to the user's session.
 
 token_matchEditToken ( $val)
 token_matchEditToken Determine the validity of a token by checking it against the salted version of the clear-text token we have already stored in the session.
 
 token_refreshAllTokenEverything ()
 token_refreshAllTokenEverything In the case where we have an expired session (token mismatch), we go ahead and fix it for 'em for their next post.
 
 transaction_option ( $option_value)
 If there are things about a transaction that we need to stash in the transaction's definition (defined in a local defineTransactions() ), we can recall them here.
 
 trimFieldToConstraints ( $value, $field)
 Trims a single field according to length constraints in data_constraints.yaml.
 
 unstageData ()
 Run any unstaging functions to decode processor responses.
 
 validateDataConstraintsMet ( $field, $value)
 Validates that the gateway-specific data constraints for this field have been met.
 
 xmlChildrenToArray ( $xml, $nodename)
 

Static Protected Member Functions

static token_applyMD5AndSalt ( $clear_token)
 token_applyMD5AndSalt Takes a clear-text token, and returns the MD5'd result of the token plus the configured gateway salt.
 

Protected Attributes

 $account_config
 
 $account_name
 
 $accountInfo
 
string $action
 
 $batch = false
 
array $config = []
 config tree
 
string $current_transaction
 Name of the current transaction.
 
StagingHelper ValidationHelper[] $data_transformers = []
 Data transformation helpers.
 
array $dataConstraints = []
 $dataConstraints provides information on how to handle variables.
 
DonationData $dataObj
 
array $error_map = []
 $error_map Reference map from gateway error to client error.
 
ErrorState $errorState
 List of errors preventing this transaction from continuing.
 
string $final_status
 When the smoke clears, this should be set to one of the constants defined in.
 
Psr Log LoggerInterface $logger
 Standard logger, logs to {type}_gateway.
 
 $order_id_candidates
 
 $order_id_meta
 
Psr Log LoggerInterface $payment_init_logger
 Logs to {type}_gateway_payment_init.
 
array $payment_methods = []
 $payment_methods will be defined by the adapter.
 
array $payment_submethods = []
 $payment_submethods will be defined by the adapter (or will default to an empty array if none are defined).
 
DonationProfiler $profiler
 Times and logs various operations.
 
 $return_value_map
 
int $risk_score = 0
 
 $staged_data
 
PaymentTransactionResponse $transaction_response
 $transaction_response is the member var that keeps track of the results of the latest discrete transaction with the gateway.
 
 $transactions
 
 $unstaged_data
 
array $var_map = []
 $var_map maps gateway variables to client variables
 
DomDocument $xmlDoc
 For gateways that speak XML, we use this variable to hold the document while we build the outgoing request.
 

Private Member Functions

 do_transaction_internal ( $transaction, &$retryVars=null)
 Called from do_transaction() in order to be able to deal with transactions that had recoverable errors but that do require the entire transaction to be repeated.
 

Detailed Description

GatewayAdapter.

Definition at line 37 of file gateway.adapter.php.

Constructor & Destructor Documentation

◆ __construct()

GatewayAdapter::__construct ( $options = [])

Member Function Documentation

◆ addCodeRange()

GatewayAdapter::addCodeRange ( $transaction,
$key,
$action,
$lower,
$upper = null )
protected

addCodeRange is used to define ranges of response codes for major gateway transactions, that let us know what status bucket to sort them into.

DO NOT DEFINE OVERLAPPING RANGES! TODO: Make sure it won't let you add overlapping ranges. That would probably necessitate the sort moving to here, too.

Parameters
string$transactionThe transaction these codes map to.
string$keyThe (incoming) field name containing the numeric codes we're defining here.
string$actionOne of the constants defined in
See also
FinalStatus.
Parameters
int$lowerThe integer value of the lower-bound in this code range.
int | null$upperOptional: The integer value of the upper-bound in the code range. If omitted, it will make a range of one value: The lower bound.
Exceptions
UnexpectedValueException
Returns
void

Definition at line 1843 of file gateway.adapter.php.

Referenced by AstroPayAdapter\defineReturnValueMap(), GlobalCollectAdapter\defineReturnValueMap(), PaypalExpressAdapter\defineReturnValueMap(), GlobalCollectAdapter\parseResponseData(), and GlobalCollectAdapter\transactionConfirm_CreditCard().

◆ addContactMessageFields()

GatewayAdapter::addContactMessageFields ( $message)
protected

IMPORTANT: only add the contact_id to a message if the contact_hash is preset.

We don't want to allow overwriting arbitrary CiviCRM contacts.

Parameters
array$message
Returns
array

Definition at line 2046 of file gateway.adapter.php.

◆ addRequestData()

GatewayAdapter::addRequestData ( $dataArray)

◆ addResponseData()

GatewayAdapter::addResponseData ( $dataArray)

Add data from the processor to staged_data and run any unstaging functions.

Parameters
array$dataArrayAn associative array of data, with normalized keys and raw processor values.

Only keys that are included in $dataArray will be persisted to the stored normalized data. This prevents us from overwriting items which should only ever hold data determined in this extension, not data from the processor or return querystring.

Definition at line 569 of file gateway.adapter.php.

References $unstaged_data, and unstageData().

Referenced by AmazonAdapter\authorizeAndCapturePayment(), AdyenCheckoutAdapter\doPayment(), AstroPayAdapter\processDonorReturn(), GlobalCollectAdapter\processResponse(), and PaypalExpressAdapter\processResponse().

◆ addStandardMessageFields()

GatewayAdapter::addStandardMessageFields ( $transaction)

For making freeform queue messages.

As these are all non-critical, we don't need to be as strict as we have been with the other stuff. But, we've got to have some standards.

Parameters
array$transactionThe fields that we are interested in sending.
Returns
array The fields that will actually be sent. So, $transaction ++ some other things we think we're likely to always need.

Implements GatewayType.

Definition at line 2056 of file gateway.adapter.php.

◆ appendNodeIfValue()

GatewayAdapter::appendNodeIfValue ( $value,
& $node )
protected

appendNodeIfValue is a helper function for buildTransactionNodes, which is used by buildRequestXML to construct an XML transaction.

This function will append an XML node to the transaction being built via the passed-in parent node, only if the current node would have a non-empty value.

Parameters
string$valueThe GATEWAY's field name for the current node.
DOMElement&$nodeThe parent node this node will be contained in, if it is determined to have a non-empty value.

Definition at line 948 of file gateway.adapter.php.

References getTransactionSpecificValue().

Referenced by buildTransactionNodes().

◆ buildOrderIDSources()

GatewayAdapter::buildOrderIDSources ( )

buildOrderIDSources: Uses the 'alt_locations' array in the order id metadata, to build an array of all possible candidates for order_id.

This will also weed out candidates that do not meet the gateway-specific data constraints for that field, and are therefore invalid.

Todo
Data Item Class. There should be a class that keeps track of the metadata for every field we use (everything that currently comes back from DonationData), that can be overridden per gateway. Revisit this in a more universal way when that time comes.

Definition at line 3430 of file gateway.adapter.php.

References $source.

◆ buildRequestArray()

GatewayAdapter::buildRequestArray ( )
protected

◆ buildRequestNameValueString()

GatewayAdapter::buildRequestNameValueString ( )
protected

Builds a set of transaction data in name/value format *)The current transaction must be set before you call this function.

*)Uses getTransactionSpecificValue to assign staged values to the fields required by the gateway. Look there for more insight into the heirarchy of all possible data sources.

Returns
string The raw transaction in name/value format, ready to be curl'd off to the remote server.

Definition at line 823 of file gateway.adapter.php.

References buildRequestArray().

Referenced by do_transaction_internal().

◆ buildRequestParams()

GatewayAdapter::buildRequestParams ( )

Build the parameters sent with the next request.

Returns
array Parameters as a map.

Implements GatewayType.

Definition at line 2171 of file gateway.adapter.php.

◆ buildRequestXML()

GatewayAdapter::buildRequestXML ( $rootElement = 'XML',
$encoding = 'UTF-8' )
protected

Builds a set of transaction data in XML format *)The current transaction must be set before you call this function.

*)(eventually) uses getTransactionSpecificValue to assign staged values to the fields required by the gateway. Look there for more insight into the heirarchy of all possible data sources.

Parameters
string$rootElementName of root element
string$encodingCharacter set to use for tag values
Returns
string The raw transaction in xml format, ready to be curl'd off to the remote server.

Definition at line 850 of file gateway.adapter.php.

References buildTransactionNodes(), cleanTransactionStructureForLogs(), getCurrentTransaction(), and getTransactionRequestStructure().

Referenced by do_transaction_internal().

◆ buildTransactionNodes()

GatewayAdapter::buildTransactionNodes ( $structure,
& $node )
protected

buildRequestXML helper function.

Builds the XML transaction by recursively crawling the transaction structure and adding populated nodes by reference.

Parameters
array$structureCurrent transaction's more leafward structure, from the point of view of the current XML node.
DOMElement&$nodeThe current XML node.

Definition at line 895 of file gateway.adapter.php.

References appendNodeIfValue(), and buildTransactionNodes().

Referenced by buildRequestXML(), and buildTransactionNodes().

◆ calculateKeyMashScore()

GatewayAdapter::calculateKeyMashScore ( $stringToCheck)
Parameters
string$stringToCheck
Returns
int|mixed

Definition at line 1597 of file gateway.adapter.php.

◆ cancel()

GatewayAdapter::cancel ( )

Cancel payment based on adapter and set status to cancelled.

Returns
PaymentResult

Reimplemented in IngenicoAdapter.

Definition at line 3897 of file gateway.adapter.php.

References PaymentResult\newFailure().

◆ checkTokens()

GatewayAdapter::checkTokens ( )

Checks the edit tokens in the user's session against the one gathered from populated form data.

Adds a string to the debugarray, to make it a little easier to tell what happened if we turn the debug results on. Only called from the .body pages

Returns
bool true if match, else false.

Definition at line 494 of file gateway.adapter.php.

References refreshGatewayValueFromSource(), and token_checkTokens().

◆ cleanTransactionStructureForLogs()

GatewayAdapter::cleanTransactionStructureForLogs ( $structure,
$never_log )
protected

Recursively sink through a transaction structure array to remove all nodes that we can't have showing up in the server logs.

Mostly for CVV: If we log those, we are all fired.

Parameters
array$structureThe transaction structure that we want to clean.
array$never_logAn array of values we should never log. These values should be the gateway's transaction nodes, rather than our normal values.
Returns
array $structure stripped of all references to the values in $never_log

Definition at line 925 of file gateway.adapter.php.

References cleanTransactionStructureForLogs().

Referenced by buildRequestXML(), and cleanTransactionStructureForLogs().

◆ createDonorReturnParams()

GatewayAdapter::createDonorReturnParams ( )

Takes normalized data and creates adapter specific params for processDonorReturn.

Returns
array

Reimplemented in PaypalExpressAdapter.

Definition at line 3881 of file gateway.adapter.php.

◆ curl_errno()

GatewayAdapter::curl_errno ( $ch)
protected

Wrapper for the real curl_errno so we can override with magic for unit tests.

Parameters
resource$chcurl handle (returned from curl_init)
Returns
int the error number or 0 if none occurred

Definition at line 1532 of file gateway.adapter.php.

◆ curl_exec()

GatewayAdapter::curl_exec ( $ch)
protected

Wrapper for the real curl_exec so we can override with magic for unit tests.

Parameters
resource$chcurl handle (returned from curl_init)
Returns
mixed True or the result on success (depends if CURLOPT_RETURNTRANSFER is set or not). False on total failure.

Definition at line 1514 of file gateway.adapter.php.

◆ curl_getinfo()

GatewayAdapter::curl_getinfo ( $ch)
protected

Wrapper for the real curl_getinfo so we can override with magic for unit tests.

Parameters
resource$chcurl handle (returned from curl_init)
Returns
mixed an array, string, or false on total failure.

Definition at line 1523 of file gateway.adapter.php.

◆ curl_transaction()

GatewayAdapter::curl_transaction ( $data)
protected

Sends a curl request to the gateway server, and gets a response.

Saves that response to the transaction_response's rawResponse;

Parameters
string$datathe raw data we want to curl up to a server somewhere. Should have been constructed with either buildRequestNameValueString, or buildRequestXML.
Returns
bool true if the communication was successful and there is a parseable response, false if there was a fundamental communication problem. (timeout, bad URL, etc.)

Reimplemented in IngenicoAdapter.

Definition at line 1366 of file gateway.adapter.php.

Referenced by do_transaction_internal().

◆ curlResponseIsValidFormat()

GatewayAdapter::curlResponseIsValidFormat ( $curl_response)
protected

Allows adapters to specify curl response format requirements (e.g.

xml, json, other custom format)

Defaults to true to allow any response format where check not needed.

Parameters
mixed$curl_response
Returns
bool

Reimplemented in GlobalCollectAdapter.

Definition at line 3961 of file gateway.adapter.php.

◆ defineAccountInfo()

GatewayAdapter::defineAccountInfo ( )
abstractprotected

defineAccountInfo needs to set up the $accountInfo array.

Keys = the name (or node name) value in the gateway transaction Values = The actual values for those keys. Probably have to access a global or two. (use getGlobal()!)

Reimplemented in AdyenCheckoutAdapter, AmazonAdapter, AstroPayAdapter, BraintreeAdapter, DlocalAdapter, GlobalCollectAdapter, and PaypalExpressAdapter.

Referenced by __construct().

◆ defineDataConstraints()

GatewayAdapter::defineDataConstraints ( )
protected

TODO: see comment on definePaymentMethods.

Definition at line 408 of file gateway.adapter.php.

Referenced by __construct().

◆ defineDataTransformers()

GatewayAdapter::defineDataTransformers ( )

Sets up the $data_transformers array.

Definition at line 430 of file gateway.adapter.php.

Referenced by __construct().

◆ defineErrorMap()

GatewayAdapter::defineErrorMap ( )
protected

Define the message keys used to display errors to the user.

Should set

See also
$this->error_map to an array whose keys are error codes and whose values are i18n keys or callables that return a translated error message. Any unmapped error code will use 'donate_interface-processing-error' TODO: see comment on definePaymentMethods

Reimplemented in AmazonAdapter, and AstroPayAdapter.

Definition at line 421 of file gateway.adapter.php.

Referenced by __construct().

◆ defineOrderIDMeta()

GatewayAdapter::defineOrderIDMeta ( )
abstractprotected

Sets up the $order_id_meta array.

Todo
Data Item Class. There should be a class that keeps track of the metadata for every field we use (everything that currently comes back from DonationData), that can be overridden per gateway. Revisit this in a more universal way when that time comes.

In general, $order_id_meta contains default data about how we handle/create/gather order_id, which needs to be defined on a per-gateway basis. Once $order_id_meta has been used to decide the order_id for the current request, it will also be used to keep information about the origin and state of the order_id data.

Should contain the following keys/values: 'alt_locations' => [ $dataset_name, $dataset_key ] ** alt_locations is intended to contain a list of arrays that are always available (or should be), from which we can pull the order_id. ** Examples of valid things to throw in $dataset_name are 'request' and 'session' ** $dataset_key : The key in the associated dataset that is expected to contain the order_id. Probably going to be order_id if we are generating the dataset internally. Probably something else if a gateway is posting or getting back to us in a resultswitcher situation. ** These should be expressed in $order_id_meta in order of preference / authority. 'generate' => boolean value. True if we will be generating our own order IDs, false if we are deferring order_id generation to the gateway. 'ct_id' => boolean value. If True, when generating order ID use the contribution tracking ID with the sequence number appended

Will eventually contain the following keys/values: 'final'=> The value that we have chosen as the valid order ID for this request. 'final_source' => Where we ultimately decided to grab the value we chose to stuff in 'final'.

Reimplemented in AdyenCheckoutAdapter, AmazonAdapter, AstroPayAdapter, BraintreeAdapter, DlocalAdapter, GlobalCollectAdapter, IngenicoAdapter, and PaypalExpressAdapter.

Referenced by __construct().

◆ definePaymentMethods()

GatewayAdapter::definePaymentMethods ( )

Sets up the $payment_methods array.

Keys = unique name for this method Values = metadata about the method 'validation' should be an array whose keys are field names and whose values indicate whether the field is required For legacy support. TODO replace with access to config structure

Reimplemented in AstroPayAdapter.

Definition at line 384 of file gateway.adapter.php.

Referenced by __construct().

◆ defineReturnValueMap()

GatewayAdapter::defineReturnValueMap ( )
abstractprotected

defineReturnValueMap sets up the $return_value_map array.

Keys = The different constants that may be contained as values in the gateway's response. Values = what that string constant means to mediawiki.

Reimplemented in AdyenCheckoutAdapter, AmazonAdapter, AstroPayAdapter, BraintreeAdapter, DlocalAdapter, GlobalCollectAdapter, and PaypalExpressAdapter.

Referenced by __construct().

◆ defineTransactions()

GatewayAdapter::defineTransactions ( )
abstractprotected

defineTransactions will define the $transactions array.

The array will contain everything we need to know about the request structure for all the transactions we care about, for the current gateway. First array key: Some way for us to id the transaction. Doesn't actually have to be the gateway's name for it, but I'm going with that until I have a reason not to. Second array key: 'request' contains the structure of that request. Leaves in the array tree will eventually be mapped to actual values of ours, according to the precedence established in the getTransactionSpecificValue function. 'values' contains default values for the transaction. Things that are typically not overridden should go here. 'check_required' should be set to true for transactions that require donor information, like initial payment setup. TODO: different required fields per transaction

Reimplemented in AdyenCheckoutAdapter, AmazonAdapter, AstroPayAdapter, BraintreeAdapter, DlocalAdapter, GlobalCollectAdapter, IngenicoAdapter, and PaypalExpressAdapter.

Referenced by __construct().

◆ defineVarMap()

GatewayAdapter::defineVarMap ( )
protected

defineVarMap needs to set up the $var_map array.

Keys = the name (or node name) value in the gateway transaction Values = the mediawiki field name for the corresponding piece of data. TODO: see comment on definePaymentMethods

Definition at line 399 of file gateway.adapter.php.

Referenced by __construct().

◆ do_transaction()

GatewayAdapter::do_transaction ( $transaction)

Performs a transaction through the gateway.

Optionally may reattempt the transaction if a recoverable gateway error occurred.

This function provides all functionality to the external world to communicate with a properly constructed gateway and handle all the return data in an appropriate manner. – Appropriateness is determined by the requested $transaction structure and definition.

Parameters
string$transactionThe specific transaction type, like 'INSERT_ORDERWITHPAYMENT', that maps to a first-level key in the $transactions array.
Returns
PaymentTransactionResponse

Reimplemented in GlobalCollectAdapter, and IngenicoAdapter.

Definition at line 973 of file gateway.adapter.php.

References $unstaged_data, do_transaction_internal(), getFailedValidationResponse(), getGlobal(), regenerateOrderID(), session_addDonorData(), setCurrentTransaction(), stageData(), validate(), and validatedOK().

Referenced by PaypalExpressAdapter\cancelSubscription(), AstroPayAdapter\doPayment(), PaypalExpressAdapter\doPayment(), PaypalExpressAdapter\doRefund(), and PaypalExpressAdapter\processDonorReturn().

◆ do_transaction_internal()

GatewayAdapter::do_transaction_internal ( $transaction,
& $retryVars = null )
private

Called from do_transaction() in order to be able to deal with transactions that had recoverable errors but that do require the entire transaction to be repeated.

This function has the following extension hooks:

  • pre_process_<strtolower($transaction)> Called before the transaction is processed; intended to call setValidationAction() if the transaction should not be performed. Anti-fraud can be performed in this hook by calling $this->runAntifraudFilters().
  • post_process_<strtolower($transaction)>
Parameters
string$transactionName of the transaction being performed
string | null&$retryVarsReference to an array of variables that caused the transaction to fail.
Returns
PaymentTransactionResponse
Exceptions
UnexpectedValueException

Definition at line 1047 of file gateway.adapter.php.

References $transaction_response, buildRequestArray(), buildRequestNameValueString(), buildRequestXML(), curl_transaction(), executeIfFunctionExists(), GatewayType\getCommunicationType(), ResponseProcessingException\getErrorCode(), getErrorMapByCodeAndTranslate(), getFormattedResponse(), ResponseProcessingException\getRetryVars(), getValidationAction(), isBatchProcessor(), Gateway_Extras_CustomFilters\onGatewayReady(), processResponse(), session_getData(), and setValidationAction().

Referenced by do_transaction().

◆ doQueueTransaction()

GatewayAdapter::doQueueTransaction ( )
protected

Sends a queue message to the configured server and queue, based on the outcome of our current transaction.

The big tricky thing here, is that we DO NOT SET a FinalStatus, unless we have just learned what happened to a donation in progress, through performing the current transaction. To put it another way, getFinalStatus should always return false, unless it's new data about a new transaction. In that case, the outcome will be assigned and the proper queue selected.

Probably called in postProcessDonation(), which is itself most likely to be called through executeFunctionIfExists, later on in do_transaction.

Definition at line 1923 of file gateway.adapter.php.

◆ ensureUniqueOrderID()

GatewayAdapter::ensureUniqueOrderID ( )
protected

◆ executeIfFunctionExists()

GatewayAdapter::executeIfFunctionExists ( $function_name,
$parameter = null )
protected

Executes the specified function in $this, if one exists.

NOTE: THIS WILL LCASE YOUR FUNCTION_NAME. ...I like to keep the voodoo functions tidy.

Parameters
string$function_nameThe name of the function you're hoping to execute.
mixed | null$parameterThat's right: For now you only get one.
Returns
bool True if a function was found and executed.

Definition at line 2084 of file gateway.adapter.php.

Referenced by do_transaction_internal().

◆ fallbackToDefaultCurrency()

GatewayAdapter::fallbackToDefaultCurrency ( )
protected

Called when a currency code error exists.

If a fallback currency conversion is enabled for this adapter, convert intended amount to default currency.

TODO: In the future, we might want to switch gateways.

Exceptions
DomainException

Definition at line 2736 of file gateway.adapter.php.

◆ finalizeInternalStatus()

GatewayAdapter::finalizeInternalStatus ( $status)

Sets the final payment status.

This is the one we care about for switching on behavior. DO NOT SET THE FINAL STATUS unless you've just taken an entire donation process to completion: This status being set at all, denotes the very end of the donation process on our end. Further attempts by the same user will be seen as starting over.

Parameters
string$statusThe final status of one discrete donation attempt, can be one of constants defined in
See also
FinalStatus
Exceptions
UnexpectedValueException

Definition at line 2229 of file gateway.adapter.php.

Referenced by AmazonAdapter\authorizeAndCapturePayment(), GlobalCollectAdapter\cancelCreditCardPayment(), AstroPayAdapter\doPayment(), GlobalCollectAdapter\finalizeCreditCardPayment(), AmazonAdapter\handleErrors(), GlobalCollectAdapter\parseResponseData(), AstroPayAdapter\processDonorReturn(), GlobalCollectAdapter\processDonorReturn(), PaypalExpressAdapter\processDonorReturn(), AstroPayAdapter\processNewInvoiceResponse(), PaypalExpressAdapter\processResponse(), GlobalCollectAdapter\transactionDirect_Debit(), and GlobalCollectAdapter\transactionRecurring_Charge().

◆ findAccount()

GatewayAdapter::findAccount ( )
protected

Determine which account to use for this session.

Definition at line 453 of file gateway.adapter.php.

References $account_name, and getGlobal().

Referenced by __construct().

◆ findCodeAction()

GatewayAdapter::findCodeAction ( $transaction,
$key,
$code )

findCodeAction

Parameters
string$transaction
string$keyThe key to lookup in the transaction such as STATUSID
int | string$codeThis gets converted to an integer if the values is numeric. FIXME: We should be pulling $code out of the current transaction fields, internally. FIXME: Rename to reflect that these are Final Status values, not validation actions
Returns
null|string Returns the code action if a valid code is supplied. Otherwise, the return is null.

Definition at line 1861 of file gateway.adapter.php.

Referenced by GlobalCollectAdapter\doRefund(), GlobalCollectAdapter\parseResponseData(), AstroPayAdapter\processDonorReturn(), PaypalExpressAdapter\processResponse(), GlobalCollectAdapter\transactionConfirm_CreditCard(), and GlobalCollectAdapter\transactionRecurring_Charge().

◆ formatStagedData()

GatewayAdapter::formatStagedData ( )

Format staged data.

Formatting:

  • trim - all strings
  • truncate - all strings to the maximum length permitted by the gateway

Definition at line 2132 of file gateway.adapter.php.

◆ formatXmlString()

GatewayAdapter::formatXmlString ( $xml)
protected

To avoid reinventing the wheel: taken from http://recursive-design.com/blog/2007/04/05/format-xml-with-php/.

Parameters
string$xml
Returns
string

Definition at line 1733 of file gateway.adapter.php.

References $line, and $matches.

◆ generateOrderID()

GatewayAdapter::generateOrderID ( $dataObj = null)

Default orderID generation This used to be done in DonationData, but gateways should control the format here.

Override this in child classes.

Parameters
DonationData | null$dataObjReference to the donation data object when we are forced to create the order ID during construction of it and thus do not already have a reference. THIS IS A HACK! /me vomits
Returns
int A freshly generated order ID

Reimplemented in AmazonAdapter, and GlobalCollectAdapter.

Definition at line 3638 of file gateway.adapter.php.

References DonationData\getVal(), and DonationData\saveContributionTrackingData().

◆ getAccountConfig()

GatewayAdapter::getAccountConfig ( $key)

Get globals-based configuration setting.

Parameters
string$keysetting to retrieve
Returns
mixed the setting requested

Implements GatewayType.

Definition at line 3041 of file gateway.adapter.php.

◆ getAvailableSubmethods()

GatewayAdapter::getAvailableSubmethods ( )

Get metadata for all available submethods, given current method / country TODO: A PaymentMethod should be able to list its child options.

Probably still need some gateway-specific logic to prune the list by country and currency. TODO: Make it possible to override availability by currency and currency in LocalSettings. Idea: same metadata array structure as used in definePaymentMethods, overrides cascade from methodMeta -> submethodMeta -> settingsMethodMeta -> settingsSubmethodMeta

Returns
array with available submethods 'visa' => [ 'label' => 'Visa' ]

Reimplemented in AmazonAdapter.

Definition at line 3772 of file gateway.adapter.php.

◆ getClientSideValidationRules()

GatewayAdapter::getClientSideValidationRules ( )

Returns an array of rules used to validate data before submission.

Each entry's key should correspond to the id of the target field, and the value should be a list of rules with keys as described in

See also
ClientSideValidationHelper::getClientSideValidation
Returns
array

Definition at line 3852 of file gateway.adapter.php.

◆ getConfig()

GatewayAdapter::getConfig ( $key = null)

Get settings loaded from adapter's config directory.

Parameters
string | null$keysetting to retrieve, or null for all
Returns
mixed the setting requested, or the config array

Implements GatewayType.

Definition at line 348 of file gateway.adapter.php.

References $config.

Referenced by Gateway_Form_Mustache\setGateway().

◆ getCoreDataTransformers()

GatewayAdapter::getCoreDataTransformers ( )

Definition at line 526 of file gateway.adapter.php.

◆ getCurlBaseHeaders()

GatewayAdapter::getCurlBaseHeaders ( )
protected

Definition at line 1250 of file gateway.adapter.php.

References GatewayType\getCommunicationType(), and getData_Staged().

◆ getCurlBaseOpts()

GatewayAdapter::getCurlBaseOpts ( )
protected

Reimplemented in PaypalExpressAdapter.

Definition at line 1224 of file gateway.adapter.php.

References $path, getGlobal(), getProcessorUrl(), transaction_option(), and true.

◆ getCurrencies()

GatewayAdapter::getCurrencies ( $options = [])
Parameters
array$optionsIf given, try to filter supported currencies by: 'country' ISO 3166 2 letter country code 'payment_method' 'payment_submethod'
Returns
array of ISO 4217 currency codes supported by this adapter for the given options. If options are not given, the adapter may return all supported currencies of filter by the unstaged data.

Implements GatewayType.

Reimplemented in AstroPayAdapter.

Definition at line 1352 of file gateway.adapter.php.

◆ getCurrentTransaction()

GatewayAdapter::getCurrentTransaction ( )

Gets the currently set transaction name.

This value should only ever be set with setCurrentTransaction: A function that ensures the current transaction maps to a first-level key that is known to exist in the $transactions array, defined in the child gateway.

Returns
string|false The name of the properly set transaction, or false if none has been set.

Implements GatewayType.

Definition at line 1285 of file gateway.adapter.php.

References $current_transaction.

Referenced by buildRequestXML(), IngenicoAdapter\curl_transaction(), getTransactionRequestStructure(), getTransactionSpecificValue(), GlobalCollectAdapter\parseResponseData(), AstroPayAdapter\processResponse(), GlobalCollectAdapter\processResponse(), PaypalExpressAdapter\processResponse(), and AstroPayAdapter\verifyStatusSignature().

◆ getData_Staged()

GatewayAdapter::getData_Staged ( $val = '')
protected

Returns staged data from the adapter object, or null if a key was specified and no value exists.

Parameters
string$valAn optional specific key you want returned.
Returns
mixed All the staged data held by the adapter, or if a key was set, the staged value for that key.

Definition at line 514 of file gateway.adapter.php.

References $staged_data.

Referenced by AmazonAdapter\authorizeOnBillingAgreement(), AmazonAdapter\authorizeOnOrderReference(), AmazonAdapter\confirmBillingAgreement(), AmazonAdapter\confirmOrderReference(), PaypalExpressAdapter\createDonorReturnParams(), GlobalCollectAdapter\doPayment(), IngenicoAdapter\doPayment(), getCurlBaseHeaders(), getTransactionSpecificValue(), AstroPayAdapter\processNewInvoiceResponse(), AmazonAdapter\setBillingAgreementDetailsIfUnset(), and AmazonAdapter\setOrderReferenceDetailsIfUnset().

◆ getData_Unstaged_Escaped()

GatewayAdapter::getData_Unstaged_Escaped ( $val = '')

This is the ONLY getData type function anything should be using outside the adapter.

Short explanation of the data population up to now: *) When the gateway adapter is constructed, it constructs a DonationData object. *) On construction, the DonationData object pulls donation data from an appropriate source, and normalizes the entire data set for storage. *) The gateway adapter pulls normalized, html escaped data out of the DonationData object, as the base of its own data set.

Parameters
string$valThe specific key you're looking for (if any)
Returns
mixed An array of all the raw, unstaged (but normalized and sanitized) data sent to the adapter, or if $val was set, either the specific value held for $val, or null if none exists.

Implements GatewayType.

Definition at line 618 of file gateway.adapter.php.

References $unstaged_data.

Referenced by AmazonAdapter\__construct(), IngenicoAdapter\curl_transaction(), AmazonAdapter\doPayment(), GlobalCollectAdapter\doPayment(), PaypalExpressAdapter\doPayment(), GlobalCollectAdapter\doRefund(), GlobalCollectAdapter\getAVSResult(), GlobalCollectAdapter\getBankList(), AstroPayAdapter\getCurrencies(), GlobalCollectAdapter\getCVVResult(), GlobalCollectAdapter\getGatewayTransactionId(), IngenicoAdapter\getGatewayTransactionId(), getPaymentMethod(), IngenicoAdapter\getPaymentProvider(), getPaymentSubmethod(), IngenicoAdapter\getStatusCode(), localizeGlobal(), GlobalCollectAdapter\parseResponseData(), GlobalCollectAdapter\post_process_get_orderstatus(), GlobalCollectAdapter\processDonorReturn(), PaypalExpressAdapter\processDonorReturn(), PaypalExpressAdapter\processResponse(), AstroPayAdapter\processStatusResponse(), PaypalExpressAdapter\setGatewayDefaults(), GlobalCollectAdapter\transactionConfirm_CreditCard(), GlobalCollectAdapter\tuneForCountry(), GlobalCollectAdapter\tuneForMethod(), GlobalCollectAdapter\tuneForRecurring(), and IngenicoAdapter\tuneForRecurring().

◆ getDataConstraints()

GatewayAdapter::getDataConstraints ( $field)

Get any known constraints on the field's value.

Parameters
string$field
Returns
array The field's constraints, or an empty array if none are available.

Implements GatewayType.

Definition at line 3511 of file gateway.adapter.php.

◆ getDataSources()

GatewayAdapter::getDataSources ( )

Definition at line 630 of file gateway.adapter.php.

◆ getDataTransformers()

GatewayAdapter::getDataTransformers ( )

FIXME: Not convinced we need this.

Returns
array

Definition at line 446 of file gateway.adapter.php.

References $data_transformers.

◆ getDonationRules()

GatewayAdapter::getDonationRules ( )

Add donation rules for the users country & currency combo.

Returns
array

Implements GatewayType.

Definition at line 1341 of file gateway.adapter.php.

◆ getEnabledGateways()

static GatewayAdapter::getEnabledGateways ( Config $mwConfig)
static

Return an array of all the currently enabled gateways.

Parameters
Config$mwConfigMediaWiki Config
Returns
array of gateway identifiers.

Definition at line 1802 of file gateway.adapter.php.

◆ getErrorMap()

GatewayAdapter::getErrorMap ( $code,
$options = [] )

getErrorMap

This will also return an error message if a $code is passed.

If the error code does not exist, the default message will be returned.

A default message should always exist with an index of 0.

NOTE: This method will check to see if the message exists in translation and use that message instead of the default. This would override error_map.

Parameters
string$codeThe error code to look up in the map
array$options
Returns
array|string Returns
See also
GatewayAdapter::$error_map

Definition at line 679 of file gateway.adapter.php.

References getGlobal(), and getIdentifier().

Referenced by GlobalCollectAdapter\checkDoBankValidation(), and getErrorMapByCodeAndTranslate().

◆ getErrorMapByCodeAndTranslate()

GatewayAdapter::getErrorMapByCodeAndTranslate ( $code)

getErrorMapByCodeAndTranslate

This will take an error code and translate the message.

Parameters
string$codeThe error code to look up in the map
Returns
string Returns the translated message from
See also
GatewayAdapter::$error_map

Definition at line 724 of file gateway.adapter.php.

References getErrorMap().

Referenced by do_transaction_internal().

◆ getErrorState()

GatewayAdapter::getErrorState ( )

Return any errors that prevent this transaction from continuing.

Returns
ErrorState

Definition at line 2379 of file gateway.adapter.php.

◆ getFailedValidationResponse()

GatewayAdapter::getFailedValidationResponse ( )
protected
Returns
PaymentTransactionResponse

Definition at line 3941 of file gateway.adapter.php.

Referenced by do_transaction().

◆ getFinalStatus()

GatewayAdapter::getFinalStatus ( )

If it has been set: returns the final payment status in the $final_status member variable.This is the one we care about for switching on overall behavior. Otherwise, returns false.

Returns
mixed Final Transaction results status, or false if not set. Should be one of the constants defined in
See also
FinalStatus

Implements GatewayType.

Definition at line 2210 of file gateway.adapter.php.

Referenced by IngenicoAdapter\do_transaction(), AmazonAdapter\doPayment(), AstroPayAdapter\doPayment(), GlobalCollectAdapter\doPayment(), PaypalExpressAdapter\doPayment(), GlobalCollectAdapter\processDonorReturn(), IngenicoAdapter\processDonorReturn(), PaypalExpressAdapter\processDonorReturn(), and GlobalCollectAdapter\transactionDirect_Debit().

◆ getFormattedResponse()

GatewayAdapter::getFormattedResponse ( $rawResponse)
protected

Take the entire response string, and strip everything we don't care about.

For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off.

Parameters
string$rawResponsehot off the curl
Returns
string|DomDocument|array depending on $this->getResponseType
Exceptions
InvalidArgumentException
LogicException

Definition at line 1671 of file gateway.adapter.php.

References $keys, and $type.

Referenced by do_transaction_internal().

◆ getFormFields()

GatewayAdapter::getFormFields ( $knownData = null)

Build list of form fields TODO: Determine if this ever needs to be overridden per gateway, or if all the per-country / per-gateway cases can be expressed declaratively in payment method / submethod metadata.

If that's the case, move this function (to DataValidator?)

Parameters
array | null$knownDataif provided, used to determine fields that depend on country or payment method. Falls back to unstaged data.
Returns
array of field names (empty if no payment method set)

Reimplemented in AdyenCheckoutAdapter.

Definition at line 2587 of file gateway.adapter.php.

References Subdivisions\getByCountry().

◆ getGatewayAdapterClass()

GatewayAdapter::getGatewayAdapterClass ( )

Definition at line 2371 of file gateway.adapter.php.

◆ getGatewayName()

static GatewayAdapter::getGatewayName ( )
static

Gets the name of the payment processor, e.g.

Adyen

Returns
string

Implements GatewayType.

Definition at line 1776 of file gateway.adapter.php.

Referenced by getTransactionRequestStructure(), getTransactionSpecificValue(), and setCurrentTransaction().

◆ getGlobal()

static GatewayAdapter::getGlobal ( $varname)
static

This function is important.

All the globals in Donation Interface should be accessed in this manner if they are meant to have a default value, but can be overridden by any of the gateways. It will check to see if a gateway-specific global exists, and if one is not set, it will pull the default from the wgDonationInterface definitions. Through this function, it is no longer necessary to define gateway-specific globals in LocalSettings unless you wish to override the default value for all gateways. If the variable exists in {prefix}AccountInfo[currentAccountName], that value will override the default settings.

Parameters
string$varnameThe global value we're looking for. It will first look for a global named for the instantiated gateway's GLOBAL_PREFIX, plus the $varname value. If that doesn't come up with anything that has been set, it will use the default value for all of donation interface, stored in $wgDonationInterface . $varname.
Returns
mixed The configured value for that gateway if it exists. If not, the configured value for Donation Interface if it exists or not.

Implements GatewayType.

Definition at line 634 of file gateway.adapter.php.

References getGlobalPrefix().

Referenced by AmazonAdapter\callPwaClient(), AmazonAdapter\defineErrorMap(), do_transaction(), findAccount(), GlobalCollectAdapter\getAVSResult(), getCurlBaseOpts(), GlobalCollectAdapter\getCVVResult(), getErrorMap(), getProcessorUrl(), PaypalExpressAdapter\getProcessorUrl(), localizeGlobal(), CountryValidation\lookUpCountry(), and GlobalCollectAdapter\processResponse().

◆ getGlobalPrefix()

static GatewayAdapter::getGlobalPrefix ( )
static

Definition at line 1781 of file gateway.adapter.php.

Referenced by getGlobal().

◆ getIdentifier()

static GatewayAdapter::getIdentifier ( )
static

Get a general purpose identifier for this processor, e.g.

paypal

Returns
string

Implements GatewayType.

Definition at line 1786 of file gateway.adapter.php.

Referenced by getErrorMap().

◆ getLogDebugJSON()

GatewayAdapter::getLogDebugJSON ( )

Returns some useful debugging JSON we can append to loglines for increased debugging happiness.

This is working pretty well for debugging GatewayChooser problems, so let's use it other places. Still, this should probably still be used sparingly...

Returns
string JSON-encoded donation data

Definition at line 3802 of file gateway.adapter.php.

Referenced by GlobalCollectAdapter\processResponse().

◆ getLogIdentifier()

static GatewayAdapter::getLogIdentifier ( )
static

Get a tag to use to identify this adapter in logs, e.g.

amazon_gateway

Returns
string

Implements GatewayType.

Definition at line 1791 of file gateway.adapter.php.

◆ getLogMessagePrefix()

GatewayAdapter::getLogMessagePrefix ( )

Get the log message prefix: $contribution_tracking_id .

':' . $order_id . ' '

Now, going to the DonationData object to handle this, because it will always have less stale data (and we need messages to come out of there before data exists here)

Returns
string

Implements LogPrefixProvider.

Definition at line 478 of file gateway.adapter.php.

◆ getMerchantID()

GatewayAdapter::getMerchantID ( )

For places that might need the merchant ID outside of the adapter.

Deprecated

Definition at line 3049 of file gateway.adapter.php.

◆ getMonthlyConvertAmounts()

GatewayAdapter::getMonthlyConvertAmounts ( )

Add the suggested monthly donation amounts for each donation level according to the currency saved in session for this donation attempt.

For currencies that are neither in the config nor these fallback rules, we leave the variable unset here and the JavaScript just redirects the donor to the Thank You page. Defaults include rules for USD, GBP, and JPY

Returns
array|null

Definition at line 3983 of file gateway.adapter.php.

◆ getOrderIDMeta()

GatewayAdapter::getOrderIDMeta ( $key = false)

Returns information about how to manage the Order ID, either a specific value or the whole associative array.

Parameters
string | false$keyThe key to retrieve. Optional.
Returns
mixed|false Data requested, or false if it is not set.

Implements GatewayType.

Definition at line 3700 of file gateway.adapter.php.

Referenced by GlobalCollectAdapter\parseResponseData().

◆ getPaymentMethod()

GatewayAdapter::getPaymentMethod ( )

Get the payment method.

Returns
string

Definition at line 1298 of file gateway.adapter.php.

References getData_Unstaged_Escaped().

Referenced by AdyenCheckoutAdapter\doPayment(), and GlobalCollectAdapter\doPayment().

◆ getPaymentMethodMeta()

GatewayAdapter::getPaymentMethodMeta ( $payment_method = null)

Get metadata for the specified payment method as set in.

See also
definePaymentMethods
Parameters
string | null$payment_methodDefaults to the current method
Returns
array
Exceptions
OutOfBoundsException

Implements GatewayType.

Definition at line 3727 of file gateway.adapter.php.

Referenced by GlobalCollectAdapter\parseResponseData().

◆ getPaymentMethods()

GatewayAdapter::getPaymentMethods ( )

Define payment methods.

Not all payment methods are available within an adapter

Returns
array Returns the available payment methods for the specific adapter

Definition at line 1310 of file gateway.adapter.php.

References $payment_methods.

◆ getPaymentSubmethod()

GatewayAdapter::getPaymentSubmethod ( )

Get the name of the currently selected payment submethod.

Returns
string

Implements GatewayType.

Definition at line 1314 of file gateway.adapter.php.

References getData_Unstaged_Escaped().

Referenced by GlobalCollectAdapter\doPayment().

◆ getPaymentSubmethodMeta()

GatewayAdapter::getPaymentSubmethodMeta ( $payment_submethod = null)

Get metadata for the specified payment submethod.

Parameters
string | null$payment_submethodDefaults to the current submethod
Returns
array
Exceptions
OutOfBoundsException

Implements GatewayType.

Definition at line 3740 of file gateway.adapter.php.

◆ getPaymentSubmethods()

GatewayAdapter::getPaymentSubmethods ( )

Get the entire list of payment submethod definitions.

Not all payment submethods are available within an adapter

Returns
array Returns the available payment submethods for the specific adapter

Implements GatewayType.

Definition at line 1318 of file gateway.adapter.php.

References $payment_submethods.

◆ getProcessorUrl()

GatewayAdapter::getProcessorUrl ( )
protected

Return the base URL to use for the current transaction.

Some adapters will append a path component and query parameters. That variation should be handled by the request controller. Customize things like varying server endpoints by overriding this function.

Returns
string

Reimplemented in PaypalExpressAdapter.

Definition at line 366 of file gateway.adapter.php.

References getGlobal().

Referenced by getCurlBaseOpts().

◆ getQueueContactMessage()

GatewayAdapter::getQueueContactMessage ( )
protected

Definition at line 1949 of file gateway.adapter.php.

References DonationData\getContactFields().

◆ getQueueDonationMessage()

GatewayAdapter::getQueueDonationMessage ( )
protected

Collect donation details and normalize keys for pending or donations queue.

Returns
array

Definition at line 1964 of file gateway.adapter.php.

References DonationData\getMessageFields(), and Amount\round().

Referenced by AmazonAdapter\addDonorDetails().

◆ getRequestProcessId()

GatewayAdapter::getRequestProcessId ( $requestValues)

Gateways which return true from isReturnProcessingRequired must override this with logic to get an ID from the request which will identify repeated attempts to process the same payment.

Parameters
array$requestValues
Returns
int|string Order id

Reimplemented in IngenicoAdapter, and PaypalExpressAdapter.

Definition at line 1563 of file gateway.adapter.php.

◆ getRequiredFields()

GatewayAdapter::getRequiredFields ( $knownData = null)
Parameters
null$knownData
Returns
array

Reimplemented in AdyenCheckoutAdapter.

Definition at line 2665 of file gateway.adapter.php.

◆ getResponseType()

GatewayAdapter::getResponseType ( )

Default response type to be the same as communication type.

Returns
string

Implements GatewayType.

Reimplemented in AstroPayAdapter, IngenicoAdapter, and PaypalExpressAdapter.

Definition at line 204 of file gateway.adapter.php.

References GatewayType\getCommunicationType().

◆ getScoreCountryMap()

GatewayAdapter::getScoreCountryMap ( )

This custom filter function checks the global variable:

CountryMap

How the score is tabulated:

  • If a country is not defined, a score of zero will be generated.
  • Generates a score based on the defined value.
  • Returns an integer: 0 <= $score <= 100
See also
$wgDonationInterfaceCustomFiltersFunctions
$wgDonationInterfaceCountryMap
Returns
int

Definition at line 2847 of file gateway.adapter.php.

◆ getScoreEmailDomainMap()

GatewayAdapter::getScoreEmailDomainMap ( )

This custom filter function checks the global variable:

EmailDomainMap

How the score is tabulated:

  • If a emailDomain is not defined, a score of zero will be generated.
  • Generates a score based on the defined value.
  • Returns an integer: 0 <= $score <= 100
See also
$wgDonationInterfaceCustomFiltersFunctions
$wgDonationInterfaceEmailDomainMap
Returns
int

Definition at line 2886 of file gateway.adapter.php.

◆ getScoreName()

GatewayAdapter::getScoreName ( )

This custom filter function checks the global variable: wgDonationInterfaceNameFilterRules Each entry in that array has keys KeyMapA, KeyMapB: define keyboard zones GibberishWeight: threshold fraction of name letters in a single zone Score: added to the total fraud score when this threshold is exceeded.

How the score is tabulated:

  • If the configurable portion letters in a name come from the same zone points are added.
  • Returns an integer: 0 <= $score <= 100
See also
$wgDonationInterfaceCustomFiltersFunctions
$wgDonationInterfaceNameFilterRules
Returns
int

Definition at line 2824 of file gateway.adapter.php.

◆ getScoreUtmCampaignMap()

GatewayAdapter::getScoreUtmCampaignMap ( )

This custom filter function checks the global variable:

UtmCampaignMap

Todo
All these regex map matching functions that are identical with different internal var names are making me rilly mad. Collapse.

How the score is tabulated:

  • Add the score(value) associated with each regex(key) in the map var.
See also
$wgDonationInterfaceCustomFiltersFunctions
$wgDonationInterfaceUtmCampaignMap
Returns
int

Definition at line 2929 of file gateway.adapter.php.

◆ getScoreUtmMediumMap()

GatewayAdapter::getScoreUtmMediumMap ( )

This custom filter function checks the global variable:

UtmMediumMap

Todo
Again. Regex map matching functions, identical, with minor internal var names. Collapse.

How the score is tabulated:

  • Add the score(value) associated with each regex(key) in the map var.
See also
$wgDonationInterfaceCustomFiltersFunctions
$wgDonationInterfaceUtmMediumMap
Returns
int

Definition at line 2972 of file gateway.adapter.php.

◆ getScoreUtmSourceMap()

GatewayAdapter::getScoreUtmSourceMap ( )

This custom filter function checks the global variable:

UtmSourceMap

Todo
Argharghargh, inflated code! Collapse!

How the score is tabulated:

  • Add the score(value) associated with each regex(key) in the map var.
See also
$wgDonationInterfaceCustomFiltersFunctions
$wgDonationInterfaceUtmSourceMap
Returns
int

Definition at line 3014 of file gateway.adapter.php.

References $source.

◆ getTransactionData()

GatewayAdapter::getTransactionData ( )

Returns the FORMATTED data harvested from the reply, or false if it is not set.

Returns
mixed An array of returned data, or false.

Definition at line 2364 of file gateway.adapter.php.

Referenced by GlobalCollectAdapter\getTransactionDataFormAction(), GlobalCollectAdapter\transactionConfirm_CreditCard(), GlobalCollectAdapter\transactionDirect_Debit(), and GlobalCollectAdapter\transactionRecurring_Charge().

◆ getTransactionMessage()

GatewayAdapter::getTransactionMessage ( )
Deprecated
Returns
string|boolean

Definition at line 2353 of file gateway.adapter.php.

◆ getTransactionRequestStructure()

GatewayAdapter::getTransactionRequestStructure ( )
protected

Returns the current transaction request structure if it exists, otherwise returns false.

Fails nicely if the current transaction is simply not set yet.

Exceptions
LogicExceptionif the transaction is set, but no structure is defined.
Returns
mixed current transaction's structure as an array, or false

Definition at line 796 of file gateway.adapter.php.

References getCurrentTransaction(), and getGatewayName().

Referenced by buildRequestArray(), and buildRequestXML().

◆ getTransactionResponse()

GatewayAdapter::getTransactionResponse ( )

Returns the response object with the details of the latest transaction, or null if the adapter has not yet performed one.

Returns
PaymentTransactionResponse|null

Implements GatewayType.

Definition at line 2191 of file gateway.adapter.php.

Referenced by PaypalExpressAdapter\processDonorReturn().

◆ getTransactionSpecificValue()

GatewayAdapter::getTransactionSpecificValue ( $gateway_field_name)

This function is used exclusively by the two functions that build requests to be sent directly to external payment gateway servers.

Those two functions are buildRequestNameValueString, and (perhaps less obviously) buildRequestXML. As such, unless a valid current transaction has already been set, this will error out rather hard. In other words: In all likelihood, this is not the function you're looking for.

Parameters
string$gateway_field_nameThe GATEWAY's field name that we are hoping to populate. Probably not even remotely the way we name the same data internally.
Exceptions
LogicException
Returns
mixed The value we want to send directly to the gateway, for the specified gateway field name.

Definition at line 742 of file gateway.adapter.php.

References getCurrentTransaction(), getData_Staged(), getGatewayName(), and trimFieldToConstraints().

Referenced by appendNodeIfValue().

◆ getTransactionStatus()

GatewayAdapter::getTransactionStatus ( )

Returns the transaction communication status, or false if not set present.

Returns
mixed

Definition at line 2200 of file gateway.adapter.php.

Referenced by GlobalCollectAdapter\parseResponseData().

◆ getValidationAction()

GatewayAdapter::getValidationAction ( )

Returns the current validation action.

This will typically get set and altered by the fraud filters.

Returns
string the current process action.

Implements GatewayType.

Definition at line 2566 of file gateway.adapter.php.

Referenced by do_transaction_internal(), AdyenCheckoutAdapter\doPayment(), AstroPayAdapter\doPayment(), PaypalExpressAdapter\processResponse(), and GlobalCollectAdapter\transactionConfirm_CreditCard().

◆ incrementNumAttempt()

GatewayAdapter::incrementNumAttempt ( )
protected

Adds one to the 'numAttempt' field we use to keep track of how many times a donor has attempted a payment, in a session.

When they first show up (or get their token/session reset), it should be set to '0'.

Definition at line 2389 of file gateway.adapter.php.

◆ incrementSequenceNumber()

GatewayAdapter::incrementSequenceNumber ( )
protected

Some payment gateways require a distinct identifier for each API call or for each new payment attempt, even if retrying an attempt that failed validation.

This is slightly different from numAttempt, which is only incremented when setting a final status for a payment attempt. It is the child class's responsibility to increment this at the appropriate time.

Definition at line 2413 of file gateway.adapter.php.

Referenced by IngenicoAdapter\do_transaction(), AmazonAdapter\doPayment(), and AstroPayAdapter\processNewInvoiceResponse().

◆ isBatchProcessor()

GatewayAdapter::isBatchProcessor ( )

Lets the outside world (particularly filters that accumulate points scores) know if we are a batch processor.

Returns
bool

Implements GatewayType.

Definition at line 2573 of file gateway.adapter.php.

Referenced by do_transaction_internal(), PaypalExpressAdapter\processDonorReturn(), PaypalExpressAdapter\processResponse(), and GlobalCollectAdapter\transactionConfirm_CreditCard().

◆ isMonthlyConvertCountry()

GatewayAdapter::isMonthlyConvertCountry ( )
protected

Check if currency is in the list for $wgDonationInterfaceMonthlyConvertCountries.

Returns
bool

Definition at line 3969 of file gateway.adapter.php.

◆ isReturnProcessingRequired()

GatewayAdapter::isReturnProcessingRequired ( )

Whether donation processing depends on additional processing on-wiki at the donor's return from a payment processor.

This is used to determine whether we should show fail pages on session timeouts.

Returns
bool true when on-wiki post-processing is required.

Reimplemented in PaypalExpressAdapter.

Definition at line 1551 of file gateway.adapter.php.

◆ loadConfig()

GatewayAdapter::loadConfig ( $variant = null)

Definition at line 341 of file gateway.adapter.php.

References ConfigurationReader\createForGateway().

Referenced by __construct().

◆ localizeGlobal()

GatewayAdapter::localizeGlobal ( $varname)

Gets a global variable according to.

See also
getGlobal rules, then replaces $country and $language with values from gateway instance data.
Parameters
string$varnameName of setting to retrieve
Returns
string Localized setting

Definition at line 654 of file gateway.adapter.php.

References getData_Unstaged_Escaped(), and getGlobal().

Referenced by AmazonAdapter\defineErrorMap(), and AstroPayAdapter\processNewInvoiceResponse().

◆ logCompletedPayment()

GatewayAdapter::logCompletedPayment ( )
protected

Definition at line 3829 of file gateway.adapter.php.

◆ logFinalStatus()

GatewayAdapter::logFinalStatus ( $status)

Easily-child-overridable log component of setting the final transaction status, which will only ever be set at the very end of a transaction workflow.

Parameters
string$statusone of the constants defined in
See also
FinalStatus

Definition at line 2285 of file gateway.adapter.php.

References $keys.

◆ logPaymentDetails()

GatewayAdapter::logPaymentDetails ( $preface = self::REDIRECT_PREFACE)
protected

Definition at line 3823 of file gateway.adapter.php.

Referenced by AdyenCheckoutAdapter\doPayment().

◆ logPending()

GatewayAdapter::logPending ( )

Dump info about a transaction in logs and pending queues before sending the donor off to complete it.

Implements GatewayType.

Definition at line 1536 of file gateway.adapter.php.

◆ normalizeOrderID()

GatewayAdapter::normalizeOrderID ( $override = null,
$dataObj = null )

This function is meant to be run by the DonationData class, both before and after any communication has been done that might retrieve an order ID.

To put it another way: If we are meant to be getting the OrderID from a piece of gateway communication that hasn't been done yet, this should return NULL. I think.

Parameters
string | null$overrideThe pre-determined value of order_id. When you want to normalize an order_id to something you have already sorted out (anything running in batch mode is a good candidate - you have probably grabbed a preexisting order_id from some external data source in that case), short-circuit the hunting process and just take the override's word for order_id's final value. Also used when receiving the order_id from external sources (example: An API response)
DonationData | null$dataObjReference to the donation data object when we're creating the order ID in the constructor of the object (and thus do not yet have a reference to it.)
Returns
string The normalized value of order_id

Definition at line 3582 of file gateway.adapter.php.

References $source.

Referenced by GlobalCollectAdapter\parseResponseData().

◆ parseResponseCommunicationStatus()

GatewayAdapter::parseResponseCommunicationStatus ( $response)
protected

Check the response for general sanity - e.g.

correct data format, keys exists

Parameters
mixed$responseWhatever came back from the API call
Returns
bool true if response looks sane

Reimplemented in GlobalCollectAdapter, and IngenicoAdapter.

Definition at line 1638 of file gateway.adapter.php.

◆ parseResponseData()

GatewayAdapter::parseResponseData ( $response)
protected

Harvest the data we need back from the gateway.

Parameters
mixed$responseWhatever came back from the API call
Returns
array a key/value array

Reimplemented in GlobalCollectAdapter, and IngenicoAdapter.

Definition at line 1658 of file gateway.adapter.php.

◆ parseResponseErrors()

GatewayAdapter::parseResponseErrors ( $response)
protected

Parse the response to get the errors in a format we can log and otherwise deal with.

Parameters
mixed$responseWhatever came back from the API call
Returns
array a key/value array of codes (if they exist) and messages. TODO: Move to a parsing class, where these are part of an interface rather than empty although non-abstract.

Reimplemented in GlobalCollectAdapter, IngenicoAdapter, and PaypalExpressAdapter.

Definition at line 1649 of file gateway.adapter.php.

◆ postProcessDonation()

GatewayAdapter::postProcessDonation ( )
protected

Runs all the post-process logic that has been enabled and configured in donationdata.php and/or LocalSettings.php, including the queue message.

This function is most likely to be called through executeFunctionIfExists, later on in do_transaction.

Definition at line 2457 of file gateway.adapter.php.

References Gateway_Extras_ConversionLog\onPostProcess(), and Gateway_Extras_CustomFilters_IP_Velocity\onPostProcess().

Referenced by AmazonAdapter\authorizeAndCapturePayment(), GlobalCollectAdapter\finalizeCreditCardPayment(), AstroPayAdapter\processDonorReturn(), and PaypalExpressAdapter\processResponse().

◆ processDonorReturn()

GatewayAdapter::processDonorReturn ( $requestValues)

Default implementation sets status to complete.

Parameters
array$requestValuesall GET and POST values from the request
Returns
PaymentResult

Implements GatewayType.

Reimplemented in AdyenCheckoutAdapter, AstroPayAdapter, GlobalCollectAdapter, IngenicoAdapter, and PaypalExpressAdapter.

Definition at line 1588 of file gateway.adapter.php.

References PaymentResult\newSuccess().

◆ processResponse()

GatewayAdapter::processResponse ( $response)
protected

Process the API response obtained from the payment processor and set properties of transaction_response.

Default implementation just says we got a response.

Parameters
array | DomDocument$responseCleaned-up response returned from
See also
getFormattedResponse. Type depends on $this->getResponseType
Exceptions
ResponseProcessingExceptionwith an actionable error code and any variables to retry

TODO: Move response parsing to a separate class.

Reimplemented in AstroPayAdapter, GlobalCollectAdapter, and PaypalExpressAdapter.

Definition at line 1579 of file gateway.adapter.php.

Referenced by do_transaction_internal().

◆ pushMessage()

GatewayAdapter::pushMessage ( $queue,
$contactOnly = false )
protected

NOTE: Adyen Checkout has it's own pushMessage that does not push recurring iDEALs to the donations queue.

Parameters
string$queueWhat queue to send the message to
bool$contactOnlyIf we only have the donor's contact information

Reimplemented in AdyenCheckoutAdapter.

Definition at line 2477 of file gateway.adapter.php.

References $queue.

◆ rectifyOrphan()

GatewayAdapter::rectifyOrphan ( )

Looks at message to see if it should be rectified Allows exit if the adapter should not rectify the orphan Then tries to see if the orphan can be matched.

Returns
PaymentResult

Definition at line 3907 of file gateway.adapter.php.

References PaymentResult\newEmpty().

◆ refreshGatewayValueFromSource()

GatewayAdapter::refreshGatewayValueFromSource ( $val)
protected

Instead of pulling all the DonationData back through to update one local value, use this.

It updates both staged_data (which is intended to be staged and used just by the gateway) and unstaged_data, which is actually just normalized and sanitized form data as entered by the user. You should restage the data after running this.

Not doing this right now, though, because it's not yet necessary for anything we have at the moment.

Parameters
string$valThe field name that we are looking to retrieve from our DonationData object.

Definition at line 2529 of file gateway.adapter.php.

Referenced by addRequestData(), and checkTokens().

◆ regenerateOrderID()

GatewayAdapter::regenerateOrderID ( )

Definition at line 3662 of file gateway.adapter.php.

References $source.

Referenced by do_transaction().

◆ runAntifraudFilters()

GatewayAdapter::runAntifraudFilters ( )

Runs all the fraud filters that have been enabled and configured in donationdata.php and/or LocalSettings.php This function is most likely to be called through executeFunctionIfExists, early on in do_transaction.

Definition at line 2439 of file gateway.adapter.php.

References Gateway_Extras_CustomFilters\onValidate().

Referenced by AstroPayAdapter\doPayment(), GlobalCollectAdapter\post_process_get_orderstatus(), and PaypalExpressAdapter\processResponse().

◆ runSessionVelocityFilter()

GatewayAdapter::runSessionVelocityFilter ( )
protected

◆ sendFinalStatusMessage()

GatewayAdapter::sendFinalStatusMessage ( $status)

Build and send a message to the payments-init queue, once the initial workflow is complete.

Parameters
string$statusone of the constants in
See also
SmashPig\PaymentData\FinalStatus

Definition at line 2318 of file gateway.adapter.php.

References $keys.

◆ sendPendingMessage()

GatewayAdapter::sendPendingMessage ( )
protected

Definition at line 2487 of file gateway.adapter.php.

Referenced by AmazonAdapter\addDonorDetails().

◆ session_addDonorData()

GatewayAdapter::session_addDonorData ( )

Removes any old donor data from the session, and adds the current set.

This will be used internally every time we call do_transaction.

Definition at line 3113 of file gateway.adapter.php.

References DonationData\getSessionFields().

Referenced by AmazonAdapter\__construct(), do_transaction(), GlobalCollectAdapter\do_transaction(), IngenicoAdapter\do_transaction(), AdyenCheckoutAdapter\doPayment(), and GlobalCollectAdapter\parseResponseData().

◆ session_ensure()

GatewayAdapter::session_ensure ( )

session_ensure Ensure that we have a session set for the current user.

If we do not have a session set for the current user, start the session.

Implements GatewayType.

Definition at line 3053 of file gateway.adapter.php.

◆ session_getData()

GatewayAdapter::session_getData ( $key,
$subkey = null )

Retrieve data from the session if it's set, and null if it's not.

Parameters
string$keyThe array key to return from the session.
string | null$subkeyOptional: The subkey to return from the session. Only really makes sense if $key is an array.
Returns
mixed The session value if present, or null if it is not set.

Definition at line 3064 of file gateway.adapter.php.

Referenced by do_transaction_internal(), GlobalCollectAdapter\processDonorReturn(), AmazonAdapter\setBillingAgreementDetailsIfUnset(), and AmazonAdapter\setOrderReferenceDetailsIfUnset().

◆ session_hasDonorData()

GatewayAdapter::session_hasDonorData ( )

Checks to see if we have donor data in our session.

This can be useful for determining if a user should be at a certain point in the workflow for certain gateways. For example: This is used on the outside of the adapter in resultswitcher pages, to determine if the user is actually in the process of making a credit card transaction.

Returns
bool true if the session contains donor data

Definition at line 3085 of file gateway.adapter.php.

◆ session_killAllEverything()

GatewayAdapter::session_killAllEverything ( )

This should kill the session as hard as possible.

It will leave the cookie behind, but everything it could possibly reference will be gone.

Definition at line 3134 of file gateway.adapter.php.

◆ session_resetForNewAttempt()

GatewayAdapter::session_resetForNewAttempt ( $force = false)

For those times you want to have the user functionally start over without, you know, cutting your entire head off like you do with session_unsetAllData().

Parameters
bool$forceBehavior Description: $force = true: Reset for potential totally new payment, but keep numAttempt and other antifraud things (velocity data) around. $force = false: Keep all donor data around unless numAttempt has hit its max, but kill the ctid (in the likely case that it was an honest mistake)

Definition at line 3165 of file gateway.adapter.php.

◆ session_resetOnSwitch()

GatewayAdapter::session_resetOnSwitch ( )
protected

Check to see if donor is making a repeated attempt that is incompatible with the previous attempt, such as a gateway changes.

Reset certain things if so. Prevents order_id leakage, log spam, and recur problems. FIXME: this all has to be special cases because we need to compare session values with request values that are normalized by DonationData, and DonationData's idea of normalization includes some stuff we don't want to do yet, like assigning order ID and saving contribution tracking.

Definition at line 3232 of file gateway.adapter.php.

Referenced by __construct().

◆ session_setDonorBackupData()

GatewayAdapter::session_setDonorBackupData ( array $donorData)

Saves a backup of the Donor Data in session.

Parameters
array$donorData

Definition at line 3094 of file gateway.adapter.php.

◆ session_unsetAllData()

GatewayAdapter::session_unsetAllData ( )

Destroys the session completely.

...including session velocity data, and the form stack. So, you probably just shouldn't. Please consider session_reset instead. Please. Note: This will leave the cookie behind! It just won't go to anything at all. FIXME: This is silly and redundant and should probably be killed.

Definition at line 3149 of file gateway.adapter.php.

◆ session_unsetDonorData()

GatewayAdapter::session_unsetDonorData ( )

Unsets the session data, in the case that we've saved it for gateways like GlobalCollect that require it to persist over here through their iframe experience.

Definition at line 3103 of file gateway.adapter.php.

◆ setCurrentTransaction()

GatewayAdapter::setCurrentTransaction ( $transaction_name)

Sets the transaction you are about to send to the payment gateway.

This will throw an exception if you try to set it to something that has no transaction definition.

Parameters
string$transaction_nameThis is a specific transaction type like 'INSERT_ORDERWITHPAYMENT' (if you're GlobalCollect) that maps to a first-level key in the $transactions array.
Exceptions
UnexpectedValueException

Definition at line 1272 of file gateway.adapter.php.

References getGatewayName().

Referenced by do_transaction(), AdyenCheckoutAdapter\doPayment(), and AstroPayAdapter\processDonorReturn().

◆ setGatewayDefaults()

GatewayAdapter::setGatewayDefaults ( $options = [])
protected

Called in the constructor, this function should be used to define pieces of default data particular to the gateway.

It will be up to the child class to poke the data through to the data object (probably with $this->addRequestData()). DO NOT set default payment informati on here (or anywhere, really). That would be naughty.

Parameters
array$optionsassociative array of values as given to the GateWayType constructor.

Reimplemented in GlobalCollectAdapter, IngenicoAdapter, and PaypalExpressAdapter.

Definition at line 1333 of file gateway.adapter.php.

Referenced by __construct().

◆ setHash()

GatewayAdapter::setHash ( $hashval)

Set a value used to determine whether data has changed.

Parameters
string$hashval

Implements GatewayType.

Definition at line 2425 of file gateway.adapter.php.

◆ setOrderIDMeta()

GatewayAdapter::setOrderIDMeta ( $key,
$value )

sets more orderID Meta, so we can remember things about what we chose to go with in later logic.

Parameters
string$keyThe key to set.
mixed$valueThe value to set.

Definition at line 3723 of file gateway.adapter.php.

◆ setRiskScore()

GatewayAdapter::setRiskScore ( $score)

Set the adapter's fraud score.

Parameters
float$score

Implements GatewayType.

Definition at line 2540 of file gateway.adapter.php.

◆ setValidationAction()

GatewayAdapter::setValidationAction ( $action,
$reset = false )

Sets the current validation action.

This is meant to be used by the fraud filters, and as such, by default, only worse news than was already being stored will be retained for the final result.

Parameters
string$actionthe value you want to set as the action.
bool$resetset to true to do a hard set on the action value. Otherwise, the status will only change if it fails harder than it already was.
Exceptions
UnexpectedValueException

Implements GatewayType.

Definition at line 2544 of file gateway.adapter.php.

Referenced by do_transaction_internal().

◆ shouldRectifyOrphan()

GatewayAdapter::shouldRectifyOrphan ( )

Allows adapters to specify logic as to whether an orphan can be rectified.

Returns
bool

Reimplemented in IngenicoAdapter, and PaypalExpressAdapter.

Definition at line 3889 of file gateway.adapter.php.

◆ showMonthlyConvert()

GatewayAdapter::showMonthlyConvert ( )
Returns
bool true when we want to ask a one-time donor for a recurring donation after their one-time donation is complete.
See also
$wgDonationInterfaceMonthlyConvertCountries

Implements GatewayType.

Definition at line 4010 of file gateway.adapter.php.

Referenced by AdyenCheckoutAdapter\doPayment(), and IngenicoAdapter\tuneForRecurring().

◆ stageData()

GatewayAdapter::stageData ( )
protected

Run any staging DataTransformers configured for the adapter.

Reimplemented in GlobalCollectAdapter.

Definition at line 2097 of file gateway.adapter.php.

Referenced by __construct(), addRequestData(), do_transaction(), and PaypalExpressAdapter\doPayment().

◆ stripXMLResponseHeaders()

GatewayAdapter::stripXMLResponseHeaders ( $rawResponse)
protected

Definition at line 1713 of file gateway.adapter.php.

◆ token_applyMD5AndSalt()

static GatewayAdapter::token_applyMD5AndSalt ( $clear_token)
staticprotected

token_applyMD5AndSalt Takes a clear-text token, and returns the MD5'd result of the token plus the configured gateway salt.

Parameters
string$clear_tokenThe original, unsalted, unencoded edit token.
Returns
string The salted and MD5'd token.

Definition at line 3303 of file gateway.adapter.php.

◆ token_checkTokens()

GatewayAdapter::token_checkTokens ( )
protected

token_checkTokens The main function to check the salted and MD5'd token we should have saved and gathered from the request, against the clear-text token we should have saved to the user's session.

token_getSaltedSessionToken() will start off the process if this is a first load, and there's no saved token in the session yet.

Returns
bool

Definition at line 3393 of file gateway.adapter.php.

Referenced by checkTokens().

◆ token_generateToken()

static GatewayAdapter::token_generateToken ( $padding = '')
static

token_generateToken Generate a random string to be used as an edit token.

Parameters
string$paddingA string with which we could pad out the random hex further.
Returns
string

Definition at line 3321 of file gateway.adapter.php.

◆ token_getSaltedSessionToken()

GatewayAdapter::token_getSaltedSessionToken ( )

Establish an 'edit' token to help prevent CSRF, etc.

We use this in place of User::editToken() b/c currently User::editToken() is broken (apparently by design) for anonymous users. Using User::editToken() currently exposes a security risk for non-authenticated users. Until this is resolved, we'll use our own methods for token handling.

Public so the api can get to it.

Returns
string

Implements GatewayType.

Definition at line 3326 of file gateway.adapter.php.

◆ token_matchEditToken()

GatewayAdapter::token_matchEditToken ( $val)
protected

token_matchEditToken Determine the validity of a token by checking it against the salted version of the clear-text token we have already stored in the session.

On failure, it resets the edit token both in the session and in the form, so they will match on the user's next load.

Parameters
string$val
Returns
bool

Definition at line 3368 of file gateway.adapter.php.

◆ token_refreshAllTokenEverything()

GatewayAdapter::token_refreshAllTokenEverything ( )
protected

token_refreshAllTokenEverything In the case where we have an expired session (token mismatch), we go ahead and fix it for 'em for their next post.

We do this by refreshing everything that has to do with the edit token.

Definition at line 3348 of file gateway.adapter.php.

◆ transaction_option()

GatewayAdapter::transaction_option ( $option_value)
protected

If there are things about a transaction that we need to stash in the transaction's definition (defined in a local defineTransactions() ), we can recall them here.

Currently, this is only being used to determine if we have a transaction whose transmission would require multiple attempts to wait for a certain status (or set of statuses), but we could do more with this mechanism if we need to.

Parameters
string$option_valuethe name of the key we're looking for in the transaction definition.
Returns
mixed the transaction's value for that key if it exists, or NULL.

Definition at line 2504 of file gateway.adapter.php.

Referenced by getCurlBaseOpts(), AstroPayAdapter\getResponseType(), and GlobalCollectAdapter\processResponse().

◆ trimFieldToConstraints()

GatewayAdapter::trimFieldToConstraints ( $value,
$field )
protected

Trims a single field according to length constraints in data_constraints.yaml.

Parameters
mixed$value
string$fieldthe name of the field specified in data_constraints
Returns
mixed|string

Definition at line 2146 of file gateway.adapter.php.

Referenced by getTransactionSpecificValue().

◆ unsetHash()

GatewayAdapter::unsetHash ( )

Clear the data hash value.

Implements GatewayType.

Definition at line 2429 of file gateway.adapter.php.

◆ unstageData()

GatewayAdapter::unstageData ( )
protected

Run any unstaging functions to decode processor responses.

Definition at line 2115 of file gateway.adapter.php.

Referenced by addResponseData().

◆ unstageKeys()

GatewayAdapter::unstageKeys ( $processor_data,
$key_map = null )

Change the keys on this data from processor API names to normalized names.

Parameters
array$processor_dataResponse data with raw API keys
array | null$key_mapmap processor keys to our keys, defaults to $this->var_map
Returns
array data with normalized keys

TODO: Figure out why this isn't the default behavior in addResponseData. Once that's resolved, we might operate on member fields rather than do this as a function.

Definition at line 602 of file gateway.adapter.php.

References $staged_data, and $var_map.

Referenced by GlobalCollectAdapter\processResponse(), and PaypalExpressAdapter\processResponse().

◆ validate()

GatewayAdapter::validate ( )

Check donation data for validity and set errors.

This function will go through all the data we have pulled from wherever we've pulled it, and make sure it's safe and expected and everything. If it is not, it will return an array of errors ready for any DonationInterface form class derivative to display.

Returns
bool true if validation passes

Definition at line 2684 of file gateway.adapter.php.

References DataValidator\validate().

Referenced by __construct(), and do_transaction().

◆ validateDataConstraintsMet()

GatewayAdapter::validateDataConstraintsMet ( $field,
$value )
protected

Validates that the gateway-specific data constraints for this field have been met.

Parameters
string$fieldThe field name we're checking
mixed$valueThe candidate value of the field we want to check
Returns
bool True if it's a valid value for that field, false if it isn't.

Definition at line 3525 of file gateway.adapter.php.

References $type.

◆ validatedOK()

GatewayAdapter::validatedOK ( )
Returns
bool True if submitted data is valid and sufficient to proceed to the next step. TODO: Were we also trying to indicate whether the validation step has succeeded here, by distinguishing array() != false?

Definition at line 2723 of file gateway.adapter.php.

Referenced by do_transaction().

◆ xmlChildrenToArray()

GatewayAdapter::xmlChildrenToArray ( $xml,
$nodename )
protected

Definition at line 1814 of file gateway.adapter.php.

Referenced by GlobalCollectAdapter\parseResponseData().

Member Data Documentation

◆ $account_config

GatewayAdapter::$account_config
protected

Definition at line 87 of file gateway.adapter.php.

Referenced by AstroPayAdapter\defineAccountInfo().

◆ $account_name

GatewayAdapter::$account_name
protected

Definition at line 86 of file gateway.adapter.php.

Referenced by findAccount().

◆ $accountInfo

GatewayAdapter::$accountInfo
protected

Definition at line 88 of file gateway.adapter.php.

◆ $action

string GatewayAdapter::$action
protected

Definition at line 170 of file gateway.adapter.php.

◆ $batch

GatewayAdapter::$batch = false
protected

Definition at line 182 of file gateway.adapter.php.

◆ $config

array GatewayAdapter::$config = []
protected

config tree

Definition at line 48 of file gateway.adapter.php.

Referenced by getConfig().

◆ $current_transaction

string GatewayAdapter::$current_transaction
protected

Name of the current transaction.

Set via

See also
setCurrentTransaction

Definition at line 168 of file gateway.adapter.php.

Referenced by getCurrentTransaction().

◆ $data_transformers

StagingHelper ValidationHelper [] GatewayAdapter::$data_transformers = []
protected

Data transformation helpers.

These implement the StagingHelper interface for now, and are responsible for staging and unstaging data.

Definition at line 115 of file gateway.adapter.php.

Referenced by getDataTransformers().

◆ $dataConstraints

array GatewayAdapter::$dataConstraints = []
protected

$dataConstraints provides information on how to handle variables.

 <code>
    'account_holder'        => [ 'type' => 'alphanumeric',      'length' => 50, ]
 </code>

Definition at line 59 of file gateway.adapter.php.

◆ $dataObj

DonationData GatewayAdapter::$dataObj
protected

◆ $debugarray

string [] GatewayAdapter::$debugarray

Definition at line 174 of file gateway.adapter.php.

◆ $error_map

array GatewayAdapter::$error_map = []
protected

$error_map Reference map from gateway error to client error.

The key of each error should map to a i18n message key or a callable By convention, the following three keys have these meanings: 'internal-0000' => 'message-key-1', // Failed failed pre-process checks. 'internal-0001' => 'message-key-2', // Transaction could not be processed due to an internal error. 'internal-0002' => 'message-key-3', // Communication failure A callable should return the translated error message. Any undefined key will map to 'donate_interface-processing-error' When formatted, each message key will be given the ProblemEmail global as a first parameter. Error messages that use other parameters should use the callable.

Definition at line 77 of file gateway.adapter.php.

◆ $errorState

ErrorState GatewayAdapter::$errorState
protected

List of errors preventing this transaction from continuing.

Definition at line 162 of file gateway.adapter.php.

◆ $final_status

string GatewayAdapter::$final_status
protected

When the smoke clears, this should be set to one of the constants defined in.

See also
FinalStatus

Definition at line 158 of file gateway.adapter.php.

Referenced by GlobalCollectAdapter\doRefund().

◆ $log_outbound

bool GatewayAdapter::$log_outbound = false

This should be set to true for gateways that don't return the request in the response.

See also
buildLogXML()

Definition at line 195 of file gateway.adapter.php.

◆ $logger

Psr Log LoggerInterface GatewayAdapter::$logger
protected

Standard logger, logs to {type}_gateway.

Definition at line 134 of file gateway.adapter.php.

◆ $order_id_candidates

GatewayAdapter::$order_id_candidates
protected

Definition at line 197 of file gateway.adapter.php.

◆ $order_id_meta

GatewayAdapter::$order_id_meta
protected

Definition at line 198 of file gateway.adapter.php.

◆ $payment_init_logger

Psr Log LoggerInterface GatewayAdapter::$payment_init_logger
protected

Logs to {type}_gateway_payment_init.

Definition at line 140 of file gateway.adapter.php.

◆ $payment_methods

array GatewayAdapter::$payment_methods = []
protected

$payment_methods will be defined by the adapter.

Definition at line 96 of file gateway.adapter.php.

Referenced by getPaymentMethods().

◆ $payment_submethods

array GatewayAdapter::$payment_submethods = []
protected

$payment_submethods will be defined by the adapter (or will default to an empty array if none are defined).

Definition at line 104 of file gateway.adapter.php.

Referenced by getPaymentSubmethods().

◆ $posted

bool GatewayAdapter::$posted = false

A boolean that will tell us if we've posted to ourselves.

A little more telling than WebRequest->wasPosted(), as something else could have posted to us.

Definition at line 181 of file gateway.adapter.php.

◆ $profiler

DonationProfiler GatewayAdapter::$profiler
protected

Times and logs various operations.

Definition at line 146 of file gateway.adapter.php.

◆ $return_value_map

GatewayAdapter::$return_value_map
protected

Definition at line 106 of file gateway.adapter.php.

◆ $risk_score

int GatewayAdapter::$risk_score = 0
protected

Definition at line 172 of file gateway.adapter.php.

◆ $staged_data

GatewayAdapter::$staged_data
protected

Definition at line 107 of file gateway.adapter.php.

Referenced by getData_Staged(), and unstageKeys().

◆ $transaction_response

PaymentTransactionResponse GatewayAdapter::$transaction_response
protected

$transaction_response is the member var that keeps track of the results of the latest discrete transaction with the gateway.

Definition at line 153 of file gateway.adapter.php.

Referenced by do_transaction_internal().

◆ $transactions

GatewayAdapter::$transactions
protected

Definition at line 89 of file gateway.adapter.php.

◆ $unstaged_data

GatewayAdapter::$unstaged_data
protected

◆ $var_map

array GatewayAdapter::$var_map = []
protected

$var_map maps gateway variables to client variables

Definition at line 84 of file gateway.adapter.php.

Referenced by unstageKeys().

◆ $xmlDoc

DomDocument GatewayAdapter::$xmlDoc
protected

For gateways that speak XML, we use this variable to hold the document while we build the outgoing request.

TODO: move XML functions out of the main gateway classes.

Definition at line 123 of file gateway.adapter.php.

◆ COMPLETED_PREFACE

const GatewayAdapter::COMPLETED_PREFACE = 'Completed donation: '

Definition at line 42 of file gateway.adapter.php.

◆ DONOR

const GatewayAdapter::DONOR = 'Donor'

◆ DONOR_BKUP

const GatewayAdapter::DONOR_BKUP = 'Donor_BKUP'

◆ GATEWAY_NAME

const GatewayAdapter::GATEWAY_NAME = 'Donation Gateway'

Definition at line 185 of file gateway.adapter.php.

◆ GLOBAL_PREFIX

const GatewayAdapter::GLOBAL_PREFIX = 'wgDonationGateway'

Definition at line 187 of file gateway.adapter.php.

◆ IDENTIFIER

const GatewayAdapter::IDENTIFIER = 'donation'

Definition at line 186 of file gateway.adapter.php.

◆ REDIRECT_PREFACE

const GatewayAdapter::REDIRECT_PREFACE = 'Redirecting for transaction: '

Don't change these strings without fixing cross-repo usages.

Definition at line 41 of file gateway.adapter.php.


The documentation for this class was generated from the following file: