/** * 2016-05-20 * @see df_customer_info_add() * @used-by \Df\Payment\Method::iiaAdd() * @param II|I|OP|QP $payment * @param array $info */ function dfp_add_info(II $payment, array $info) { foreach ($info as $key => $value) { /** @var string $key */ /** @var string $value */ $payment->setAdditionalInformation($key, $value); } }
public function testHasAdditionalInformation() { $this->assertFalse($this->info->hasAdditionalInformation()); $data = ['key1' => 'data1', 'key2' => 'data2']; $this->info->setAdditionalInformation($data); $this->assertFalse($this->info->hasAdditionalInformation('key3')); $this->assertTrue($this->info->hasAdditionalInformation('key2')); $this->assertTrue($this->info->hasAdditionalInformation()); }
public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount) { if (!$this->canAuthorize()) { throw new \Magento\Framework\Exception\LocalizedException(__('The authorize action is not available.')); } $payment->getAdditionalInformation(); $order = $payment->getOrder(); $billing_address = $order->getBillingAddress(); $shipping_address = $order->getShippingAddress(); $params = array(); $params["sellerId"] = $this->getConfigData("merchant_id"); $params["privateKey"] = $this->getConfigData("private_key"); $params["merchantOrderId"] = $order->getRealOrderId(); $params["currency"] = $order->getOrderCurrencyCode(); $params["token"] = $payment->getAdditionalInformation()['token']; $params["total"] = round($order->getGrandTotal(), 2); // Set billing info $params["billingAddr"] = array(); $params["billingAddr"]["name"] = $billing_address->getName(); $params["billingAddr"]["addrLine1"] = $billing_address->getStreet()[0]; if (count($billing_address->getStreet()) > 1) { $params["billingAddr"]["addrLine2"] = $billing_address->getStreet()[1]; } $params["billingAddr"]["city"] = $billing_address->getCity(); $params["billingAddr"]["state"] = $billing_address->getRegion(); $params["billingAddr"]["zipCode"] = $billing_address->getPostcode(); $params["billingAddr"]["country"] = $billing_address->getCountryId(); $params["billingAddr"]["email"] = $order->getCustomerEmail(); $params["billingAddr"]["phoneNumber"] = $billing_address->getTelephone(); if (isset($shipping_address)) { $params["shippingAddress"] = array(); $params["shippingAddress"]["name"] = $shipping_address->getName(); $params["shippingAddress"]["addrLine1"] = $shipping_address->getStreet()[0]; if (count($shipping_address->getStreet()) > 1) { $params["shippingAddress"]["addrLine2"] = $shipping_address->getStreet()[1]; } $params["shippingAddress"]["city"] = $shipping_address->getCity(); $params["shippingAddress"]["state"] = $shipping_address->getRegion(); $params["shippingAddress"]["zipCode"] = $shipping_address->getPostcode(); $params["shippingAddress"]["country"] = $shipping_address->getCountryId(); } $client = $this->_httpClientFactory->create(); $path = $this->getConfigData('merchant_id') . "/rs/authService"; $url = $this->getPaymentApiUrl(); $client->setUri($url . $path); $client->setConfig(['maxredirects' => 0, 'timeout' => 30]); $client->setHeaders(['Accept: application/json', 'Content-Type: application/json']); $client->setMethod(\Zend_Http_Client::POST); $client->setRawData(json_encode($params), 'application/json'); try { $response = $client->request(); $responseBody = json_decode($response->getBody(), true); if (isset($responseBody['exception'])) { throw new \Magento\Framework\Exception\LocalizedException(__($responseBody['exception']['errorMsg'])); } elseif (!isset($responseBody['response'])) { throw new \Magento\Framework\Exception\LocalizedException(__('Error placing transaction.')); } } catch (\Exception $e) { throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage())); } $payment->setTransactionId($responseBody['response']['transactionId']); $payment->setIsTransactionClosed(0); $payment->setTransactionAdditionalInfo('tco_order_number', $responseBody['response']['orderNumber']); $payment->setAdditionalInformation('tco_order_number', $responseBody['response']['orderNumber']); $payment->setAdditionalInformation('tco_order_status', 'approved'); return $this; }
/** * Perform the payment review * * @param InfoInterface $payment * @param string $action * @return bool */ public function reviewPayment(InfoInterface $payment, $action) { $request = $this->buildBasicRequest(); $transactionId = $payment->getCcTransId() ? $payment->getCcTransId() : $payment->getLastTransId(); $request->setTrxtype(self::TRXTYPE_ACCEPT_DENY); $request->setOrigid($transactionId); $request->setUpdateaction($action); $response = $this->postRequest($request, $this->getConfig()); $payment->setAdditionalInformation((array) $response->getData()); $this->processErrors($response); if (!$this->_isTransactionUnderReview($response->getOrigresult())) { $payment->setTransactionId($response->getOrigpnref())->setIsTransactionClosed(0); if ($response->getOrigresult() == self::RESPONSE_CODE_APPROVED) { $payment->setIsTransactionApproved(true); } elseif ($response->getOrigresult() == self::RESPONSE_CODE_DECLINED_BY_MERCHANT) { $payment->setIsTransactionDenied(true); } } $rawData = $response->getData(); return $rawData ? $rawData : []; }
/** * Send authorize request to gateway * * @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface $payment * @param float $amount * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount) { $payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action')); }
protected function _processResponse(\Magento\Payment\Model\InfoInterface $payment, $response) { $payment->setAdditionalInformation('3dActive', false); switch ($response['resultCode']) { case "Authorised": //$this->_addStatusHistory($payment, $responseCode, $pspReference, $this->_getConfigData('order_status')); $this->_addStatusHistory($payment, $response['resultCode'], $response['pspReference']); $payment->setAdditionalInformation('pspReference', $response['pspReference']); break; case "RedirectShopper": // 3d is active so set the param to true checked in Controller/Validate3d $payment->setAdditionalInformation('3dActive', true); $issuerUrl = $response['issuerUrl']; $PaReq = $response['paRequest']; $md = $response['md']; if (!empty($PaReq) && !empty($md) && !empty($issuerUrl)) { $payment->setAdditionalInformation('issuerUrl', $response['issuerUrl']); $payment->setAdditionalInformation('paRequest', $response['paRequest']); $payment->setAdditionalInformation('md', $response['md']); } else { throw new \Magento\Framework\Exception\LocalizedException(__('3D secure is not valid')); } break; case "Refused": // refusalReason if ($response['refusalReason']) { $refusalReason = $response['refusalReason']; switch ($refusalReason) { case "Transaction Not Permitted": $errorMsg = __('The transaction is not permitted.'); break; case "CVC Declined": $errorMsg = __('Declined due to the Card Security Code(CVC) being incorrect. Please check your CVC code!'); break; case "Restricted Card": $errorMsg = __('The card is restricted.'); break; case "803 PaymentDetail not found": $errorMsg = __('The payment is REFUSED because the saved card is removed. Please try an other payment method.'); break; case "Expiry month not set": $errorMsg = __('The expiry month is not set. Please check your expiry month!'); break; default: $errorMsg = __('The payment is REFUSED.'); break; } } else { $errorMsg = __('The payment is REFUSED.'); } if ($errorMsg) { $this->_logger->critical($errorMsg); throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg)); } break; } }
/** * Send authorize request to gateway * * @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface $payment * @param float $amount * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount) { $this->_logger->addDebug('Directpost authorize was hit'); $payment->setAdditionalInformation('is_transaction_pending', 1); $order = $payment->getOrder(); $order->setState('pending'); $order->setStatus('pending'); }