/**
  * Parse and Authenticate the incoming notification from Genesis
  *
  * @param array $notification - Incoming notification ($_POST)
  * @param bool  $authenticate - Set to true if you want to validate the notification
  *
  * @throws \Genesis\Exceptions\InvalidArgument()
  */
 public function parseNotification($notification = array(), $authenticate = true)
 {
     $notificationWalk = array();
     array_walk($notification, function ($val, $key) use(&$notificationWalk) {
         $key = trim(rawurldecode($key));
         $val = trim(rawurldecode($val));
         $notificationWalk[$key] = $val;
     });
     $notification = $notificationWalk;
     $this->notificationObj = \Genesis\Utils\Common::createArrayObject($notification);
     if ($this->isAPINotification()) {
         $this->unique_id = (string) $this->notificationObj->unique_id;
     }
     if ($this->isWPFNotification()) {
         $this->unique_id = (string) $this->notificationObj->wpf_unique_id;
     }
     if ($authenticate && !$this->isAuthentic()) {
         throw new \Genesis\Exceptions\InvalidArgument('Invalid Genesis Notification!');
     }
 }
Example #2
0
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('payment_transaction' => array('transaction_type' => \Genesis\API\Constants\Transaction\Types::VOID, 'transaction_id' => $this->transaction_id, 'usage' => $this->usage, 'remote_ip' => $this->remote_ip, 'reference_id' => $this->reference_id));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('blacklist_request' => array('card_number' => $this->card_number, 'terminal_token' => $this->terminal_token));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * 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;
 }
