예제 #1
0
 public function testAssignData()
 {
     $data = new DataObject();
     $paymentInfo = $this->getMock(InfoInterface::class);
     $this->payment->setInfoInstance($paymentInfo);
     $eventData = [AbstractDataAssignObserver::METHOD_CODE => $this, AbstractDataAssignObserver::MODEL_CODE => $paymentInfo, AbstractDataAssignObserver::DATA_CODE => $data];
     $this->eventManagerMock->expects(static::exactly(2))->method('dispatch')->willReturnMap([['payment_method_assign_data_' . Stub::STUB_CODE, $eventData], ['payment_method_assign_data', $eventData]]);
     $this->payment->assignData($data);
 }
예제 #2
0
 /**
  * Assign data to info model instance
  *
  * @param mixed $data
  * @return \Magento\Payment\Model\Info
  */
 public function assignData($data)
 {
     $result = parent::assignData($data);
     $key = self::TRANSPORT_BILLING_AGREEMENT_ID;
     $id = false;
     if (is_array($data) && isset($data[$key])) {
         $id = $data[$key];
     } elseif ($data instanceof \Magento\Framework\Object && $data->getData($key)) {
         $id = $data->getData($key);
     }
     if ($id) {
         $info = $this->getInfoInstance();
         $ba = $this->_agreementFactory->create()->load($id);
         if ($ba->getId() && $ba->getCustomerId() == $info->getQuote()->getCustomerId()) {
             $info->setAdditionalInformation($key, $id)->setAdditionalInformation(self::PAYMENT_INFO_REFERENCE_ID, $ba->getReferenceId());
         }
     }
     return $result;
 }
예제 #3
0
 /**
  * Assign data to info model instance
  *
  * @param \Magento\Framework\DataObject $data
  * @return \Magento\Payment\Model\Info
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     parent::assignData($data);
     $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);
     if (!is_array($additionalData) || !isset($additionalData[self::TRANSPORT_BILLING_AGREEMENT_ID])) {
         return $this;
     }
     $id = $additionalData[self::TRANSPORT_BILLING_AGREEMENT_ID];
     if (!$id || !is_numeric($id)) {
         return $this;
     }
     $info = $this->getInfoInstance();
     /** @var Agreement $ba */
     $ba = $this->_agreementFactory->create();
     $ba->load($id);
     if ($ba->getId() && $ba->getCustomerId() == $info->getQuote()->getCustomerId()) {
         $info->setAdditionalInformation(self::TRANSPORT_BILLING_AGREEMENT_ID, $id);
         $info->setAdditionalInformation(self::PAYMENT_INFO_REFERENCE_ID, $ba->getReferenceId());
     }
     return $this;
 }
 /**
  * Assign corresponding data
  *
  * @param \Magento\Framework\DataObject|mixed $data
  * @return $this
  * @throws LocalizedException
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     parent::assignData($data);
     $infoInstance = $this->getInfoInstance();
     $additionalData = $data->getData()['additional_data'];
     if (is_null($additionalData) || !array_key_exists('destination_customer', $additionalData)) {
         $additionalData['destination_customer'] = $this->config->getValue('payment/openpay/concentratorAccount');
     }
     $infoInstance->setAdditionalInformation('destination_customer', $additionalData['destination_customer']);
     return $this;
 }
예제 #5
0
 /**
  * Assign data to info model instance
  *
  * @param array|\Magento\Framework\DataObject $data
  * @return \Magento\Payment\Model\Info
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     parent::assignData($data);
     $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);
     if (!is_array($additionalData) || !isset($additionalData[ExpressCheckout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT])) {
         return $this;
     }
     $this->getInfoInstance()->setAdditionalInformation(ExpressCheckout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT, $additionalData[ExpressCheckout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT]);
     return $this;
 }
예제 #6
0
 /**
  * Assign data to info model instance
  *
  * @param array|DataObject $data
  * @return $this
  */
 public function assignData(DataObject $data)
 {
     parent::assignData($data);
     $details = array_filter($this->getCheckoutConfig());
     $infoInstance = $this->getInfoInstance();
     foreach ($details as $key => $value) {
         $infoInstance->setAdditionalInformation($key, $value);
     }
     return $this;
 }
