Ejemplo n.º 1
0
 /**
  * Create a Web-Payment Form Instance
  * @param array $data
  * @return \stdClass
  * @throws \Magento\Framework\Webapi\Exception
  */
 protected function checkout($data)
 {
     $genesis = new \Genesis\Genesis('WPF\\Create');
     $genesis->request()->setTransactionId($data['transaction_id'])->setCurrency($data['order']['currency'])->setAmount($data['order']['amount'])->setUsage($data['order']['usage'])->setDescription($data['order']['description'])->setCustomerPhone(strval($data['order']['billing']->getTelephone()))->setCustomerEmail(strval($data['order']['customer']['email']))->setNotificationUrl($data['urls']['notify'])->setReturnSuccessUrl($data['urls']['return_success'])->setReturnFailureUrl($data['urls']['return_failure'])->setReturnCancelUrl($data['urls']['return_cancel'])->setBillingFirstName(strval($data['order']['billing']->getFirstname()))->setBillingLastName(strval($data['order']['billing']->getLastname()))->setBillingAddress1(strval($data['order']['billing']->getStreetLine(1)))->setBillingAddress2(strval($data['order']['billing']->getStreetLine(2)))->setBillingZipCode(strval($data['order']['billing']->getPostcode()))->setBillingCity(strval($data['order']['billing']->getCity()))->setBillingState(strval($data['order']['billing']->getRegionCode()))->setBillingCountry(strval($data['order']['billing']->getCountryId()))->setLanguage($data['order']['language']);
     if (!empty($data['order']['shipping'])) {
         $genesis->request()->setShippingFirstName(strval($data['order']['shipping']->getFirstname()))->setShippingLastName(strval($data['order']['shipping']->getLastname()))->setShippingAddress1(strval($data['order']['shipping']->getStreetLine(1)))->setShippingAddress2(strval($data['order']['shipping']->getStreetLine(2)))->setShippingZipCode(strval($data['order']['shipping']->getPostcode()))->setShippingCity(strval($data['order']['shipping']->getCity()))->setShippingState(strval($data['order']['shipping']->getRegionCode()))->setShippingCountry(strval($data['order']['shipping']->getCountryId()));
     }
     foreach ($this->getCheckoutTransactionTypes() as $type) {
         if (is_array($type)) {
             $genesis->request()->addTransactionType($type['name'], $type['parameters']);
         } else {
             if (\Genesis\API\Constants\Transaction\Types::isPayByVoucher($type)) {
                 $parameters = ['card_type' => \Genesis\API\Constants\Transaction\Parameters\PayByVouchers\CardTypes::VIRTUAL, 'redeem_type' => \Genesis\API\Constants\Transaction\Parameters\PayByVouchers\RedeemTypes::INSTANT];
                 if ($type == \Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_YEEPAY) {
                     $parameters['product_name'] = $data['order']['description'];
                     $parameters['product_category'] = $data['order']['description'];
                 }
                 $genesis->request()->addTransactionType($type, $parameters);
             } else {
                 $genesis->request()->addTransactionType($type);
             }
         }
     }
     $genesis->execute();
     return $genesis->response()->getResponseObject();
 }