Example #5
0
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('wpf_payment' => array('transaction_id' => $this->transaction_id, 'amount' => $this->transform('amount', array($this->amount, $this->currency)), 'currency' => $this->currency, 'usage' => $this->usage, 'description' => $this->description, 'customer_email' => $this->customer_email, 'customer_phone' => $this->customer_phone, 'notification_url' => $this->notification_url, 'return_success_url' => $this->return_success_url, 'return_failure_url' => $this->return_failure_url, 'return_cancel_url' => $this->return_cancel_url, 'billing_address' => array('first_name' => $this->billing_first_name, 'last_name' => $this->billing_last_name, 'address1' => $this->billing_address1, 'address2' => $this->billing_address2, 'zip_code' => $this->billing_zip_code, 'city' => $this->billing_city, 'state' => $this->billing_state, 'country' => $this->billing_country), 'shipping_address' => array('first_name' => $this->shipping_first_name, 'last_name' => $this->shipping_last_name, 'address1' => $this->shipping_address1, 'address2' => $this->shipping_address2, 'zip_code' => $this->shipping_zip_code, 'city' => $this->shipping_city, 'state' => $this->shipping_state, 'country' => $this->shipping_country), 'transaction_types' => $this->transaction_types, 'risk_params' => array('ssn' => $this->risk_ssn, 'mac_address' => $this->risk_mac_address, 'session_id' => $this->risk_session_id, 'user_id' => $this->risk_user_id, 'user_level' => $this->risk_user_level, 'email' => $this->risk_email, 'phone' => $this->risk_phone, 'remote_ip' => $this->risk_remote_ip, 'serial_number' => $this->risk_serial_number)));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('wpf_reconcile' => array('unique_id' => $this->unique_id));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Read through the entire document
  *
  * @param \XMLReader $reader
  * @return mixed
  */
 public function readerLoop($reader)
 {
     $tree = new \stdClass();
     while ($reader->read()) {
         switch ($reader->nodeType) {
             case \XMLReader::END_ELEMENT:
                 return $tree;
             case \XMLReader::ELEMENT:
                 $this->processElement($reader, $tree);
                 if ($reader->hasAttributes) {
                     $this->processAttributes($reader, $tree);
                 }
                 break;
             case \XMLReader::TEXT:
             case \XMLReader::CDATA:
                 $tree = \Genesis\Utils\Common::stringToBoolean(trim($reader->expand()->textContent));
                 break;
         }
     }
     return $tree;
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('payment_transaction' => array('transaction_type' => \Genesis\API\Constants\Transaction\Types::ACCOUNT_VERIFICATION, 'transaction_id' => $this->transaction_id, 'usage' => $this->usage, 'moto' => $this->moto, 'remote_ip' => $this->remote_ip, 'card_holder' => $this->card_holder, 'card_number' => $this->card_number, 'cvv' => $this->cvv, 'expiration_month' => $this->expiration_month, 'expiration_year' => $this->expiration_year, 'customer_email' => $this->customer_email, 'customer_phone' => $this->customer_phone, 'billing_address' => array('first_name' => $this->billing_first_name, 'last_name' => $this->billing_last_name, 'address1' => $this->billing_address1, 'address2' => $this->billing_address2, 'zip_code' => $this->billing_zip_code, 'city' => $this->billing_city, 'state' => $this->billing_state, 'country' => $this->billing_country), 'shipping_address' => array('first_name' => $this->shipping_first_name, 'last_name' => $this->shipping_last_name, 'address1' => $this->shipping_address1, 'address2' => $this->shipping_address2, 'zip_code' => $this->shipping_zip_code, 'city' => $this->shipping_city, 'state' => $this->shipping_state, 'country' => $this->shipping_country), 'risk_params' => array('ssn' => $this->risk_ssn, 'mac_address' => $this->risk_mac_address, 'session_id' => $this->risk_session_id, 'user_id' => $this->risk_user_id, 'user_level' => $this->risk_user_level, 'email' => $this->risk_email, 'phone' => $this->risk_phone, 'remote_ip' => $this->risk_remote_ip, 'serial_number' => $this->risk_serial_number)));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('payment_transaction' => array('transaction_type' => \Genesis\API\Constants\Transaction\Types::PPRO, 'transaction_id' => $this->transaction_id, 'payment_type' => $this->payment_type, 'usage' => $this->usage, 'remote_ip' => $this->remote_ip, 'amount' => $this->transform('amount', array($this->amount, $this->currency)), 'currency' => $this->currency, 'return_success_url' => $this->return_success_url, 'return_failure_url' => $this->return_failure_url, 'customer_email' => $this->customer_email, 'customer_phone' => $this->customer_phone, 'account_number' => $this->account_number, 'bank_code' => $this->bank_code, 'bic' => $this->bic, 'iban' => $this->iban, 'account_phone' => $this->account_phone, 'billing_address' => array('first_name' => $this->billing_first_name, 'last_name' => $this->billing_last_name, 'address1' => $this->billing_address1, 'address2' => $this->billing_address2, 'zip_code' => $this->billing_zip_code, 'city' => $this->billing_city, 'state' => $this->billing_state, 'country' => $this->billing_country), 'shipping_address' => array('first_name' => $this->shipping_first_name, 'last_name' => $this->shipping_last_name, 'address1' => $this->shipping_address1, 'address2' => $this->shipping_address2, 'zip_code' => $this->shipping_zip_code, 'city' => $this->shipping_city, 'state' => $this->shipping_state, 'country' => $this->shipping_country), 'risk_params' => array('ssn' => $this->risk_ssn, 'mac_address' => $this->risk_mac_address, 'session_id' => $this->risk_session_id, 'user_id' => $this->risk_user_id, 'user_level' => $this->risk_user_level, 'email' => $this->risk_email, 'phone' => $this->risk_phone, 'remote_ip' => $this->risk_remote_ip, 'serial_number' => $this->risk_serial_number)));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Set the per-request configuration
  *
  * @return void
  */
 protected function initConfiguration()
 {
     $this->config = \Genesis\Utils\Common::createArrayObject(array('protocol' => 'https', 'port' => 443, 'type' => 'GET', 'format' => 'plain'));
     $this->setApiConfig('url', $this->buildRequestURL('gateway', 'retrieve_abn_ideal_banks', false));
 }
 /**
  * Parse and Authenticate the incoming notification from Genesis
  *
  * @param array $notification - Incoming notification ($_POST)
  * @param bool  $authenticate - Set to true if you want to validate the notification
  *
  * @throws \Genesis\Exceptions\InvalidArgument()
  */
 public function parseNotification($notification = array(), $authenticate = true)
 {
     $this->notificationObj = \Genesis\Utils\Common::createArrayObject($notification);
     if (isset($this->notificationObj->unique_id) && !empty($this->notificationObj->unique_id)) {
         $this->isAPINotification = true;
         $this->unique_id = (string) $this->notificationObj->unique_id;
     }
     if (isset($this->notificationObj->wpf_unique_id) && !empty($this->notificationObj->wpf_unique_id)) {
         $this->isWPFNotification = true;
         $this->unique_id = (string) $this->notificationObj->wpf_unique_id;
     }
     if ($authenticate && !$this->isAuthentic()) {
         throw new \Genesis\Exceptions\InvalidArgument('Invalid Genesis Notification!');
     }
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('payment_transaction' => array('transaction_type' => \Genesis\API\Constants\Transaction\Types::PAYOUT, 'transaction_id' => $this->transaction_id, 'usage' => $this->usage, 'amount' => $this->transform('amount', array($this->amount, $this->currency)), 'currency' => $this->currency, 'remote_ip' => $this->remote_ip, 'card_holder' => $this->card_holder, 'card_number' => $this->card_number, 'cvv' => $this->cvv, 'expiration_month' => $this->expiration_month, 'expiration_year' => $this->expiration_year, 'customer_email' => $this->customer_email, 'customer_phone' => $this->customer_phone, 'billing_address' => array('first_name' => $this->billing_first_name, 'last_name' => $this->billing_last_name, 'address1' => $this->billing_address1, 'address2' => $this->billing_address2, 'zip_code' => $this->billing_zip_code, 'city' => $this->billing_city, 'state' => $this->billing_state, 'country' => $this->billing_country), 'shipping_address' => array('first_name' => $this->shipping_first_name, 'last_name' => $this->shipping_last_name, 'address1' => $this->shipping_address1, 'address2' => $this->shipping_address2, 'zip_code' => $this->shipping_zip_code, 'city' => $this->shipping_city, 'state' => $this->shipping_state, 'country' => $this->shipping_country)));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
Example #13
0
 /**
  * Apply transformation:
  *
  * Encode a string in base64 or return
  * the input if already in base64
  *
  * @param string $input
  *
  * @return mixed
  */
 protected function transformWalletPassword($input = '')
 {
     if (!\Genesis\Utils\Common::isBase64Encoded($input)) {
         return base64_encode($input);
     }
     return $input;
 }
Example #14
0
 /**
  * Write XML Element
  *
  * @param $key
  * @param $value
  */
 public function writeElement($key, $value)
 {
     if (is_array($value)) {
         $this->iterateArray($key, $value);
     } else {
         $value = \Genesis\Utils\Common::booleanToString($value);
         $this->context->writeElement($key, $value);
     }
 }
 /**
  * Handle "magic" calls
  *
  * @param $method
  * @param $args
  *
  * @return $this|bool
  */
 public function __call($method, $args)
 {
     list($action, $target) = \Genesis\Utils\Common::resolveDynamicMethod($method);
     switch ($action) {
         case 'is':
             if (isset($this->status)) {
                 return $this->compare($target);
             }
             break;
         default:
             break;
     }
     return null;
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('payment_transaction' => array('transaction_type' => \Genesis\API\Constants\Transaction\Types::CREDIT, 'transaction_id' => $this->transaction_id, 'usage' => $this->usage, 'remote_ip' => $this->remote_ip, 'reference_id' => $this->reference_id, 'amount' => $this->transform('amount', array($this->amount, $this->currency)), 'currency' => $this->currency));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Check the PHP interpreter version we're currently running
  *
  * @throws \Exception
  */
 public static function checkSystemVersion()
 {
     if (\Genesis\Utils\Common::compareVersions('5.3.2', '<')) {
         throw new \Exception(self::getErrorMessage('system'));
     }
 }
Example #18
0
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('payment_transaction' => array('transaction_type' => \Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_YEEPAY, 'transaction_id' => $this->transaction_id, 'card_type' => $this->card_type, 'redeem_type' => $this->redeem_type, 'remote_ip' => $this->remote_ip, 'amount' => $this->transform('amount', array($this->amount, $this->currency)), 'currency' => $this->currency, 'product_name' => $this->product_name, 'product_category' => $this->product_category, 'customer_name' => $this->customer_name, 'customer_email' => $this->customer_email, 'customer_phone' => $this->customer_phone, 'customer_id_number' => $this->customer_id_number, 'customer_bank_id' => $this->customer_bank_id, 'bank_account_number' => $this->bank_account_number));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('payment_transaction' => array('transaction_type' => \Genesis\API\Constants\Transaction\Types::EZEEWALLET, 'transaction_id' => $this->transaction_id, 'usage' => $this->usage, 'remote_ip' => $this->remote_ip, 'amount' => $this->transform('amount', array($this->amount, $this->currency)), 'currency' => $this->currency, 'return_success_url' => $this->return_success_url, 'return_failure_url' => $this->return_failure_url, 'source_wallet_id' => $this->source_wallet_id, 'source_wallet_pwd' => $this->transform('wallet_password', array($this->source_wallet_pwd))));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('payment_transaction' => array('transaction_type' => \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE, 'transaction_id' => $this->transaction_id, 'usage' => $this->usage, 'gaming' => $this->gaming, 'moto' => $this->moto, 'remote_ip' => $this->remote_ip, 'amount' => $this->transform('amount', array($this->amount, $this->currency)), 'currency' => $this->currency, 'card_holder' => $this->card_holder, 'card_number' => $this->card_number, 'cvv' => $this->cvv, 'expiration_month' => $this->expiration_month, 'expiration_year' => $this->expiration_year, 'customer_email' => $this->customer_email, 'customer_phone' => $this->customer_phone, 'birth_date' => $this->birth_date, 'billing_address' => array('first_name' => $this->billing_first_name, 'last_name' => $this->billing_last_name, 'address1' => $this->billing_address1, 'address2' => $this->billing_address2, 'zip_code' => $this->billing_zip_code, 'city' => $this->billing_city, 'state' => $this->billing_state, 'country' => $this->billing_country), 'shipping_address' => array('first_name' => $this->shipping_first_name, 'last_name' => $this->shipping_last_name, 'address1' => $this->shipping_address1, 'address2' => $this->shipping_address2, 'zip_code' => $this->shipping_zip_code, 'city' => $this->shipping_city, 'state' => $this->shipping_state, 'country' => $this->shipping_country), 'risk_params' => array('ssn' => $this->risk_ssn, 'mac_address' => $this->risk_mac_address, 'session_id' => $this->risk_session_id, 'user_id' => $this->risk_user_id, 'user_level' => $this->risk_user_level, 'email' => $this->risk_email, 'phone' => $this->risk_phone, 'remote_ip' => $this->risk_remote_ip, 'serial_number' => $this->risk_serial_number), 'dynamic_descriptor_params' => array('merchant_name' => $this->dynamic_merchant_name, 'merchant_city' => $this->dynamic_merchant_city)));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * Set Stream parameters: url, data, auth etc.
  *
  * @param array $requestData
  *
  * @return void
  */
 public function prepareRequestBody($requestData)
 {
     $url = parse_url($requestData['url']);
     $headers = array('Content-Type: text/xml', sprintf('Authorization: Basic %s', base64_encode($requestData['user_login'])), sprintf('Content-Length: %s', strlen($requestData['body'])), sprintf('User-Agent: %s', $requestData['user_agent']));
     $contextOptions = array('http' => array('method' => $requestData['type'], 'header' => implode("\r\n", $headers), 'content' => $requestData['body'], 'timeout' => $requestData['timeout']), 'ssl' => array('allow_self_signed' => false, 'cafile' => $requestData['ca_bundle'], 'verify_peer' => true, 'verify_depth' => 10, 'SNI_enabled' => true, 'ciphers' => implode(':', self::getCiphers())));
     // Note: Mitigate CRIME/BEAST attacks
     if (\Genesis\Utils\Common::compareVersions('5.4.13', '>=')) {
         $contextOptions['ssl']['disable_compression'] = true;
     }
     // Note: PHP does NOT support SAN certs on PHP version < 5.6
     if (\Genesis\Utils\Common::compareVersions('5.6.0', '<')) {
         $contextOptions['ssl']['CN_match'] = $url['host'];
         $contextOptions['ssl']['SNI_server_name'] = $url['host'];
     } else {
         $contextOptions['ssl']['peer_name'] = $url['host'];
         $contextOptions['ssl']['verify_peer_name'] = true;
     }
     $this->streamContext = stream_context_create($contextOptions);
     $this->requestData = $requestData;
 }
Example #22
0
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('retrieval_request_request' => array('start_date' => $this->start_date, 'end_date' => $this->end_date, 'page' => $this->page));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
Example #23
0
 /**
  * Check whether the transaction was partially approved
  *
  * @see Genesis_API_Documentation for more information
  *
  * @return bool | null (if inapplicable)
  */
 public function isPartiallyApproved()
 {
     if (isset($this->responseObj->partial_approval)) {
         return \Genesis\Utils\Common::stringToBoolean($this->responseObj->partial_approval);
     }
     return null;
 }
 /**
  * Create the request's Tree structure
  *
  * @return void
  */
 protected function populateStructure()
 {
     $treeStructure = array('chargeback_request' => array('arn' => $this->arn, 'original_transaction_unique_id' => $this->original_transaction_unique_id));
     $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
 }
 /**
  * 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);
 }