public function SquareApi::capture in Commerce Square Connect 7
Captures a transaction.
Parameters
object $transaction: The payment transaction.
Return value
\SquareConnect\Model\CaptureTransactionResponse The transaction response.
File
- includes/
SquareApi.php, line 144 - Square Connect SDK wrapper.
Class
- SquareApi
- A wrapper around the Square Connect SDK.
Code
public function capture($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
->captureTransaction($location_id, $transaction_id);
}