You are here

public function SquareApi::void in Commerce Square Connect 7

Voids a transaction.

Parameters

object $transaction: The payment transaction.

Return value

\SquareConnect\Model\VoidTransactionResponse The transaction response.

File

includes/SquareApi.php, line 87
Square Connect SDK wrapper.

Class

SquareApi
A wrapper around the Square Connect SDK.

Code

public function void($transaction) {
  $payment_method = commerce_payment_method_instance_load($transaction->instance_id);
  $mode = $payment_method['settings']['mode'];
  $location_id = $mode = $payment_method['settings'][$mode . '_location_id'];
  list($transaction_id, $tender_id) = explode('|', $transaction->remote_id);
  $transaction_api = new TransactionsApi($this
    ->getClient());
  return $transaction_api
    ->voidTransaction($location_id, $transaction_id);
}