예제 #7
0
 /**
  * Assign data to info model instance
  *
  * @param array|\Magento\Framework\Object $data
  * @return \Magento\Payment\Model\Info
  */
 public function assignData($data)
 {
     $result = parent::assignData($data);
     $key = ExpressCheckout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT;
     if (is_array($data)) {
         $this->getInfoInstance()->setAdditionalInformation($key, isset($data[$key]) ? $data[$key] : null);
     } elseif ($data instanceof \Magento\Framework\Object) {
         $this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key));
     }
     return $result;
 }
 /**
  * Assign corresponding data
  *
  * @param \Magento\Framework\DataObject|mixed $data
  * @return $this
  * @throws LocalizedException
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     parent::assignData($data);
     $infoInstance = $this->getInfoInstance();
     $openpayCard = $data->getData()['additional_data']['extension_attributes']->getOpenpayCard();
     $infoInstance->setAdditionalInformation('customer_card_id', $openpayCard->getCardId());
     $infoInstance->setAdditionalInformation('device_session_id', $openpayCard->getDeviceSessionId());
     return $this;
 }
예제 #9
0
 /**
  * Assign corresponding data
  *
  * @param \Magento\Framework\DataObject|mixed $data
  * @return $this
  * @throws LocalizedException
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     parent::assignData($data);
     $infoInstance = $this->getInfoInstance();
     if (($s2p_method = $data->getSpMethod()) === null) {
         $s2p_method = $data->getAdditionalData('sp_method');
     }
     if (($country_code = $data->getSelectedCountry()) === null) {
         $country_code = $data->getAdditionalData('selected_country');
     }
     if (!empty($country_code)) {
         $country_code = strtoupper(trim($country_code));
     }
     $configured_methods_instance = $this->_configuredMethods->create();
     if (!$s2p_method or empty($country_code) or !($method_details = $configured_methods_instance->getConfiguredMethodDetails($s2p_method, ['country_code' => $country_code, 'only_active' => true]))) {
         // ob_start();
         // var_dump( $data->getSpMethod() );
         // var_dump( $data->getAdditionalData( 'sp_method' ) );
         // var_dump( $s2p_method );
         // var_dump( $country_code );
         // if( isset( $method_details ) )
         //     var_dump( $method_details );
         // $buf = ob_get_clean();
         throw new LocalizedException(__('Please select a valid Smart2Pay method first.'));
     }
     $details_arr = array();
     if (!empty($method_details[$country_code])) {
         $details_arr = $method_details[$country_code];
     } elseif (!empty($method_details[Country::INTERNATIONAL_CODE])) {
         $details_arr = $method_details[Country::INTERNATIONAL_CODE];
     }
     if (empty($details_arr) or !is_array($details_arr)) {
         throw new LocalizedException(__('Couldn\'t obtain Smart2Pay payment method details. Please retry.'));
     }
     $s2p_transaction = $this->_s2pTransaction->create();
     $s2p_transaction->setMethodID($s2p_method)->setMerchantTransactionID('NOTSETYET_' . microtime(true));
     $s2p_transaction->save();
     $infoInstance->setAdditionalInformation('sp_method', $s2p_method);
     $infoInstance->setAdditionalInformation('sp_surcharge', isset($details_arr['surcharge']) ? $details_arr['surcharge'] : 0);
     $infoInstance->setAdditionalInformation('sp_fixed_amount', isset($details_arr['fixed_amount']) ? $details_arr['fixed_amount'] : 0);
     $infoInstance->setAdditionalInformation('sp_transaction', $s2p_transaction->getID());
     return $this;
 }
예제 #10
0
 /**
  * Assign data to info model instance
  *
  * @param array|DataObject $data
  * @return PaymentMethod
  */
 public function assignData(DataObject $data)
 {
     parent::assignData($data);
     $infoInstance = $this->getInfoInstance();
     $infoInstance->setAdditionalInformation("biller_code", $this->getConfigData("biller_code"));
     $infoInstance->setAdditionalInformation("customer_ref", $this->getCustomerRef());
     $infoInstance->setAdditionalInformation("accepts_credit_cards", $this->getConfigData("accepts_credit_cards"));
     return $this;
 }
예제 #11
0
 /**
  * Assign data to info model instance
  *
  * @param array|\Magento\Framework\DataObject $data
  *
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  * @api
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     parent::assignData($data);
     /** @var \Magento\Quote\Model\Quote\Payment $infoInstance */
     $infoInstance = $this->getInfoInstance();
     /* unset data wich is used for dedicated payment methods only */
     $infoInstance->unsAdditionalInformation('financialInstitution');
     $infoInstance->unsAdditionalInformation('customerDob');
     return $this;
 }
예제 #12
0
 /**
  * Assign data to info model instance
  *
  * @param \Magento\Framework\DataObject|mixed $data
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     parent::assignData($data);
     $infoInstance = $this->getInfoInstance();
     if (isset($data['brand_code'])) {
         $infoInstance->setAdditionalInformation('brand_code', $data['brand_code']);
     }
     if (isset($data['issuer_id'])) {
         $infoInstance->setAdditionalInformation('issuer_id', $data['issuer_id']);
     }
     $this->_adyenLogger->debug(print_r($data, 1));
     return $this;
 }