protected function AuthorizeNet::chargeCard in Ubercart 8.4
Called when a credit card should be processed.
@todo Replace the return array with a typed object.
Parameters
\Drupal\uc_order\OrderInterface $order: The order that is being processed. Credit card details supplied by the user are available in $order->payment_details[].
float $amount: The amount that should be charged.
string $txn_type: The transaction type, one of the UC_CREDIT_* constants.
string $reference: (optional) The payment reference, where needed for specific transaction types.
Return value
array Returns an associative array with the following members:
- "success": TRUE if the transaction succeeded, FALSE otherwise.
- "message": a human-readable message describing the result of the transaction.
- "log_payment": TRUE if the transaction should be regarded as a successful payment.
- "uid": The user ID of the person logging the payment, or 0 if the payment was processed automatically.
- "comment": The comment string, markup allowed, to enter in the payment log.
- "data": Any data that should be serialized and stored with the payment.
Overrides CreditCardPaymentMethodBase::chargeCard
File
- payment/
uc_authorizenet/ src/ Plugin/ Ubercart/ PaymentMethod/ AuthorizeNet.php, line 243
Class
- AuthorizeNet
- Defines the Authorize.net payment method.
Namespace
Drupal\uc_authorizenet\Plugin\Ubercart\PaymentMethodCode
protected function chargeCard(OrderInterface $order, $amount, $txn_type, $reference = NULL) {
//function uc_authorizenet_charge($order_id, $amount, $data) {
// Perform the appropriate action based on the transaction type.
switch ($txn_type) {
// Reference transactions are handled through Authorize.Net's CIM.
case UC_CREDIT_REFERENCE_TXN:
return _uc_authorizenet_cim_profile_charge($order, $amount, $data);
// Set a reference only.
case UC_CREDIT_REFERENCE_SET:
// Return the error message if this failed.
if ($message = _uc_authorizenet_cim_profile_create($order)) {
return [
'success' => FALSE,
'message' => $message,
];
}
else {
return [
'success' => TRUE,
'log_payment' => FALSE,
'message' => $this
->t('New customer profile created successfully at Authorize.Net.'),
];
}
// Accommodate all other transaction types.
default:
return _uc_authorizenet_charge($order, $amount, $txn_type, $reference);
}
}