Ejemplo n.º 2
0
 /**
  * Processes initial transactions
  *      - Authorize
  *      - Authorize3D
  *      - Sale
  *      - Sale3D
  *
  * @param \Magento\Payment\Model\InfoInterface $payment
  * @param $amount
  * @return $this
  * @throws \Exception
  * @throws \Genesis\Exceptions\ErrorAPI
  */
 protected function processInitialTransaction(\Magento\Payment\Model\InfoInterface $payment, $amount)
 {
     $transactionType = $this->getTransactionType();
     $order = $payment->getOrder();
     $helper = $this->getModuleHelper();
     $config = $helper->getTransactionConfig($transactionType);
     $this->getConfigHelper()->initGatewayClient();
     $billing = $order->getBillingAddress();
     if (empty($billing)) {
         throw new \Exception(__('Billing address is empty.'));
     }
     $shipping = $order->getShippingAddress();
     $genesis = new \Genesis\Genesis($config->request);
     $genesis->request()->setTransactionId($helper->genTransactionId($order->getIncrementId()))->setRemoteIp($order->getRemoteIp())->setUsage($helper->buildOrderDescriptionText($order))->setLanguage($helper->getLocale())->setCurrency($order->getBaseCurrencyCode())->setAmount($amount);
     if (!empty($payment->getCcOwner())) {
         $genesis->request()->setCardHolder($payment->getCcOwner());
     } else {
         $genesis->request()->setCardHolder($billing->getFirstname() . ' ' . $billing->getLastname());
     }
     $genesis->request()->setCardNumber($payment->getCcNumber())->setExpirationYear($payment->getCcExpYear())->setExpirationMonth($payment->getCcExpMonth())->setCvv($payment->getCcCid())->setCustomerEmail($order->getCustomerEmail())->setCustomerPhone($billing->getTelephone())->setBillingFirstName($billing->getFirstname())->setBillingLastName($billing->getLastname())->setBillingAddress1($billing->getStreetLine(1))->setBillingAddress2($billing->getStreetLine(2))->setBillingZipCode($billing->getPostcode())->setBillingCity($billing->getCity())->setBillingState($billing->getRegionCode())->setBillingCountry($billing->getCountryId());
     if (!empty($shipping)) {
         $genesis->request()->setShippingFirstName($shipping->getFirstname())->setShippingLastName($shipping->getLastname())->setShippingAddress1($shipping->getStreetLine(1))->setShippingAddress2($shipping->getStreetLine(2))->setShippingZipCode($shipping->getPostcode())->setShippingCity($shipping->getCity())->setShippingState($shipping->getRegionCode())->setShippinCountry($shipping->getCountryId());
     }
     if ($config->is3D) {
         $genesis->request()->setNotificationUrl($helper->getNotificationUrl($this->getCode()))->setReturnSuccessUrl($helper->getReturnUrl($this->getCode(), "success"))->setReturnCancelUrl($helper->getReturnUrl($this->getCode(), "cancel"))->setReturnFailureUrl($helper->getReturnUrl($this->getCode(), "failure"));
     }
     $genesis->execute();
     $this->setGenesisResponse($genesis->response()->getResponseObject());
     $genesis_response = $this->getModuleHelper()->getArrayFromGatewayResponse($this->getGenesisResponse());
     $payment->setTransactionId($this->getGenesisResponse()->unique_id)->setIsTransactionClosed($config->should_close)->setIsTransactionPending($config->is3D)->setTransactionAdditionalInfo(\Magento\Sales\Model\Order\Payment\Transaction::RAW_DETAILS, $genesis_response);
     $status = $this->getGenesisResponse()->status;
     $statusList = array(\Genesis\API\Constants\Transaction\States::DECLINED, \Genesis\API\Constants\Transaction\States::ERROR, \Genesis\API\Constants\Transaction\States::UNSUCCESSFUL);
     if (in_array($status, $statusList)) {
         throw new \Genesis\Exceptions\ErrorAPI($this->getGenesisResponse()->message);
     }
     if ($config->is3D) {
         $this->setRedirectUrl($this->getGenesisResponse()->redirect_url);
         $payment->setPreparedMessage('3D-Secure: Redirecting customer to a verification page.');
     } else {
         $this->unsetRedirectUrl();
     }
 }
 /**
  * Execute a WPF Reconcile
  *
  * @param $unique_id
  *
  * @return EMerchantPay_Genesis_Model_Checkout
  *
  * @throws Mage_Core_Exception
  */
 public function reconcile($unique_id)
 {
     try {
         $this->getHelper()->initClient($this->getCode());
         $genesis = new \Genesis\Genesis('WPF\\Reconcile');
         $genesis->request()->setUniqueId($unique_id);
         $genesis->execute();
         return $genesis->response()->getResponseObject();
     } catch (Exception $exception) {
         Mage::logException($exception);
         Mage::throwException($exception->getMessage());
     }
     return false;
 }
 /**
  * Reconcile with the Payment Gateway to get the latest
  * status on the transaction
  *
  * @throws \Genesis\Exceptions\InvalidResponse
  */
 public function initReconciliation()
 {
     if ($this->isAPINotification()) {
         $type = 'NonFinancial\\Reconcile\\Transaction';
     } elseif ($this->isWPFNotification()) {
         $type = 'WPF\\Reconcile';
     } else {
         $type = '';
     }
     $request = new \Genesis\Genesis($type);
     try {
         $request->request()->setUniqueId($this->unique_id);
         $request->execute();
     } catch (\Genesis\Exceptions\ErrorAPI $api) {
         // This is reconciliation, don't throw on ErrorAPI
     }
     $this->reconciliationObj = $request->response()->getResponseObject();
 }
 /**
  * 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;
 }