/** * Perform a field transformation * and return the result * * @param string $method * @param array $args * @param string $prefix * * @return mixed */ protected function transform($method, $args, $prefix = 'transform') { $method = $prefix . \Genesis\Utils\Common::snakeCaseToCamelCase($method); if (method_exists($this, $method)) { $result = call_user_func_array(array($this, $method), $args); if ($result) { return $result; } } return reset($args); }
/** * Initiate a Payment Gateway Reference Transaction * - Capture * - Refund * - Void * * @param string $transactionType * @param \Magento\Payment\Model\InfoInterface $payment * @param array $data * @return \stdClass */ protected function processReferenceTransaction($transactionType, \Magento\Payment\Model\InfoInterface $payment, $data) { $transactionType = ucfirst(strtolower($transactionType)); $this->getConfigHelper()->initGatewayClient(); $genesis = new \Genesis\Genesis("Financial\\{$transactionType}"); foreach ($data as $key => $value) { $methodName = sprintf("set%s", \Genesis\Utils\Common::snakeCaseToCamelCase($key)); $genesis->request()->{$methodName}($value); } $genesis->execute(); $responseObject = $genesis->response()->getResponseObject(); $payment->setTransactionId($responseObject->unique_id)->setParentTransactionId($data['reference_id'])->setShouldCloseParentTransaction(true)->setIsTransactionPending(false)->setIsTransactionClosed(true)->resetTransactionAdditionalInfo(); $this->getModuleHelper()->setPaymentTransactionAdditionalInfo($payment, $responseObject); $payment->save(); return $responseObject; }