CRM_Core_Payment_AuthorizeNet
class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment
NOTE: When looking up response codes in the Authorize.Net API, they begin at one, so always delete one from the "Position in Response"
Constants
BILLING_MODE_FORM |
How are we getting billing information. We are trying to completely deprecate these parameters. FORM - we collect it on the same page BUTTON - the processor collects it and sends it back to us via some protocol |
BILLING_MODE_BUTTON |
How are we getting billing information. We are trying to completely deprecate these parameters. FORM - we collect it on the same page BUTTON - the processor collects it and sends it back to us via some protocol |
BILLING_MODE_NOTIFY |
How are we getting billing information. We are trying to completely deprecate these parameters. FORM - we collect it on the same page BUTTON - the processor collects it and sends it back to us via some protocol |
PAYMENT_TYPE_CREDIT_CARD |
Which payment type(s) are we using? credit card direct debit or both |
PAYMENT_TYPE_DIRECT_DEBIT |
Which payment type(s) are we using? credit card direct debit or both |
RECURRING_PAYMENT_START |
Subscription / Recurring payment Status START, END |
RECURRING_PAYMENT_END |
Subscription / Recurring payment Status START, END |
CHARSET |
|
AUTH_APPROVED |
|
AUTH_DECLINED |
|
AUTH_ERROR |
|
AUTH_REVIEW |
|
TIMEZONE |
|
Properties
protected string | $_component | Component - ie. event or contribute. | from CRM_Core_Payment |
protected array | $_paymentProcessor | from CRM_Core_Payment | |
protected string | $baseReturnUrl | Base url of the calling form (offsite processors). | from CRM_Core_Payment |
protected string | $successUrl | Return url upon success (offsite processors). | from CRM_Core_Payment |
protected string | $cancelUrl | Return url upon failure (offsite processors). | from CRM_Core_Payment |
string | $_processorName | Processor type label. | from CRM_Core_Payment |
protected int|string | $billingProfile | The profile configured to show on the billing form. | from CRM_Core_Payment |
protected int | $paymentInstrumentID | Payment instrument ID. | from CRM_Core_Payment |
protected bool | $backOffice | Is this a back office transaction. | from CRM_Core_Payment |
protected | $_mode | ||
protected | $_params |
Methods
Opportunity for the payment processor to override the entire form build.
Log payment notification message to forensic system log.
Can more than one transaction be processed at once?
Are live payments supported - e.g dummy doesn't support this.
Should the first payment date be configurable when setting up back office recurring payments.
Does this processor support cancelling recurring contributions through code.
Does this processor support updating billing info for recurring contributions through code.
Can recurring contributions be set against pledges.
Get any details that may be available to the payment processor due to an approval process having happened.
Default payment instrument validation.
Setter for the payment form that wants to use the processor.
Get help text information (help, description, etc.) about this payment, to display to the user.
Get array of fields that should be displayed on the payment form.
Get an array of the fields that can be edited on the recurring contribution.
Get the help text to present on the recurring update page.
Get the metadata of all the fields configured for this processor.
Get array of fields that should be displayed on the payment form for credit cards.
Get array of fields that should be displayed on the payment form for direct debits.
Return an array of all the details about the fields potentially required for payment fields.
Get billing fields required for this processor.
Get form metadata for billing address fields.
Get url to return to after cancelled or failed transaction.
Get URL to return the browser to on success.
Get URL to return the browser to on failure.
Submit a payment using Advanced Integration Method.
Process payment - this function wraps around both doTransferCheckout and doDirectPayment.
Query payment processor for details about a transaction.
This function checks to see if we have the right config values.
Payment callback handler.
Check whether a method is present ( & supported ) by the payment processor object.
Some processors replace the form submit button with their own.
Checks to see if invoice_id already exists in db.
Get url for users to manage this recurring contribution for this processor.
Get description of payment to pass to processor.
Checks if backoffice recurring edit is allowed
Does this processor support changing the amount for recurring contributions through code.
Checks if payment processor supports recurring contributions
Checks if payment processor supports an account login URL TODO: This is checked by self::subscriptionURL but is only used if no entityID is found.
Constructor.
Submit an Automated Recurring Billing subscription.
No description
Generate HMAC_MD5
Calculate and return the transaction fingerprint.
Split a CSV file. Requires , as delimiter and " as enclosure.
Extract variables from returned XML.
Helper function for _parseArbReturn.
Get the value of a field if set.
No description
Set a field to the specified value. Value must be a scalar (int, float, string, or boolean)
No description
No description
No description
Process incoming notification.
No description
Details
in CRM_Core_Payment at line 155
bool
isBackOffice()
in CRM_Core_Payment at line 164
setBackOffice(bool $isBackOffice)
Set back office property.
in CRM_Core_Payment at line 173
int
getPaymentInstrumentID()
Get payment instrument id.
in CRM_Core_Payment at line 182
int
getID()
Getter for the id.
in CRM_Core_Payment at line 193
setPaymentInstrumentID(int $paymentInstrumentID)
Set payment Instrument id.
By default we actually ignore the form value. The manual processor takes it more seriously.
in CRM_Core_Payment at line 205
setBaseReturnUrl(string $url)
Set base return path (offsite processors).
This is only useful with an internal civicrm form.
in CRM_Core_Payment at line 217
setSuccessUrl(string $url)
Set success return URL (offsite processors).
This overrides $baseReturnUrl
in CRM_Core_Payment at line 229
setCancelUrl(string $url)
Set cancel return URL (offsite processors).
This overrides $baseReturnUrl
in CRM_Core_Payment at line 238
setBillingProfile(int|string $value)
Set the configured payment profile.
in CRM_Core_Payment at line 250
bool
buildForm(CRM_Core_Form $form)
Opportunity for the payment processor to override the entire form build.
in CRM_Core_Payment at line 261
static
logPaymentNotification(array $params)
Log payment notification message to forensic system log.
in CRM_Core_Payment at line 293
bool
supports(string $capability)
Check if capability is supported.
Capabilities have a one to one relationship with capability-related functions on this class.
Payment processor classes should over-ride the capability-specific function rather than this one.
in CRM_Core_Payment at line 311
protected bool
supportsBackOffice()
Are back office payments supported.
e.g paypal standard won't permit you to enter a credit card associated with someone else's login. The intention is to support off-site (other than paypal) & direct debit but that is not all working yet so to reach a 'stable' point we disable.
in CRM_Core_Payment at line 329
protected bool
supportsMultipleConcurrentPayments()
Can more than one transaction be processed at once?
In general processors that process payment by server to server communication support this while others do not.
In future we are likely to hit an issue where this depends on whether a token already exists.
in CRM_Core_Payment at line 343
protected bool
supportsLiveMode()
Are live payments supported - e.g dummy doesn't support this.
in CRM_Core_Payment at line 352
protected bool
supportsTestMode()
Are test payments supported.
in CRM_Core_Payment at line 361
bool
supportsRefund()
Does this payment processor support refund?
at line 71
protected bool
supportsFutureRecurStartDate()
Should the first payment date be configurable when setting up back office recurring payments.
In the case of Authorize.net this is an option
in CRM_Core_Payment at line 385
protected bool
supportsCancelRecurring()
Does this processor support cancelling recurring contributions through code.
If the processor returns true it must be possible to take action from within CiviCRM that will result in no further payments being processed. In the case of token processors (e.g IATS, eWay) updating the contribution_recur table is probably sufficient.
in CRM_Core_Payment at line 400
protected bool
supportsPreApproval()
Does this processor support pre-approval.
This would generally look like a redirect to enter credentials which can then be used in a later payment call.
Currently Paypal express supports this, with a redirect to paypal after the 'Main' form is submitted in the contribution page. This token can then be processed at the confirm phase. Although this flow 'looks' like the 'notify' flow a key difference is that in the notify flow they don't have to return but in this flow they do.
in CRM_Core_Payment at line 412
protected bool
supportsUpdateSubscriptionBillingInfo()
Does this processor support updating billing info for recurring contributions through code.
If the processor returns true then it must be possible to update billing info from within CiviCRM that will be updated at the payment processor.
at line 87
protected bool
supportsRecurContributionsForPledges()
Can recurring contributions be set against pledges.
In practice all processors that use the baseIPN function to finish transactions or call the completetransaction api support this by looking up previous contributions in the series and, if there is a prior contribution against a pledge, and the pledge is not complete, adding the new payment to the pledge.
However, only enabling for processors it has been tested against.
in CRM_Core_Payment at line 442
doPreApproval(array $params)
Function to action pre-approval if supported
in CRM_Core_Payment at line 455
array
getPreApprovalDetails(array $storedDetails)
Get any details that may be available to the payment processor due to an approval process having happened.
In some cases the browser is redirected to enter details on a processor site. Some details may be available as a result.
in CRM_Core_Payment at line 468
validatePaymentInstrument(array $values, array $errors)
Default payment instrument validation.
Implement the usual Luhn algorithm via a static function in the CRM_Core_Payment_Form if it's a credit card Not a static function, because I need to check for payment_type.
in CRM_Core_Payment at line 483
array
getPaymentProcessor()
Getter for the payment processor.
The payment processor array is based on the civicrm_payment_processor table entry.
in CRM_Core_Payment at line 492
setPaymentProcessor(array $processor)
Setter for the payment processor.
in CRM_Core_Payment at line 503
setForm(CRM_Core_Form $paymentForm)
deprecated
deprecated
Setter for the payment form that wants to use the processor.
in CRM_Core_Payment at line 513
CRM_Core_Form
getForm()
deprecated
deprecated
Getter for payment form that is using the processor.
in CRM_Core_Payment at line 532
string
getText(string $context, array $params)
Get help text information (help, description, etc.) about this payment, to display to the user.
in CRM_Core_Payment at line 579
null
getVar(string $name)
Getter for accessing member vars.
in CRM_Core_Payment at line 588
string
getPaymentTypeName()
Get name for the payment information type.
in CRM_Core_Payment at line 597
string
getPaymentTypeLabel()
Get label for the payment information type.
in CRM_Core_Payment at line 616
array
getPaymentFormFields()
Get array of fields that should be displayed on the payment form.
Common results are array('credit_card_type', 'credit_card_number', 'cvv2', 'credit_card_exp_date') or array('account_holder', 'bank_account_number', 'bank_identification_number', 'bank_name') or array()
in CRM_Core_Payment at line 648
array
getEditableRecurringScheduleFields()
Get an array of the fields that can be edited on the recurring contribution.
Some payment processors support editing the amount and other scheduling details of recurring payments, especially those which use tokens. Others are fixed. This function allows the processor to return an array of the fields that can be updated from the contribution recur edit screen.
The fields are likely to be a subset of these - 'amount', - 'installments', - 'frequency_interval', - 'frequency_unit', - 'cycle_day', - 'next_sched_contribution_date', - 'end_date', - 'failure_retry_day',
The form does not restrict which fields from the contribution_recur table can be added (although if the html_type metadata is not defined in the xml for the field it will cause an error.
Open question - would it make sense to return membership_id in this - which is sometimes editable and is on that form (UpdateSubscription).
in CRM_Core_Payment at line 662
string
getRecurringScheduleUpdateHelpText()
Get the help text to present on the recurring update page.
This should reflect what can or cannot be edited.
in CRM_Core_Payment at line 674
protected array;
getMandatoryFields()
Get the metadata for all required fields.
in CRM_Core_Payment at line 689
protected array
getAllFields()
Get the metadata of all the fields configured for this processor.
in CRM_Core_Payment at line 700
protected array
getCreditCardFormFields()
Get array of fields that should be displayed on the payment form for credit cards.
in CRM_Core_Payment at line 714
protected array
getDirectDebitFormFields()
Get array of fields that should be displayed on the payment form for direct debits.
in CRM_Core_Payment at line 731
array
getPaymentFormFieldsMetadata()
Return an array of all the details about the fields potentially required for payment fields.
Only those determined by getPaymentFormFields will actually be assigned to the form
in CRM_Core_Payment at line 903
array
getBillingAddressFields(int $billingLocationID = NULL)
Get billing fields required for this processor.
We apply the existing default of returning fields only for payment processor type 1. Processors can override to alter.
in CRM_Core_Payment at line 933
array
getBillingAddressFieldsMetadata(int $billingLocationID = NULL)
Get form metadata for billing address fields.
in CRM_Core_Payment at line 1047
protected string
getBaseReturnUrl()
Get base url dependent on component.
(or preferably set it using the setter function).
in CRM_Core_Payment at line 1069
protected string
getCurrency($params)
Get the currency for the transaction.
Handle any inconsistency about how it is passed in here.
in CRM_Core_Payment at line 1082
protected string
getAmount($params)
Get the currency for the transaction.
Handle any inconsistency about how it is passed in here.
in CRM_Core_Payment at line 1094
string
getCancelUrl(string $qfKey, int $participantID)
Get url to return to after cancelled or failed transaction.
in CRM_Core_Payment at line 1125
protected string
getReturnSuccessUrl($qfKey)
Get URL to return the browser to on success.
in CRM_Core_Payment at line 1148
protected string
getReturnFailUrl(string $key, int $participantID = NULL, int $eventID = NULL)
Get URL to return the browser to on failure.
in CRM_Core_Payment at line 1175
protected string
getGoBackUrl($qfKey)
Get URl for when the back button is pressed.
in CRM_Core_Payment at line 1193
protected string
getNotifyUrl()
Get the notify (aka ipn, web hook or silent post) url.
If there is no '.' in it we assume that we are dealing with localhost or similar and it is unreachable from the web & hence invalid.
at line 100
array
doDirectPayment(array $params)
Submit a payment using Advanced Integration Method.
in CRM_Core_Payment at line 1244
array
doPayment(array $params, string $component = 'contribute')
Process payment - this function wraps around both doTransferCheckout and doDirectPayment.
Any processor that still implements the deprecated doTransferCheckout() or doDirectPayment() should be updated to use doPayment().
This function adds some historical defaults ie. the assumption that if a 'doDirectPayment' processors comes back it completed the transaction & in fact doTransferCheckout would not traditionally come back. Payment processors should throw exceptions and not return Error objects as they may have done with the old functions.
Payment processors should set payment_status_id (which is really contribution_status_id) in the returned array. The default is assumed to be Pending. In some cases the IPN will set the payment to "Completed" some time later.
in CRM_Core_Payment at line 1289
doRefund(array $params)
Refunds payment
Payment processors should set payment_status_id if it set the status to Refunded in case the transaction is successful
in CRM_Core_Payment at line 1305
array
doQuery(array $params)
Query payment processor for details about a transaction.
at line 599
string
checkConfig()
This function checks to see if we have the right config values.
in CRM_Core_Payment at line 1326
static bool
paypalRedirect($paymentProcessor)
Redirect for paypal.
in CRM_Core_Payment at line 1350
static
handleIPN()
Handle incoming payment notification.
IPNs, also called silent posts are notifications of payment outcomes or activity on an external site.
in CRM_Core_Payment at line 1388
static
handlePaymentMethod(string $method, array $params = [])
Payment callback handler.
The processor_name or processor_id is passed in. Note that processor_id is more reliable as one site may have more than one instance of a processor & ideally the processor will be validating the results Load requested payment processor and call that processor's handle<$method> method
in CRM_Core_Payment at line 1490
bool
isSupported(string $method)
deprecated
deprecated
Check whether a method is present ( & supported ) by the payment processor object.
in CRM_Core_Payment at line 1501
isSuppressSubmitButtons()
Some processors replace the form submit button with their own.
Returning false here will leave the button off front end forms.
At this stage there is zero cross-over between back-office processors and processors that suppress the submit.
in CRM_Core_Payment at line 1519
protected bool
checkDupe(int $invoiceId, null $contributionID = NULL)
Checks to see if invoice_id already exists in db.
It's arguable if this belongs in the payment subsystem at all but since several processors implement it it is better to standardise to being here.
in CRM_Core_Payment at line 1537
string
subscriptionURL(int $entityID = NULL, null $entity = NULL, string $action = 'cancel')
Get url for users to manage this recurring contribution for this processor.
in CRM_Core_Payment at line 1630
protected string
getPaymentDescription(array $params, int $length = 24)
Get description of payment to pass to processor.
This is often what people see in the interface so we want to get as much unique information in as possible within the field length (& presumably the early part of the field)
People seeing these can be assumed to be advanced users so quantity of information probably trumps having field names to clarify
in CRM_Core_Payment at line 1659
bool
supportsEditRecurringContribution()
Checks if backoffice recurring edit is allowed
in CRM_Core_Payment at line 1671
protected bool
supportsChangeSubscriptionAmount()
Does this processor support changing the amount for recurring contributions through code.
If the processor returns true then it must be possible to update the amount from within CiviCRM that will be updated at the payment processor.
in CRM_Core_Payment at line 1680
bool
supportsRecurring()
Checks if payment processor supports recurring contributions
in CRM_Core_Payment at line 1694
protected bool
supportsAccountLoginURL()
Checks if payment processor supports an account login URL TODO: This is checked by self::subscriptionURL but is only used if no entityID is found.
TODO: It is implemented by AuthorizeNET, any others?
in CRM_Core_Payment at line 1703
isSendReceiptForPending()
Should a receipt be sent out for a pending payment.
e.g for traditional pay later & ones with a delayed settlement a pending receipt makes sense.
at line 51
CRM_Core_Payment_AuthorizeNet
__construct(string $mode, $paymentProcessor)
Constructor.
at line 221
doRecurPayment()
Submit an Automated Recurring Billing subscription.
at line 357
array
_getAuthorizeNetFields()
at line 412
string
hmac(string $key, string $data)
Generate HMAC_MD5
at line 442
string
CalculateFP()
Calculate and return the transaction fingerprint.
at line 463
array
explode_csv(string $data)
Split a CSV file. Requires , as delimiter and " as enclosure.
Based off notes from http://php.net/fgetcsv
at line 500
array
_parseArbReturn(string $content)
Extract variables from returned XML.
Function is from Authorize.Net sample code, and used to prevent the requirement of XML functions.
at line 527
bool|string
_substring_between(string $haystack, string $start, string $end)
Helper function for _parseArbReturn.
Function is from Authorize.Net sample code, and used to avoid using PHP5 XML functions
at line 549
mixed
_getParam(string $field, bool $xmlSafe = FALSE)
Get the value of a field if set.
at line 563
object
error(null $errorCode = NULL, null $errorMessage = NULL)
at line 584
bool
_setParam(string $field, mixed $value)
Set a field to the specified value. Value must be a scalar (int, float, string, or boolean)
at line 620
string
accountLoginURL()
at line 630
bool|object
cancelSubscription(string $message = '', array $params = [])
at line 677
bool|object
updateSubscriptionBillingInfo(string $message = '', array $params = [])
at line 733
static
handlePaymentNotification()
Process incoming notification.