/** * Update current token * * @param Varien_Object $billing * @param Varien_Object $infoInstance * @return Eway_Rapid31_Model_Request_Token */ public function updateToken(Varien_Object $billing, Varien_Object $infoInstance) { if (!Mage::helper('ewayrapid')->isBackendOrder() && !Mage::getSingleton('ewayrapid/config')->canEditToken()) { Mage::throwException(Mage::helper('ewayrapid')->__('Customers are not allowed to edit token.')); } // Empty Varien_Object's data $this->unsetData(); $customerParam = Mage::getModel('ewayrapid/field_customer'); $customerParam->setTitle($billing->getPrefix())->setFirstName($billing->getFirstname())->setLastName($billing->getLastname())->setCompanyName($billing->getCompany())->setJobDescription($billing->getJobDescription())->setStreet1($billing->getStreet1())->setStreet2($billing->getStreet2())->setCity($billing->getCity())->setState($billing->getRegion())->setPostalCode($billing->getPostcode())->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))->setEmail($billing->getEmail())->setPhone($billing->getTelephone())->setMobile($billing->getMobile())->setFax($billing->getFax()); $customerHelper = Mage::helper('ewayrapid/customer'); $customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken()); if ($customerTokenId) { $customerParam->setTokenCustomerID($customerTokenId); } else { Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.')); } $cardDetails = Mage::getModel('ewayrapid/field_cardDetails'); $cardDetails->setName($infoInstance->getCcOwner())->setExpiryMonth($infoInstance->getCcExpMonth())->setNumber('444433XXXXXX1111')->setExpiryYear($infoInstance->getCcExpYear())->setCVN($infoInstance->getCcCid()); $customerParam->setCardDetails($cardDetails); $this->setCustomer($customerParam); $response = $this->_doRapidAPI('Customer', 'PUT'); if ($response->isSuccess()) { $customerReturn = $response->getCustomer(); $customerReturn['RegionId'] = !$billing->getRegion() && $billing->getRegionId() ? $billing->getRegionId() : ''; unset($customerReturn['CardDetails']); $tokenInfo = array('Token' => $response->getTokenCustomerID(), 'Owner' => $infoInstance->getCcOwner(), 'ExpMonth' => $infoInstance->getCcExpMonth(), 'ExpYear' => $infoInstance->getCcExpYear(), 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn)); Mage::helper('ewayrapid/customer')->updateToken($infoInstance->getSavedToken(), $tokenInfo); return $this; } else { Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token. Please try again. (Error message: %s)', $response->getMessage())); } }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT && !$this->_isBackendOrder) { $info->setTransparentSaved($data->getTransparentSaved()); } if ($data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW) { if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE && !$this->_isBackendOrder) { Mage::getSingleton('core/session')->setData('newToken', 1); } $info->setIsNewToken(true); } else { if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE && !$this->_isBackendOrder) { Mage::getSingleton('core/session')->setData('editToken', $data->getSavedToken()); } $info->setSavedToken($data->getSavedToken()); // Update token if ($data->getCcOwner()) { $info->setIsUpdateToken(true); } } parent::assignData($data); Mage::helper('ewayrapid')->serializeInfoInstance($info); return $this; }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } // salva a bandeira, o numero de parcelas e o token $info = $this->getInfoInstance(); $additionaldata = array('parcels_number' => $data->getParcelsNumber()); if ($data->getToken()) { $tokenData = $this->_getTokenById($data->getToken()); $additionaldata['token'] = $tokenData['token']; $data->setCcType($tokenData['ccType']); } $info->setCcType($data->getCcType())->setCcNumber(Mage::helper('core')->encrypt($data->getCcNumber()))->setCcOwner($data->getCcOwner())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcCid(Mage::helper('core')->encrypt($data->getCcCid()))->setAdditionalData(serialize($additionaldata)); // pega dados de juros $withoutInterest = intval($this->getConfigData('installment_without_interest', $this->getStoreId())); $interestValue = floatval($this->getConfigData('installment_interest_value', $this->getStoreId())); // verifica se há juros if ($data->getParcelsNumber() > $withoutInterest) { $installmentValue = Mage::helper('Query_Cielo')->calcInstallmentValue($info->getQuote()->getGrandTotal(), $interestValue / 100, $data->getParcelsNumber()); $installmentValue = round($installmentValue, 2); $interest = $installmentValue * $data->getParcelsNumber() - $info->getQuote()->getGrandTotal(); $info->getQuote()->setInterest($info->getQuote()->getStore()->convertPrice($interest, false)); $info->getQuote()->setBaseInterest($interest); $info->getQuote()->setTotalsCollectedFlag(false)->collectTotals(); $info->getQuote()->save(); } else { $info->getQuote()->setInterest(0.0); $info->getQuote()->setBaseInterest(0.0); $info->getQuote()->setTotalsCollectedFlag(false)->collectTotals(); $info->getQuote()->save(); } return $this; }
public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $info->setCardToken($data->getCardToken())->setChargeAuthorization($data->getChargeAuthorization())->setCardMonthlyInstallments($data->getCardMonthlyInstallments())->setCcOwner($data->getCcOwner())->setCcLast4($data->getCcLast4())->setCcType($data->getCcType())->setCardBin($data->getCardBin()); return $this; }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $info->setCcOwner($data->getCcOwner())->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear()); return $this; }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcSsIssue($data->getCcSsIssue())->setCcSsStartMonth($data->getCcSsStartMonth())->setCcSsStartYear($data->getCcSsStartYear()); return $this; }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $additionaldata = array('Cc_parcelas' => $data->getCcParcelas(), 'cc_cid_enc' => $info->encrypt($data->getCcCid())); $info->setCcType($data->getCcType())->setAdditionalData(serialize($additionaldata))->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcSsIssue($data->getCcSsIssue())->setCcSsStartMonth($data->getCcSsStartMonth())->setCcSsStartYear($data->getCcSsStartYear())->setCcNumberEnc($info->encrypt($data->getCcNumber()))->setCcCidEnc($info->encrypt($data->getCcCid())); return $this; }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $session = Mage::getSingleton('core/session'); $info = $this->getInfoInstance(); $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcSsIssue($data->getCcSsIssue())->setCcSsStartMonth($data->getCcSsStartMonth())->setCcSsStartYear($data->getCcSsStartYear()); $session->setVeritransQuoteId($this->_getOrderId()); $session->setTokenBrowser($data->getTokenId()); return $this; }
public function processPayment(Varien_Object $payment, $amount) { ini_set('soap.wsdl_cache_enabled', '0'); $braspag_url = $this->getConfigData('service'); $merchant_id = $this->getConfigData('merchant_id'); $order = $payment->getOrder(); $order_id = $order->getIncrementId(); $soapclient = new Zend_Soap_Client($braspag_url); $parametros = array(); $parametros['merchantId'] = (string) $merchant_id; $parametros['orderId'] = (string) $order_id; $parametros['customerName'] = (string) $payment->getCcOwner(); $parametros['amount'] = (string) number_format($amount, 2, ',', '.'); $parametros['paymentMethod'] = (string) $this->getMethodConfig($payment->getCcType()); $parametros['holder'] = (string) $payment->getCcOwner(); $parametros['cardNumber'] = (string) $payment->getCcNumber(); $parametros['expiration'] = (string) $payment->getCcExpMonth() . '/' . $payment->getCcExpYear(); $parametros['securityCode'] = (string) $payment->getCcCid(); if (!$this->getCheckout()->getCcParcelamento()) { $parametros['numberPayments'] = '1'; $parametros['typePayment'] = '0'; } else { $parametros['numberPayments'] = '3'; $parametros['typePayment'] = $this->getParcelamentoType(); } $authorize = $soapclient->Authorize($parametros); $resultado = $authorize->AuthorizeResult; $transacao = Mage::getModel('braspag/braspag'); $transacao->setOrderId($order_id); $transacao->setAuthorisation($resultado->authorisationNumber); $transacao->setAmount($amount); $transacao->setNumberPayments($parametros['numberPayments']); $transacao->setTypePayment($parametros['typePayment']); $transacao->setTransactionId($resultado->transactionId); $transacao->setMessage($resultado->message); $transacao->setReturnCode($resultado->returnCode); $transacao->setStatus($resultado->status); $transacao->save(); return $transacao; }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } // salva a bandeira $info = $this->getInfoInstance(); // converte nomenclatura da bandeira if ($data->getCcType() == "visa-electron") { $cardType = "visa"; } else { $cardType = $data->getCcType(); } $info->setCcType($cardType)->setCcNumber(Mage::helper('core')->encrypt($data->getCcNumber()))->setCcOwner($data->getCcOwner())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcCid(Mage::helper('core')->encrypt($data->getCcCid())); return $this; }
/** * Assign data to info model instance * * @param mixed $data * * @return Mage_Payment_Model_Method_Abstract */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $quote = $info->getQuote(); if ($this->isSingleOrder($quote)) { $info->setAdditionalInformation('installments', $data->getCcInstallments()); } if ($data->getCcChoice() === 'saved') { $info->setAdditionalInformation('PaymentMethod', $this->_code)->setAdditionalInformation('use_saved_cc', true); return $this; } $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcSsIssue($data->getCcSsIssue())->setCcSsStartMonth($data->getCcSsStartMonth())->setCcSsStartYear($data->getCcSsStartYear())->setAdditionalInformation('PaymentMethod', $this->_code)->setAdditionalInformation('use_saved_cc', false); return $this; }
/** * Assigns data to the payment info instance * * @param Varien_Object|array $data Payment Data from checkout * @return Itabs_Debit_Model_Debit Self. */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); // Fetch routing number $ccType = $data->getDebitCcType(); if (!$ccType) { $ccType = $data->getCcType(); } $ccType = Mage::helper('debit')->sanitizeData($ccType); $ccType = $info->encrypt($ccType); // Fetch account holder $ccOwner = $data->getDebitCcOwner(); if (!$ccOwner) { $ccOwner = $data->getCcOwner(); } // Fetch account number $ccNumber = $data->getDebitCcNumber(); if (!$ccNumber) { $ccNumber = $data->getCcNumber(); } $ccNumber = Mage::helper('debit')->sanitizeData($ccNumber); $ccNumber = $info->encrypt($ccNumber); // Fetch the account swift $swift = $data->getDebitSwift(); if ($swift) { $swift = $info->encrypt($swift); } // Fetch the account iban $iban = $data->getDebitIban(); if ($iban) { $iban = $info->encrypt($iban); } $bankName = $data->getDebitBankname(); // Set account data in payment info model $info->setCcType($ccType)->setCcOwner($ccOwner)->setCcNumberEnc($ccNumber)->setDebitSwift($swift)->setDebitIban($iban)->setDebitBankname($bankName)->setDebitType(Mage::helper('debit')->getDebitType()); return $this; }
/** * 1) Called everytime the adyen_cc is called or used in checkout * @description Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); // set number of installements $info->setAdditionalInformation('number_of_installments', $data->getAdditionalData()); // save value remember details checkbox $info->setAdditionalInformation('store_cc', $data->getStoreCc()); if ($this->isCseEnabled()) { $info->setCcType($data->getCcType()); $info->setAdditionalInformation('encrypted_data', $data->getEncryptedData()); } else { $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcCid($data->getCcCid())->setPoNumber($data->getAdditionalData()); } if ($info->getAdditionalInformation('number_of_installments') != "") { // recalculate the totals so that extra fee is defined $quote = Mage::getModel('checkout/type_onepage') !== false ? Mage::getModel('checkout/type_onepage')->getQuote() : Mage::getModel('checkout/session')->getQuote(); $quote->setTotalsCollectedFlag(false); $quote->collectTotals(); } return $this; }
public function create(Varien_Object $payment, $amount, $paymentMethod = null, $merchantAccount = null, $recurringType = null, $recurringPaymentType = null, $enableMoto = null) { $order = $payment->getOrder(); $incrementId = $order->getIncrementId(); $orderCurrencyCode = $order->getOrderCurrencyCode(); // override amount because this amount uses the right currency $amount = $order->getGrandTotal(); $customerId = $order->getCustomerId(); if ($customerId) { $customer = Mage::getModel('customer/customer')->load($order->getCustomerId()); $customerId = $customer->getData('adyen_customer_ref') ?: $customer->getData('increment_id') ?: $customerId; } $realOrderId = $order->getRealOrderId(); $this->reference = $incrementId; $this->merchantAccount = $merchantAccount; $this->amount->currency = $orderCurrencyCode; $this->amount->value = Mage::helper('adyen')->formatAmount($amount, $orderCurrencyCode); //shopper data $customerEmail = $order->getCustomerEmail(); $this->shopperEmail = $customerEmail; $this->shopperIP = $order->getRemoteIp(); $this->shopperReference = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId; // Set the recurring contract if ($recurringType) { if ($paymentMethod == "oneclick") { // For ONECLICK look at the recurringPaymentType that the merchant has selected in Adyen ONECLICK settings if ($payment->getAdditionalInformation('customer_interaction')) { $this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring(); $this->recurring->contract = "ONECLICK"; } else { $this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring(); $this->recurring->contract = "RECURRING"; } } elseif ($paymentMethod == "cc") { // if save card is disabled only shoot in as recurring if recurringType is set to ONECLICK,RECURRING if ($payment->getAdditionalInformation("store_cc") == "" && $recurringType == "ONECLICK,RECURRING") { $this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring(); $this->recurring->contract = "RECURRING"; } elseif ($payment->getAdditionalInformation("store_cc") == "1") { $this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring(); $this->recurring->contract = $recurringType; } elseif ($recurringType == "RECURRING") { // recurring permission is not needed from shopper so just save it as recurring $this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring(); $this->recurring->contract = "RECURRING"; } } else { $this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring(); $this->recurring->contract = $recurringType; } } /** * Browser info * @var unknown_type */ if (isset($_SERVER['HTTP_ACCEPT'])) { $this->browserInfo->acceptHeader = $_SERVER['HTTP_ACCEPT']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { $this->browserInfo->userAgent = $_SERVER['HTTP_USER_AGENT']; } switch ($paymentMethod) { case "elv": $elv = unserialize($payment->getPoNumber()); $this->card = null; $this->shopperName = null; $this->bankAccount = null; $this->elv->accountHolderName = $elv['account_owner']; $this->elv->bankAccountNumber = $elv['account_number']; $this->elv->bankLocation = $elv['bank_location']; $this->elv->bankLocationId = $elv['bank_location']; $this->elv->bankName = $elv['bank_name']; break; case "cc": case "oneclick": $this->shopperName = null; $this->elv = null; $this->bankAccount = null; $billingAddress = $order->getBillingAddress(); $helper = Mage::helper('adyen'); if ($billingAddress) { $this->billingAddress = new Adyen_Payment_Model_Adyen_Data_BillingAddress(); $this->billingAddress->street = $helper->getStreet($billingAddress)->getName(); $this->billingAddress->houseNumberOrName = $helper->getStreet($billingAddress)->getHouseNumber(); $this->billingAddress->city = $billingAddress->getCity(); $this->billingAddress->postalCode = $billingAddress->getPostcode(); $this->billingAddress->stateOrProvince = $billingAddress->getRegionCode(); $this->billingAddress->country = $billingAddress->getCountryId(); } $deliveryAddress = $order->getShippingAddress(); if ($deliveryAddress) { $this->deliveryAddress = new Adyen_Payment_Model_Adyen_Data_DeliveryAddress(); $this->deliveryAddress->street = $helper->getStreet($deliveryAddress)->getName(); $this->deliveryAddress->houseNumberOrName = $helper->getStreet($deliveryAddress)->getHouseNumber(); $this->deliveryAddress->city = $deliveryAddress->getCity(); $this->deliveryAddress->postalCode = $deliveryAddress->getPostcode(); $this->deliveryAddress->stateOrProvince = $deliveryAddress->getRegionCode(); $this->deliveryAddress->country = $deliveryAddress->getCountryId(); } if ($paymentMethod == "oneclick") { $recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference"); if ($payment->getAdditionalInformation('customer_interaction')) { $this->shopperInteraction = "Ecommerce"; } else { $this->shopperInteraction = "ContAuth"; } // For recurring Ideal and Sofort needs to be converted to SEPA for this it is mandatory to set selectBrand to sepadirectdebit if (!$payment->getAdditionalInformation('customer_interaction')) { if ($payment->getCcType() == "directEbanking" || $payment->getCcType() == "ideal") { $this->selectedBrand = "sepadirectdebit"; } } } else { $recurringDetailReference = null; $this->shopperInteraction = "Ecommerce"; } if ($paymentMethod == "cc" && Mage::app()->getStore()->isAdmin() && $enableMoto != null && $enableMoto == 1) { $this->shopperInteraction = "Moto"; } // if it is a sepadirectdebit set selectedBrand to sepadirectdebit if ($payment->getCcType() == "sepadirectdebit") { $this->selectedBrand = "sepadirectdebit"; } if ($recurringDetailReference && $recurringDetailReference != "") { $this->selectedRecurringDetailReference = $recurringDetailReference; } if (Mage::getModel('adyen/adyen_cc')->isCseEnabled()) { $this->card = null; // this is only needed for creditcards if ($payment->getAdditionalInformation("encrypted_data") != "") { $kv = new Adyen_Payment_Model_Adyen_Data_AdditionalDataKVPair(); $kv->key = new SoapVar("card.encrypted.json", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"); $kv->value = new SoapVar($payment->getAdditionalInformation("encrypted_data"), XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"); $this->additionalData->entry = $kv; } else { if ($paymentMethod == 'cc') { // log the browser data to see why it is failing Mage::log($_SERVER['HTTP_USER_AGENT'], Zend_Log::ERR, "adyen_exception.log", true); // For CC encrypted data is needed if you use CSE Adyen_Payment_Exception::throwException(Mage::helper('adyen')->__('Missing the encrypted data value. Make sure the Client Side Encryption(CSE) script did encrypt the Credit Card details')); } } } else { if ($recurringDetailReference && $recurringDetailReference != "") { // this is only needed for creditcards if ($payment->getCcCid() != "" && $payment->getCcExpMonth() != "" && $payment->getCcExpYear() != "") { if ($recurringType != "RECURRING") { $this->card->cvc = $payment->getCcCid(); } $this->card->expiryMonth = $payment->getCcExpMonth(); $this->card->expiryYear = $payment->getCcExpYear(); } else { $this->card = null; } } else { // this is only the case for adyen_cc payments $this->card->cvc = $payment->getCcCid(); $this->card->expiryMonth = $payment->getCcExpMonth(); $this->card->expiryYear = $payment->getCcExpYear(); $this->card->holderName = $payment->getCcOwner(); $this->card->number = $payment->getCcNumber(); } } // installments if (Mage::helper('adyen/installments')->isInstallmentsEnabled() && $payment->getAdditionalInformation('number_of_installments') > 0) { $this->installments = new Adyen_Payment_Model_Adyen_Data_Installments(); $this->installments->value = $payment->getAdditionalInformation('number_of_installments'); } // add observer to have option to overrule and or add request data Mage::dispatchEvent('adyen_payment_card_payment_request', array('order' => $order, 'paymentMethod' => $paymentMethod, 'paymentRequest' => $this)); break; case "boleto": $boleto = unserialize($payment->getPoNumber()); $this->card = null; $this->elv = null; $this->bankAccount = null; $this->socialSecurityNumber = $boleto['social_security_number']; $this->selectedBrand = $boleto['selected_brand']; $this->shopperName->firstName = $boleto['firstname']; $this->shopperName->lastName = $boleto['lastname']; $this->deliveryDate = $boleto['delivery_date']; break; case "sepa": $sepa = unserialize($payment->getPoNumber()); $this->card = null; $this->elv = null; $this->shopperName = null; $this->bankAccount->iban = $sepa['iban']; $this->bankAccount->ownerName = $sepa['account_name']; $this->bankAccount->countryCode = $sepa['country']; $this->selectedBrand = "sepadirectdebit"; break; } return $this; }
/** * Building request array * * @param Varien_Object * @return array */ protected function _buildRequest(Varien_Object $payment) { $order = $payment->getOrder(); $billing = $order->getBillingAddress(); $streets = $billing->getStreet(); $street = isset($streets[0]) && $streets[0] != '' ? $streets[0] : (isset($streets[1]) && $streets[1] != '' ? $streets[1] : ''); $request = Mage::getModel('chronopay/gateway_request')->setOpcode($payment->getOpcode())->setProductId($this->getConfigData('product_id')); switch ($request->getOpcode()) { case self::OPCODE_CUSTOMER_FUND_TRANSFER: $request->setCustomer($order->getCustomerId())->setAmount(sprintf('%.2f', $payment->getAmount()))->setCurrency($order->getBaseCurrencyCode()); break; case self::OPCODE_CHARGING: case self::OPCODE_REFUND: case self::OPCODE_AUTHORIZE: case self::OPCODE_VOID_AUTHORIZE: $request->setFname($billing->getFirstname())->setLname($billing->getLastname())->setCardholder($payment->getCcOwner())->setZip($billing->getPostcode())->setStreet($street)->setCity($billing->getCity())->setState($billing->getRegionModel()->getCode())->setCountry($billing->getCountryModel()->getIso3Code())->setEmail($order->getCustomerEmail())->setPhone($billing->getTelephone())->setIp($this->_getIp())->setCardNo($payment->getCcNumber())->setCvv($payment->getCcCid())->setExpirey($payment->getCcExpYear())->setExpirem(sprintf('%02d', $payment->getCcExpMonth()))->setAmount(sprintf('%.2f', $payment->getAmount()))->setCurrency($order->getBaseCurrencyCode()); break; default: Mage::throwException(Mage::helper('chronopay')->__('Invalid operation code.')); break; } $request->setShowTransactionId(1); if ($this->getTransactionId()) { $request->setTransaction($this->getTransactionId()); } $hash = $this->_getHash($request); $request->setHash($hash); return $request; }
/** * Return commno data for *all* transactions. * @return array Data */ public function _getGeneralTrnData(Varien_Object $payment) { $order = $payment->getOrder(); $quoteObj = $this->_getQuote(); $vendorTxCode = $this->_getTrnVendorTxCode(); if ($payment->getCcNumber()) { $vendorTxCode .= $this->_cleanString(substr($payment->getCcOwner(), 0, 10)); } $payment->setVendorTxCode($vendorTxCode); $request = new Varien_Object(); $request->setVPSProtocol('2.23')->setReferrerID($this->getConfigData('referrer_id'))->setVendor($this->getConfigData('vendor'))->setVendorTxCode($vendorTxCode); $request->setClientIPAddress($this->getClientIp()); if ($payment->getIntegra()) { $this->getSageSuiteSession()->setLastVendorTxCode($vendorTxCode); $request->setIntegration($payment->getIntegra()); $request->setData('notification_URL', $this->getNotificationUrl() . '&vtxc=' . $vendorTxCode); $request->setData('success_URL', $this->getSuccessUrl()); $request->setData('redirect_URL', $this->getRedirectUrl()); $request->setData('failure_URL', $this->getFailureUrl()); } if ($this->_getIsAdminOrder()) { $request->setAccountType('M'); } if ($payment->getAmountOrdered()) { $from = $order->getOrderCurrencyCode(); if ((string) $this->getConfigData('trncurrency') == 'store') { $request->setAmount($this->formatAmount($quoteObj->getGrandTotal(), $quoteObj->getQuoteCurrencyCode())); $request->setCurrency($quoteObj->getQuoteCurrencyCode()); } else { $request->setAmount($this->formatAmount($quoteObj->getBaseGrandTotal(), $quoteObj->getBaseCurrencyCode())); $request->setCurrency($quoteObj->getBaseCurrencyCode()); } } if (!empty($order)) { $billing = $order->getBillingAddress(); if (!empty($billing)) { $request->setBillingAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setBillingSurname($this->ss($billing->getLastname(), 20))->setBillingFirstnames($this->ss($billing->getFirstname(), 20))->setBillingPostCode($this->ss($billing->getPostcode(), 10))->setBillingAddress1($this->ss($billing->getStreet(1), 100))->setBillingAddress2($this->ss($billing->getStreet(2), 100))->setBillingCity($this->ss($billing->getCity(), 40))->setBillingCountry($billing->getCountry())->setContactNumber(substr($this->_cphone($billing->getTelephone()), 0, 20)); if ($billing->getCountry() == 'US') { $request->setBillingState($billing->getRegionCode()); } $request->setCustomerEMail($billing->getEmail()); } if (!$request->getDescription()) { $request->setDescription('.'); } $shipping = $order->getShippingAddress(); if (!empty($shipping)) { $request->setDeliveryAddress($shipping->getStreet(1) . ' ' . $shipping->getCity() . ' ' . $shipping->getRegion() . ' ' . $shipping->getCountry())->setDeliverySurname($this->ss($shipping->getLastname(), 20))->setDeliveryFirstnames($this->ss($shipping->getFirstname(), 20))->setDeliveryPostCode($this->ss($shipping->getPostcode(), 10))->setDeliveryAddress1($this->ss($shipping->getStreet(1), 100))->setDeliveryAddress2($this->ss($shipping->getStreet(2), 100))->setDeliveryCity($this->ss($shipping->getCity(), 40))->setDeliveryCountry($shipping->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($shipping->getTelephone())), 20)); if ($shipping->getCountry() == 'US') { $request->setDeliveryState($shipping->getRegionCode()); } } else { #If the cart only has virtual products, I need to put an shipping address to Sage Pay. #Then the billing address will be the shipping address to $request->setDeliveryAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setDeliverySurname($this->ss($billing->getLastname(), 20))->setDeliveryFirstnames($this->ss($billing->getFirstname(), 20))->setDeliveryPostCode($this->ss($billing->getPostcode(), 10))->setDeliveryAddress1($this->ss($billing->getStreet(1), 100))->setDeliveryAddress2($this->ss($billing->getStreet(2), 100))->setDeliveryCity($this->ss($billing->getCity(), 40))->setDeliveryCountry($billing->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($billing->getTelephone())), 20)); if ($billing->getCountry() == 'US') { $request->setDeliveryState($billing->getRegionCode()); } } } if ($payment->getCcNumber()) { $request->setCardNumber($payment->getCcNumber())->setExpiryDate(sprintf('%02d%02d', $payment->getCcExpMonth(), substr($payment->getCcExpYear(), strlen($payment->getCcExpYear()) - 2)))->setCardType($payment->getCcType())->setCV2($payment->getCcCid())->setCardHolder($payment->getCcOwner()); if ($payment->getCcIssue()) { $request->setIssueNumber($payment->getCcIssue()); } if ($payment->getCcStartMonth() && $payment->getCcStartYear()) { $request->setStartDate(sprintf('%02d%02d', $payment->getCcStartMonth(), substr($payment->getCcStartYear(), strlen($payment->getCcStartYear()) - 2))); } } $totals = $shipping->getTotals(); $shippingTotal = isset($totals['shipping']) ? $totals['shipping']->getValue() : 0; if ($this->getSendBasket()) { $request->setBasket($this->_getBasketContents($quoteObj)); } if (!$request->getDeliveryPostCode()) { $request->setDeliveryPostCode('000'); } if (!$request->getBillingPostCode()) { $request->setBillingPostCode('000'); } return $request; }
protected function _buildRequest(Varien_Object $payment) { if (!$payment->getTrxtype()) { $payment->setTrxtype(self::TRXTYPE_AUTH_ONLY); } if (!$payment->getTender()) { $payment->setTender(self::TENDER_CC); } $request = Mage::getModel('paygate/payflow_pro_request')->setUser($this->getConfigData('user'))->setVendor($this->getConfigData('vendor'))->setPartner($this->getConfigData('partner'))->setPwd($this->getConfigData('pwd'))->setTender($payment->getTender())->setTrxtype($payment->getTrxtype())->setVerbosity($this->getConfigData('verbosity'))->setRequestId($this->_generateRequestId()); if ($payment->getAmount()) { $request->setAmt(round($payment->getAmount(), 2)); } switch ($request->getTender()) { case self::TENDER_CC: if ($payment->getCcNumber()) { $request->setComment1($payment->getCcOwner())->setAcct($payment->getCcNumber())->setExpdate(sprintf('%02d', $payment->getCcExpMonth()) . substr($payment->getCcExpYear(), -2, 2))->setCvv2($payment->getCcCid()); } break; } $order = $payment->getOrder(); if (!empty($order)) { $billing = $order->getBillingAddress(); if (!empty($billing)) { $request->setFirstName($billing->getFirstname())->setLastName($billing->getLastname())->setStreet($billing->getStreet(1))->setCity($billing->getCity())->setState($billing->getRegion())->setZip($billing->getPostcode())->setCountry($billing->getCountry())->setEmail($payment->getOrder()->getCustomerEmail()); } } return $request; }
/** * Note to self: * Custom fields are stored using the addData */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $info->setAdditionalData(serialize(array('cc_token' => $data['cc_token']))); if ($data['cc_token'] == 'manual') { $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcSsIssue($data->getCcSsIssue())->setCcSsStartMonth($data->getCcSsStartMonth())->setCcSsStartYear($data->getCcSsStartYear()); } else { $customer_tokens = $this->_getPaytraceTokens($info); $paytrace = null; foreach ($customer_tokens as $tk => $tv) { if ($tv->token_id == $data['cc_token']) { $paytrace = $tv; } } $last4 = empty($paytrace->token_id) ? '' : $paytrace->last4; $info->setCcType('')->setCcOwner('')->setCcLast4($last4)->setCcNumber('999999999999' . $last4)->setCcCid('')->setCcExpMonth('')->setCcExpYear('')->setCcSsIssue('')->setCcSsStartMonth('')->setCcSsStartYear(''); } return $this; }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear()); if ($this->getConfigData('mobile_active') && $data->getNetsMobile()) { $this->getCheckout()->setNetsMobile(true); } else { $this->getCheckout()->setNetsMobile(false); } if ($data->getNetsEasypaymentCard() === "on") { $this->getCheckout()->setNetsEasypaymentCard(true); } else { $this->getCheckout()->setNetsEasypaymentCard(false); } return $this; }
private function callApi(Varien_Object $payment, $amount, $type) { //在这里调用你的授权 API //如下的只是示例代码 $order = $payment->getOrder(); //$sales_order = Mage::getModel( 'sales/order' )->load( $alldata [0] ['entity_id'] ); $billingAddress = $order->getBillingAddress(); $shippingAddress = $order->getShippingAddress(); //$types = Mage::getSingleton('payment/config')->getCcTypes(); //if (isset($types[$payment->getCcType()])) { //$type = $types[$payment->getCcType()]; //} //if($shippingAddress->getData ('firstname') == null && $shippingAddress->getData ('lastname') ==null){ //$shippingAddress = $billingAddress; //} $billingCountry = $billingAddress->getData('country_id'); if ($billingCountry == 'US' || $billingCountry == 'CA') { $billingState = $billingAddress->getRegionCode(); } else { $billingState = $billingAddress->getRegion(); } if (empty($billingState)) { $billingState = '-'; } $shippingCountry = $shippingAddress->getData('country_id'); if ($shippingCountry == 'US' || $shippingCountry == 'CA') { $shippingState = $shippingAddress->getRegionCode(); } else { $shippingState = $shippingAddress->getRegion(); } if (empty($shippingState)) { $shippingState = '-'; } //Mage::throwException($this->_getHelper()->__(serialize($shippingState)));return false; if ($shippingAddress->getData('firstname') == null && $shippingAddress->getData('lastname') == null) { $shippingAddress = $billingAddress; $shippingState = $billingState; } //$billingaddress = $order->getBillingAddress(); //$totals = number_format($order->getGrandTotal() * $currency_rate, 2, '.', ''); $orderId = $order->getIncrementId(); //$currencyDesc = $order->getBaseCurrencyCode(); $currency_rate = Mage::app()->getStore()->getCurrentCurrencyRate(); $url = $this->getConfigData('gateway_url'); //Mage::throwException($this->_getHelper()->__(serialize($this->getConfigData('website_id') . $_SERVER['HTTP_HOST'])));return false; $fields = array('mode' => 'Api', 'websiteid' => $this->getConfigData('website_id'), 'ipaddress' => $this->get_ip(), 'domain' => $_SERVER['HTTP_HOST'], 'orderid' => $orderId, 'email' => $order->getData('customer_email'), 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), 'amount' => $amount * $currency_rate, 'discount' => '0.00', 'tax' => '0.00', 'freight' => '0.00', 'billingfirstname' => $billingAddress->getData('firstname'), 'billinglastname' => $billingAddress->getData('lastname'), 'billingaddress1' => $billingAddress->getData('street'), 'billingaddress2' => '-', 'billingcity' => $billingAddress->getData('city'), 'billingcountry' => $billingAddress->getData('country_id'), 'billingstate' => $billingState, 'billingzipcode' => $billingAddress->getData('postcode'), 'billingtelephone' => $billingAddress->getData('telephone'), 'shippingfirstname' => $shippingAddress->getData('firstname'), 'shippinglastname' => $shippingAddress->getData('lastname'), 'shippingaddress1' => $shippingAddress->getData('street'), 'shippingaddress2' => '-', 'shippingcity' => $shippingAddress->getData('city'), 'shippingcountry' => $shippingAddress->getData('country_id'), 'shippingstate' => $shippingState, 'shippingzipcode' => $shippingAddress->getData('postcode'), 'shippingtelephone' => $shippingAddress->getData('telephone'), 'signature' => md5($this->getConfigData('website_id') . $orderId . $order->getData('customer_email') . Mage::app()->getStore()->getCurrentCurrencyCode() . $amount * $currency_rate . '0.00' . '0.00' . '0.00' . $this->getConfigData('security_key')), 'creditcardexpire' => strlen($payment->getCcExpMonth()) == 1 ? $payment->getCcExpYear() . 0 . $payment->getCcExpMonth() : $payment->getCcExpYear() . $payment->getCcExpMonth(), 'creditcardnumber' => $payment->getCcNumber(), 'creditcardname' => $payment->getCcOwner(), 'creditcardcsc2' => $payment->getCcCid()); $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems(); $i = 1; foreach ($items as $item) { $fields = array_merge($fields, array('productsku' . $i => $item->getSku())); $fields = array_merge($fields, array('productname' . $i => $item->getName())); $fields = array_merge($fields, array('productprice' . $i => number_format($item->getPrice() * $currency_rate, 2, '.', ''))); $fields = array_merge($fields, array('productquantity' . $i => (int) $item->getQty())); $i++; } $ch = curl_init($url); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); $result = curl_exec($ch); curl_close($ch); //return $fields; return $this->explode_return_str($result); //return array('status'=>1,'transaction_id' => time() , 'fraud' => rand(0,1)); //return array('status'=>rand(0, 1),'transaction_id' => time() , 'fraud' => rand(0,1)); }
private function callApi(Varien_Object $payment, $amount, $transcition_type) { //call your authorize api here, incase of error throw exception. //only example code written below to show flow of code $order = $payment->getOrder(); $types = Mage::getSingleton('payment/config')->getCcTypes(); //echo '<pre>';print_r($order->getData());die('>>>'); if (isset($types[$payment->getCcType()])) { $type = $types[$payment->getCcType()]; } if (strlen($payment->getCcExpMonth()) == 1) { $card_expiredate = '0' . $payment->getCcExpMonth(); } else { $card_expiredate = $payment->getCcExpMonth(); } if (strlen($payment->getCcSsStartMonth()) == 1) { $card_startdate = '0' . $payment->getCcSsStartMonth(); } else { $card_startdate = $payment->getCcSsStartMonth(); } $startyear = substr($payment->getCcSsStartYear(), -2); $expireyear = substr($payment->getCcExpYear(), -2); $paymentAction = $this->getConfigData('payment_action'); $billingaddress = $order->getBillingAddress(); $countrycode = $this->getcountrycode($billingaddress->getData('country_id')); //$totals = strval(($amount)*100); $orderId = $order->getIncrementId(); $currencyDesc = $order->getBaseCurrencyCode(); $baseCurrency_code = Mage::app()->getBaseCurrencyCode(); $storeId = Mage::app()->getStore()->getId(); $SelectedCurrency = Mage::app()->getStore($storeId)->getCurrentCurrencyCode(); $module_currency_code = $this->getConfigData('payment_currency'); $paymentSenseSelectedCurrency = explode(',', $module_currency_code); $curArray = array('USD', 'GBP', 'EUR'); if (in_array($SelectedCurrency, $paymentSenseSelectedCurrency)) { $currcode = $SelectedCurrency; } else { if (in_array($baseCurrency_code, $paymentSenseSelectedCurrency)) { $currcode = $baseCurrency_code; } else { if (in_array($baseCurrency_code, $curArray)) { $currcode = $paymentSenseSelectedCurrency[0]; } else { return array('status' => 0, 'transaction_id' => time(), 'fraud' => rand(0, 1), 'message' => 'Currency Error', 'data' => '', 'CrossReference' => ''); } } } $arAdditionalInformationArray["PaymentCurrency"] = $currcode; $payment->setAdditionalInformation($arAdditionalInformationArray); $allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies(); $currencyRates = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrency_code, array_values($allowedCurrencies)); //$baseCurrnecyrate = 1/$currencyRates[Mage::app()->getStore()->getCurrentCurrencyCode()]; $grandTotal = $order->getData('base_grand_total'); $baseCurrnecyrate = $currencyRates[$currcode]; if ($currcode == 'EUR') { if ($currcode = $baseCurrency_code && $baseCurrency_code != '') { //$newprice = number_format((float)($order->getGrandTotal()*$baseCurrnecyrate),'2', '.', ''); $newprice = number_format((double) ($grandTotal * $baseCurrnecyrate), '2', '.', ''); } else { //$newprice = Mage::helper('directory')->currencyConvert($order->getGrandTotal(),'EUR',Mage::app()->getStore()->getCurrentCurrencyCode()); $newprice = Mage::helper('directory')->currencyConvert($grandTotal, 'EUR', Mage::app()->getStore()->getCurrentCurrencyCode()); } $currdes = '978'; } elseif ($currcode == 'GBP') { if ($currcode = $baseCurrency_code && $baseCurrency_code != '') { //$newprice = number_format((float)($order->getGrandTotal()*$baseCurrnecyrate),'2', '.', ''); $newprice = number_format((double) ($grandTotal * $baseCurrnecyrate), '2', '.', ''); } else { //$newprice = Mage::helper('directory')->currencyConvert($order->getGrandTotal(),Mage::app()->getStore()->getCurrentCurrencyCode(),'GBP'); $newprice = Mage::helper('directory')->currencyConvert($order->getGrandTotal(), Mage::app()->getStore()->getCurrentCurrencyCode(), 'GBP'); } $currdes = '826'; } else { if ($currcode = $baseCurrency_code && $baseCurrency_code != '') { $newprice = number_format((double) ($grandTotal * $baseCurrnecyrate), '2', '.', ''); } else { $newprice = Mage::helper('directory')->currencyConvert($grandTotal, 'USD', Mage::app()->getStore()->getCurrentCurrencyCode()); } $currdes = '840'; } $surcharge = $this->getConfigData('payment_surcharge'); $credit_surcharge = $this->getConfigData('surcharge_debit'); $newprice = round($newprice, 2); $totals = strval($newprice * 100); $url = $this->getConfigData('gateway_url'); $fields = array('MerchantID' => $this->getConfigData('api_username'), 'MerchantPassword' => $this->getConfigData('api_password'), 'PhoneNumber' => $billingaddress->getData('telephone'), 'EmailAddress' => $billingaddress->getData('email'), 'customer_ipaddress' => $_SERVER['REMOTE_ADDR'], 'Address1' => $billingaddress->getStreet1(), 'Address2' => $billingaddress->getStreet2(), 'City' => $billingaddress->getData('city'), 'CountryCode' => $countrycode, 'State' => $billingaddress->getData('region'), 'PostCode' => $billingaddress->getData('postcode'), 'CardName' => $payment->getCcOwner(), 'ExpiryDateMonth' => $card_expiredate, 'ExpiryDateYear' => $expireyear, 'CardNumber' => $payment->getCcNumber(), 'StartDateMonth' => $card_startdate, 'StartDateYear' => $startyear, 'IssueNumber' => '', 'TransactionType' => $transcition_type, 'Description' => 'Order' . $order->getIncrementId(), 'CV2' => $payment->getCcCid(), 'OrderID' => $order->getIncrementId(), 'currencydesc' => $currdes, 'Amount' => $totals); // print_r($fields);die(); $json = array(); $headers = array('SOAPAction:https://www.thepaymentgateway.net/CardDetailsTransaction', 'Content-Type: text/xml; charset = utf-8', 'Connection: close'); $xml = '<?xml version="1.0" encoding="utf-8"?>'; $xml .= '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'; $xml .= '<soap:Body>'; $xml .= '<CardDetailsTransaction xmlns="https://www.thepaymentgateway.net/">'; $xml .= '<PaymentMessage>'; $xml .= '<MerchantAuthentication MerchantID="' . $fields['MerchantID'] . '" Password="******" />'; $xml .= '<TransactionDetails Amount="' . $fields['Amount'] . '" CurrencyCode="' . $fields['currencydesc'] . '">'; $xml .= '<MessageDetails TransactionType="' . $fields['TransactionType'] . '" />'; $xml .= '<OrderID>' . $fields['OrderID'] . '</OrderID>'; $xml .= '<OrderDescription>' . $fields['Description'] . '</OrderDescription>'; $xml .= '<TransactionControl>'; $xml .= '<EchoCardType>TRUE</EchoCardType>'; $xml .= '<EchoAVSCheckResult>TRUE</EchoAVSCheckResult>'; $xml .= '<EchoCV2CheckResult>TRUE</EchoCV2CheckResult>'; $xml .= '<EchoAmountReceived>TRUE</EchoAmountReceived>'; $xml .= '<DuplicateDelay>20</DuplicateDelay>'; //$xml .= '<AVSOverridePolicy>'. $fields['AVSPolicy'] .'</AVSOverridePolicy>'; //$xml .= '<CV2OverridePolicy>'. $fields['CV2Policy'] .'</CV2OverridePolicy>'; $xml .= '<CustomVariables>'; $xml .= '<GenericVariable Name="MyInputVariable" Value="Ping" />'; $xml .= '</CustomVariables>'; $xml .= '</TransactionControl>'; $xml .= '</TransactionDetails>'; $xml .= '<CardDetails>'; $xml .= '<CardName>' . $fields['CardName'] . '</CardName>'; $xml .= '<CardNumber>' . $fields['CardNumber'] . '</CardNumber>'; if ($fields['ExpiryDateMonth'] != "") { $xml .= '<ExpiryDate Month="' . $fields['ExpiryDateMonth'] . '" Year="' . $fields['ExpiryDateYear'] . '" />'; } if ($fields['StartDateMonth'] != "") { $xml .= '<StartDate Month="' . $fields['StartDateMonth'] . '" Year="' . $fields['StartDateYear'] . '" />'; } $xml .= '<CV2>' . $fields['CV2'] . '</CV2>'; if ($fields['IssueNumber'] != "") { $xml .= '<IssueNumber>' . $fields['IssueNumber'] . '</IssueNumber>'; } $xml .= '</CardDetails>'; $xml .= '<CustomerDetails>'; $xml .= '<BillingAddress>'; $xml .= '<Address1>' . $fields['Address1'] . '</Address1>'; if (isset($fields['Address2']) && $fields['Address2'] != "") { $xml .= '<Address2>' . $fields['Address2'] . '</Address2>'; } if (isset($fields['Address3']) && $fields['Address3'] != "") { $xml .= '<Address3>' . $fields['Address3'] . '</Address3>'; } if (isset($fields['Address4']) && $fields['Address4'] != "") { $xml .= '<Address4>' . $fields['Address4'] . '</Address4>'; } $xml .= '<City>' . $fields['City'] . '</City>'; if ($fields['State'] != "") { $xml .= '<State>' . $fields['State'] . '</State>'; } $xml .= '<PostCode>' . $fields['PostCode'] . '</PostCode>'; $xml .= '<CountryCode>' . $fields['CountryCode'] . '</CountryCode>'; $xml .= '</BillingAddress>'; $xml .= '<EmailAddress>' . $fields['EmailAddress'] . '</EmailAddress>'; $xml .= '<PhoneNumber>' . $fields['PhoneNumber'] . '</PhoneNumber>'; //$xml .= '<CustomerIPAddress>'.$fields['CustomerIPAddress'].'</CustomerIPAddress>'; $xml .= '</CustomerDetails>'; $xml .= '<PassOutData>Some data to be passed out</PassOutData>'; $xml .= '</PaymentMessage>'; $xml .= '</CardDetailsTransaction>'; $xml .= '</soap:Body>'; $xml .= '</soap:Envelope>'; $gwId = 1; $domain = "paymentsensegateway.com"; $port = "4430"; $transattempt = 1; $soapSuccess = false; while (!$soapSuccess && $gwId <= 3 && $transattempt <= 3) { $url = 'https://gw' . $gwId . '.' . $domain . ':' . $port . '/'; //================================================================================= $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POSTFIELDS, $xml); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_ENCODING, 'UTF-8'); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $caInfoSetting = ini_get("curl.cainfo"); if (empty($caInfoSetting)) { curl_setopt($curl, CURLOPT_CAINFO, Mage::getModuleDir('', 'Paymentsense') . DS . 'lib' . DS . "cacert.pem"); } $ret = curl_exec($curl); $err = curl_errno($curl); $retHead = curl_getinfo($curl); curl_close($curl); $curl = null; //echo "<pre>";print_r($ret);die; //$json['error'] .= "\r\rerr=". $err ."\r\r"."response=".$ret; if ($err == 0) { $StatusCode = null; $soapStatusCode = null; if (preg_match('#<StatusCode>([0-9]+)</StatusCode>#iU', $ret, $soapStatusCode)) { $StatusCode = (int) $soapStatusCode[1]; $AuthCode = null; $soapAuthCode = null; $CrossReference = null; $soapCrossReference = null; $Message = null; $soapMessage = null; if (preg_match('#<AuthCode>([a-zA-Z0-9]+)</AuthCode>#iU', $ret, $soapAuthCode)) { $AuthCode = $soapAuthCode[1]; } if (preg_match('#<TransactionOutputData.*CrossReference="([a-zA-Z0-9]+)".*>#iU', $ret, $soapCrossReference)) { $CrossReference = $soapCrossReference[1]; } if (preg_match('#<Message>(.+)</Message>#iU', $ret, $soapMessage)) { $Message = $soapMessage[1]; } if ($StatusCode != 3) { Mage::getSingleton('core/session')->setJsonValue(''); } if ($StatusCode != 50) { $soapSuccess = true; switch ($StatusCode) { case 0: $status = 1; $json['error'] = ''; /* *$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('config_order_status_id')); */ if (preg_match('#<AddressNumericCheckResult>(.+)</AddressNumericCheckResult>#iU', $ret, $soapAVSCheck)) { $AVSCheck = $soapAVSCheck[1]; } if (preg_match('#<PostCodeCheckResult>(.+)</PostCodeCheckResult>#iU', $ret, $soapPostCodeCheck)) { $PostCodeCheck = $soapPostCodeCheck[1]; } if (preg_match('#<CV2CheckResult>(.+)</CV2CheckResult>#iU', $ret, $soapCV2Check)) { $CV2Check = $soapCV2Check[1]; } $successmessage = 'AuthCode: ' . $AuthCode . " || " . 'CrossReference: ' . $CrossReference . " || " . 'AVS Check: ' . $AVSCheck . " || " . 'Postcode Check: ' . $PostCodeCheck . " || " . 'CV2 Check: ' . $CV2Check; $json['error'] = ''; //$this->model_checkout_order->update($this->session->data['order_id'], $this->config->get('paymentsense_direct_order_status_id'), $successmessage, false); //$json['success'] = $this->url->link('checkout/success', '', 'SSL'); break; case 3: $status = 1; if (preg_match('#<ThreeDSecureOutputData>.*<PaREQ>(.+)</PaREQ>.*<ACSURL>(.+)</ACSURL>.*</ThreeDSecureOutputData>#iU', $ret, $soap3DSec)) { $PaREQ = $soap3DSec[1]; $ACSurl = $soap3DSec[2]; $json['ACSURL'] = $ACSurl; $json['MD'] = $CrossReference; $json['PaReq'] = $PaREQ; $json['TermUrl'] = Mage::getUrl('pay/index/callback', array('_secure' => true)); $json['error'] = ''; Mage::getSingleton('core/session')->setJsonValue($json); //$this->secureAuthorisation($json); } else { $json['error'] = 'Incorrect 3DSecure data.'; $do = false; } break; case 4: // Referred $json['error'] = 'Your card has been referred - please try a different card'; $do = false; $status = 0; break; case 5: // Declined $json['error'] = 'Your card has been declined - '; $status = 0; if (preg_match('#<AddressNumericCheckResult>(.+)</AddressNumericCheckResult>#iU', $ret, $soapAVSCheck)) { $AVSCheck = $soapAVSCheck[1]; } $failedreasons = ""; if ($AVSCheck == "FAILED") { if ($failedreasons != "") { $failedreasons .= " + AVS"; } else { $failedreasons = "Billing address"; } } if (preg_match('#<PostCodeCheckResult>(.+)</PostCodeCheckResult>#iU', $ret, $soapPostCodeCheck)) { $PostCodeCheck = $soapPostCodeCheck[1]; } if ($PostCodeCheck == "FAILED") { if ($failedreasons != "") { $failedreasons .= " + Postcode"; } else { $failedreasons = "Postcode"; } } if (preg_match('#<CV2CheckResult>(.+)</CV2CheckResult>#iU', $ret, $soapCV2Check)) { $CV2Check = $soapCV2Check[1]; } if ($CV2Check == "FAILED") { if ($failedreasons != "") { $failedreasons .= " + CV2"; } else { $failedreasons = "CV2"; } } if ($failedreasons != "") { $json['error'] .= $failedreasons . " checks failed. "; } $json['error'] .= 'Please check your billing address and card details and try again'; $do = false; break; case 20: // Duplicate // check the previous status in order to know if the transaction was a success $status = 1; if (preg_match('#<PreviousTransactionResult>.*<StatusCode>([0-9]+)</StatusCode>#iU', $ret, $soapStatus2)) { if ($soapStatus2[1] == '0') { //$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('config_order_status_id')); if (preg_match('#<AddressNumericCheckResult>(.+)</AddressNumericCheckResult>#iU', $ret, $soapAVSCheck)) { $AVSCheck = $soapAVSCheck[1]; } if (preg_match('#<PostCodeCheckResult>(.+)</PostCodeCheckResult>#iU', $ret, $soapPostCodeCheck)) { $PostCodeCheck = $soapPostCodeCheck[1]; } if (preg_match('#<CV2CheckResult>(.+)</CV2CheckResult>#iU', $ret, $soapCV2Check)) { $CV2Check = $soapCV2Check[1]; } $successmessage = 'AuthCode: ' . $AuthCode . " || " . 'CrossReference: ' . $CrossReference . " || " . 'AVS Check: ' . $AVSCheck . " || " . 'Postcode Check: ' . $PostCodeCheck . " || " . 'CV2 Check: ' . $CV2Check . ' || ' . '3D Secure: PASSED'; //$this->model_checkout_order->update($this->session->data['order_id'], $this->config->get('paymentsense_direct_order_status_id'), $successmessage, false); //$json['success'] = $this->url->link('checkout/success', '', 'SSL'); $json['error'] = ''; break; } else { if ($soapStatus2[1] == '4') { $json['error'] = 'Your card has been referred - please try a different card'; $do = false; break; } else { if ($soapStatus2[1] == '5') { $json['error'] = 'Your card has been declined - ' . str_replace("Card declined: ", "", $Message) . ' checks failed.\\nPlease check your billing address and card details and try again'; $do = false; break; } else { $json['error'] = 'Duplicate transaction'; $do = false; } } } } else { $json['error'] = 'Duplicate transaction'; $do = false; } break; case 30: default: $status = 0; // generic error // read error message if (preg_match('#<Message>(.*)</Message>#iU', $ret, $msg)) { $msg = $msg[1]; } else { $msg = ''; } $json['error'] = 'PaymentSense Error (' . $StatusCode . ') :' . $msg; $do = false; break; } } } } if ($transattempt <= 3) { $transattempt++; } else { $transattempt = 1; $gwId++; } } return array('status' => $status, 'transaction_id' => time(), 'fraud' => rand(0, 1), 'message' => $json['error'], 'data' => $json, 'CrossReference' => $CrossReference, 'paymenstatus' => $message); }
protected function getPaymentData(Varien_Object $payment) { if (!is_array($this->_paymentData)) { $billing = $payment->getOrder()->getBillingAddress(); $this->_paymentData = array('storageData' => array('fromDatastorageId' => $payment->getPoNumber()), 'addressData' => array('addrName' => $payment->getCcOwner(), 'addrStreet' => $this->_normalizeStreet($billing->getStreet()), 'addrCity' => $billing->getCity(), 'addrZip' => $billing->getPostcode(), 'addrCountry' => $billing->getCountry(), 'addrEmail' => $payment->getOrder()->getCustomerEmail())); } return $this->_paymentData; }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); if (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) { //Mage::getSingleton('core/session')->setData('sharedpagePaypal', $data->getSharedpageNotsaved()); Mage::getSingleton('core/session')->setData('sharedpagePaypal', 'paypal'); } elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) { $info->setTransparentNotsaved($data->getTransparentNotsaved()); //Option choice if ($data->getMethod() == 'ewayrapid_saved' && !$data->getTransparentSaved()) { Mage::throwException(Mage::helper('payment')->__('Please select an option payment for eWay saved')); } elseif ($data->getMethod() == 'ewayrapid_notsaved' && !$data->getTransparentNotsaved()) { Mage::throwException(Mage::helper('payment')->__('Please select an option payment for eWay not saved')); } //New Token if ($data->getMethod() == 'ewayrapid_saved' && $data->getTransparentSaved() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD && $data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW && Mage::helper('ewayrapid/customer')->checkTokenListByType(Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD)) { Mage::throwException(Mage::helper('payment')->__('You could only save one PayPal account, please select PayPal account existed to payent.')); } if ($data->getTransparentNotsaved()) { Mage::getSingleton('core/session')->setTransparentNotsaved($data->getTransparentNotsaved()); } if ($data->getTransparentSaved()) { Mage::getSingleton('core/session')->setTransparentSaved($data->getTransparentSaved()); } if ($data->getMethod()) { Mage::getSingleton('core/session')->setMethod($data->getMethod()); } if ($data->getSavedToken()) { Mage::getSingleton('core/session')->setSavedToken($data->getSavedToken()); if (is_numeric($data->getSavedToken())) { $token = Mage::helper('ewayrapid/customer')->getTokenById($data->getSavedToken()); /* @var Eway_Rapid31_Model_Request_Token $model */ $model = Mage::getModel('ewayrapid/request_token'); $type = $model->checkCardName($token); Mage::getSingleton('core/session')->setTransparentSaved($type); unset($model); unset($token); } } $infoCard = new Varien_Object(); Mage::getSingleton('core/session')->setInfoCard($infoCard->setCcType($data->getCcType())->setOwner($data->getCcOwner())->setLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))->setCard($data->getCcNumber())->setNumber($data->getCcNumber())->setCid($data->getCcCid())->setExpMonth($data->getCcExpMonth())->setExpYear($data->getCcExpYear())); } else { $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear()); } return $this; }
private function callApi(Varien_Object $payment, $amount, $type) { //call your authorize api here, incase of error throw exception. //only example code written below to show flow of code $order = $payment->getOrder(); $types = Mage::getSingleton('payment/config')->getCcTypes(); if (isset($types[$payment->getCcType()])) { $type = $types[$payment->getCcType()]; } $billingaddress = $order->getBillingAddress(); $totals = number_format($amount, 2, '.', ''); $orderId = $order->getIncrementId(); /* wwwwwwwwwwwwwwwwwwww */ $read = Mage::getSingleton('core/resource')->getConnection('core_read'); $instapago_inf = $read->fetchAll("select * from instapago_instapagomodulo_instapago"); //var_dump ($instapago_inf); $storeId = Mage::app()->getStore()->getStoreId(); foreach ($instapago_inf as &$valor) { if ($valor['status'] == "1") { if ($valor['tienda'] == $storeId) { $url = 'https://api.instapago.com/payment'; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $fields = array('KeyID' => $valor['keyid'], 'PublicKeyId' => $valor['publickeyid'], 'amount' => $totals, 'Description' => 'Tienda: ' . $storeId . ' numero de orden:' . $order->getIncrementId(), 'CardHolder' => $payment->getCcOwner(), 'CardHolderId' => $_SESSION['ci'], 'CardNumber' => $payment->getCcNumber(), 'CVC' => $payment->getCcCid(), 'ExpirationDate' => $payment->getCcExpMonth() . "/" . $payment->getCcExpYear(), 'StatusId' => $valor['statusid'], 'Address' => '', 'City' => '', 'ZipCode' => '', 'State' => '', 'customer_ipaddress' => $ip); $fields_string = ""; foreach ($fields as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } $fields_string = substr($fields_string, 0, -1); //var_dump ($fields_string); //open connection $ch = curl_init($url); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); // DO NOT RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN THE CONTENTS OF THE CALL curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); // Timeout on connect (2 minutes) //execute post $result = curl_exec($ch); //var_dump ($result); //var_dump (json_decode($result)); $result_json = json_decode($result, true); //var_dump($result_json); $_SESSION['result_json'] = $result_json; if ($result_json['success'] == false) { $status00 = 0; } else { if ($result_json['success'] == true) { $status00 = 1; } } curl_close($ch); //return array('status'=>rand(0, 1),'transaction_id' => time() , 'fraud' => rand(0,1)); return array('status' => $status00, 'transaction_id' => time(), 'fraud' => rand(0, 1), 'code0' => $result_json['code'], 'result_json' => $result_json, $result_json['message'], 'id' => $result_json['id']); } } } /* wwwwwwwwwwwwwwwwwwww */ //return array('status'=>rand(0, 1),'transaction_id' => time() , 'fraud' => rand(0,1)); }
public function create(Varien_Object $payment, $amount, $order, $paymentMethod = null, $merchantAccount = null, $recurringType = null, $enableMoto = null) { $incrementId = $order->getIncrementId(); $orderCurrencyCode = $order->getOrderCurrencyCode(); // override amount because this amount uses the right currency $amount = $order->getGrandTotal(); $customerId = $order->getCustomerId(); $realOrderId = $order->getRealOrderId(); $this->reference = $incrementId; $this->merchantAccount = $merchantAccount; $this->amount->currency = $orderCurrencyCode; $this->amount->value = Mage::helper('adyen')->formatAmount($amount, $orderCurrencyCode); //shopper data $customerEmail = $order->getCustomerEmail(); $this->shopperEmail = $customerEmail; $this->shopperIP = $order->getRemoteIp(); $this->shopperReference = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId; // add recurring type for oneclick and recurring if ($recurringType) { /* if user uncheck the checkbox store creditcard don't set ONECLICK in the recurring contract * for contracttype oneclick,recurring it means it will use recurring and if contracttype is recurring this can stay on recurring */ if ($paymentMethod == "cc" && $payment->getAdditionalInformation("store_cc") == "" && $recurringType == "ONECLICK,RECURRING") { $this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring(); $this->recurring->contract = "RECURRING"; } else { if (!($paymentMethod == "cc" && $payment->getAdditionalInformation("store_cc") == "" && $recurringType != "RECURRING")) { $this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring(); $this->recurring->contract = $recurringType; } } } /** * Browser info * @var unknown_type */ $this->browserInfo->acceptHeader = $_SERVER['HTTP_ACCEPT']; $this->browserInfo->userAgent = $_SERVER['HTTP_USER_AGENT']; switch ($paymentMethod) { case "elv": $elv = unserialize($payment->getPoNumber()); $this->card = null; $this->shopperName = null; $this->bankAccount = null; $this->elv->accountHolderName = $elv['account_owner']; $this->elv->bankAccountNumber = $elv['account_number']; $this->elv->bankLocation = $elv['bank_location']; $this->elv->bankLocationId = $elv['bank_location']; $this->elv->bankName = $elv['bank_name']; break; case "cc": case "oneclick": $this->shopperName = null; $this->elv = null; $this->bankAccount = null; if ($paymentMethod == "oneclick") { $recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference"); } else { $recurringDetailReference = null; } // set shopperInteraction if ($recurringType == "RECURRING") { $this->shopperInteraction = "ContAuth"; } else { $this->shopperInteraction = "Ecommerce"; } if (Mage::app()->getStore()->isAdmin() && $enableMoto != null && $enableMoto == 1) { $this->shopperInteraction = "Moto"; } if (Mage::getModel('adyen/adyen_cc')->isCseEnabled()) { if ($recurringDetailReference && $recurringDetailReference != "") { $this->selectedRecurringDetailReference = $recurringDetailReference; } $this->card = null; $kv = new Adyen_Payment_Model_Adyen_Data_AdditionalDataKVPair(); $kv->key = new SoapVar("card.encrypted.json", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"); $kv->value = new SoapVar($payment->getAdditionalInformation("encrypted_data"), XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"); $this->additionalData->entry = $kv; } else { if ($recurringDetailReference && $recurringDetailReference != "") { $this->selectedRecurringDetailReference = $recurringDetailReference; if ($recurringType != "RECURRING") { $this->card->cvc = $payment->getCcCid(); } // TODO: check if expirymonth and year is changed if so add this in the card object $this->card->expiryMonth = $payment->getCcExpMonth(); $this->card->expiryYear = $payment->getCcExpYear(); } else { $this->card->cvc = $payment->getCcCid(); $this->card->expiryMonth = $payment->getCcExpMonth(); $this->card->expiryYear = $payment->getCcExpYear(); $this->card->holderName = $payment->getCcOwner(); $this->card->number = $payment->getCcNumber(); } } // installments if (Mage::helper('adyen/installments')->isInstallmentsEnabled() && $payment->getAdditionalInformation('number_of_installments') > 0) { $this->installments = new Adyen_Payment_Model_Adyen_Data_Installments(); $this->installments->value = $payment->getAdditionalInformation('number_of_installments'); } break; case "boleto": $boleto = unserialize($payment->getPoNumber()); $this->card = null; $this->elv = null; $this->bankAccount = null; $this->socialSecurityNumber = $boleto['social_security_number']; $this->selectedBrand = $boleto['selected_brand']; $this->shopperName->firstName = $boleto['firstname']; $this->shopperName->lastName = $boleto['lastname']; $this->deliveryDate = $boleto['delivery_date']; break; case "sepa": $sepa = unserialize($payment->getPoNumber()); $this->card = null; $this->elv = null; $this->shopperName = null; $this->bankAccount->iban = $sepa['iban']; $this->bankAccount->ownerName = $sepa['account_name']; $this->bankAccount->countryCode = $sepa['country']; $this->selectedBrand = "sepadirectdebit"; break; } return $this; }
/** * Sets up the data on the object * * @param $data * @return Gorilla_ChasePaymentech_Model_Gateway */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } if ($data->getCcSaveCard() == "Yes") { $cc_save_card = true; } else { $cc_save_card = false; } $info = $this->getInfoInstance(); $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcSsIssue($data->getCcSsIssue())->setCcSsStartMonth($data->getCcSsStartMonth())->setCcSsStartYear($data->getCcSsStartYear())->setCcSaveCard('true')->setAdditionalInformation('chasepaymentech_card', $data->getChasepaymentechCard())->setAdditionalInformation('cc_save_card', $cc_save_card); return $this; }
/** * Return commno data for *all* transactions. * @return array Data */ public function _getGeneralTrnData(Varien_Object $payment, $adminParams = array()) { $order = $payment->getOrder(); $quoteObj = $this->_getQuote(); $vendorTxCode = $this->_getTrnVendorTxCode(); if ($payment->getCcNumber()) { $vendorTxCode .= $this->_cleanString(substr($payment->getCcOwner(), 0, 10)); } $payment->setVendorTxCode($vendorTxCode); $request = new Varien_Object(); $request->setVPSProtocol((string) $this->getVpsProtocolVersion($this->getConfigData('mode')))->setReferrerID($this->getConfigData('referrer_id'))->setVendor($this->getConfigData('vendor'))->setVendorTxCode($vendorTxCode); $request->setClientIPAddress($this->getClientIp()); if ($payment->getIntegra()) { //Server if (is_array($adminParams) && !empty($adminParams)) { $confParam = isset($adminParams['order']['send_confirmation']) ? '&e=' . (int) $adminParams['order']['send_confirmation'] : ''; if (isset($adminParams['order']['account']['email'])) { $confParam .= '&l=' . urlencode($adminParams['order']['account']['email']); } if (isset($adminParams['order']['account']['group_id'])) { $confParam .= '&g=' . $adminParams['order']['account']['group_id']; } } else { $confParam = ''; } $this->getSageSuiteSession()->setLastVendorTxCode($vendorTxCode); $request->setIntegration($payment->getIntegra()); $request->setData('notification_URL', $this->getNotificationUrl() . '&vtxc=' . $vendorTxCode . $confParam); $request->setData('success_URL', $this->getSuccessUrl()); $request->setData('redirect_URL', $this->getRedirectUrl()); $request->setData('failure_URL', $this->getFailureUrl()); } if ($this->_getIsAdminOrder()) { $request->setAccountType('M'); } if ($payment->getAmountOrdered()) { $this->_setRequestCurrencyAmount($request, $quoteObj); } if (!empty($order)) { $billing = $order->getBillingAddress(); if (!empty($billing)) { $request->setBillingAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setBillingSurname($this->ss($billing->getLastname(), 20))->setBillingFirstnames($this->ss($billing->getFirstname(), 20))->setBillingPostCode($this->sanitizePostcode($this->ss($billing->getPostcode(), 10)))->setBillingAddress1($this->ss($billing->getStreet(1), 100))->setBillingAddress2($this->ss($billing->getStreet(2), 100))->setBillingCity($this->ss($billing->getCity(), 40))->setBillingCountry($billing->getCountry())->setContactNumber(substr($this->_cphone($billing->getTelephone()), 0, 20)); if ($billing->getCountry() == 'US') { $request->setBillingState($billing->getRegionCode()); } $request->setCustomerEMail($billing->getEmail()); } if (!$request->getDescription()) { $request->setDescription('.'); } $shipping = $order->getShippingAddress(); if (!$quoteObj->isVirtual()) { $request->setDeliveryAddress($shipping->getStreet(1) . ' ' . $shipping->getCity() . ' ' . $shipping->getRegion() . ' ' . $shipping->getCountry())->setDeliverySurname($this->ss($shipping->getLastname(), 20))->setDeliveryFirstnames($this->ss($shipping->getFirstname(), 20))->setDeliveryPostCode($this->sanitizePostcode($this->ss($shipping->getPostcode(), 10)))->setDeliveryAddress1($this->ss($shipping->getStreet(1), 100))->setDeliveryAddress2($this->ss($shipping->getStreet(2), 100))->setDeliveryCity($this->ss($shipping->getCity(), 40))->setDeliveryCountry($shipping->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($shipping->getTelephone())), 20)); if ($shipping->getCountry() == 'US') { $request->setDeliveryState($shipping->getRegionCode()); } } else { #If the cart only has virtual products, I need to put an shipping address to Sage Pay. #Then the billing address will be the shipping address to $request->setDeliveryAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setDeliverySurname($this->ss($billing->getLastname(), 20))->setDeliveryFirstnames($this->ss($billing->getFirstname(), 20))->setDeliveryPostCode($this->sanitizePostcode($this->ss($billing->getPostcode(), 10)))->setDeliveryAddress1($this->ss($billing->getStreet(1), 100))->setDeliveryAddress2($this->ss($billing->getStreet(2), 100))->setDeliveryCity($this->ss($billing->getCity(), 40))->setDeliveryCountry($billing->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($billing->getTelephone())), 20)); if ($billing->getCountry() == 'US') { $request->setDeliveryState($billing->getRegionCode()); } } } if ($payment->getCcNumber()) { $request->setCardNumber($payment->getCcNumber())->setExpiryDate(sprintf('%02d%02d', $payment->getCcExpMonth(), substr($payment->getCcExpYear(), strlen($payment->getCcExpYear()) - 2)))->setCardType($payment->getCcType())->setCV2($payment->getCcCid())->setCardHolder($payment->getCcOwner()); if ($payment->getCcIssue()) { $request->setIssueNumber($payment->getCcIssue()); } if ($payment->getCcStartMonth() && $payment->getCcStartYear()) { $request->setStartDate(sprintf('%02d%02d', $payment->getCcStartMonth(), substr($payment->getCcStartYear(), strlen($payment->getCcStartYear()) - 2))); } } $basket = Mage::helper('sagepaysuite')->getSagePayBasket($quoteObj, false); if (!empty($basket)) { if ($basket[0] == "<") { $request->setBasketXML($basket); } else { $request->setBasket($basket); } } if (!$request->getDeliveryPostCode()) { $request->setDeliveryPostCode('000'); } if (!$request->getBillingPostCode()) { $request->setBillingPostCode('000'); } return $request; }
public function getNewTokenCardArray(Varien_Object $payment) { $data = array(); $data['CardHolder'] = $payment->getCcOwner(); $data['CardNumber'] = $payment->getCcNumber(); $data['CardType'] = $payment->getCcType(); $data['Currency'] = $payment->getOrder()->getOrderCurrencyCode(); $data['CV2'] = $payment->getCcCid(); $data['Nickname'] = $payment->getCcNickname(); $data['Protocol'] = 'direct'; #For persistant storing $data['ExpiryDate'] = str_pad($payment->getCcExpMonth(), 2, '0', STR_PAD_LEFT) . substr($payment->getCcExpYear(), 2); if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) { $data['StartDate'] = str_pad($payment->getCcSsStartMonth(), 2, '0', STR_PAD_LEFT) . substr($payment->getCcSsStartYear(), 2); } return $data; }
public function create(Varien_Object $payment, $amount, $order, $paymentMethod = null, $merchantAccount = null) { $incrementId = $order->getIncrementId(); $orderCurrencyCode = $order->getOrderCurrencyCode(); $customerId = $order->getCustomerId(); $this->reference = $incrementId; $this->merchantAccount = $merchantAccount; $this->amount->currency = $orderCurrencyCode; $this->amount->value = $this->_formatAmount($amount); $this->sesionId = $order->getQuoteId(); //shopper data $customerEmail = $order->getCustomerEmail(); $this->shopperEmail = $customerEmail; $this->shopperIP = $order->getRemoteIp(); $this->shopperReference = $customerId; /** * Browser info * @var unknown_type */ $this->browserInfo = $_SERVER['HTTP_USER_AGENT']; switch ($paymentMethod) { case "elv": $elv = unserialize($payment->getPoNumber()); $this->card = null; $this->elv->accountHolderName = $elv['account_owner']; $this->elv->bankAccountNumber = $elv['account_number']; $this->elv->bankLocation = $elv['bank_location']; $this->elv->bankLocationId = $elv['bank_location']; $this->elv->bankName = $elv['bank_name']; break; case "cc": $this->elv = null; $this->card->cvc = $payment->getCcCid(); $this->card->expiryMonth = $payment->getCcExpMonth(); $this->card->expiryYear = $payment->getCcExpYear(); $this->card->holderName = $payment->getCcOwner(); $this->card->number = $payment->getCcNumber(); // installments if (Mage::helper('adyen/installments')->isInstallmentsEnabled()) { $kv = new Madia_Adyen_Model_Adyen_Data_AdditionalDataKVPair(); $kv->key = new SoapVar("installments", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"); $kv->value = new SoapVar($payment->getPoNumber(), XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"); $this->additionalData->entry = $kv; } break; } return $this; }
public function _place(Varien_Object $payment, $amount, $requestType) { try { $order = $payment->getOrder(); $billingAddress = $order->getBillingAddress(); $flag = $payment->getCcType(); $parcels = $payment->getInstallments(); $parcelMax = Mage::getStoreConfig('payment/azpay_cc/max_installments_' . $flag . ''); $parcelMinValue = ceil(Mage::getStoreConfig('payment/azpay_cc/min_installment_value_' . $flag . '')); $amountTotal = ceil(Mage::helper('azpay')->formatAmount($amount)); $parcelValue = ceil($amountTotal / $parcels); // Check quantity of parcels if ($parcels > $parcelMax) { return Mage::throwException("Quantidade inválida de parcelas."); } // Check value of parcel if ($parcelValue < $parcelMinValue) { return Mage::throwException("Valor da parcela inválido."); } //AZPay config $azpay = new AZPay($this->_merchantId, $this->_merchantKey); $azpay->curl_timeout = 60; $azpay->config_order['reference'] = $order->getRealOrderId(); $azpay->config_order['totalAmount'] = Mage::helper('azpay')->formatAmount($amount); $azpay->config_options['urlReturn'] = Mage::getUrl('azpay/transaction_cc/postback'); $azpay->config_card_payments['amount'] = Mage::helper('azpay')->formatAmount($amount); $azpay->config_card_payments['acquirer'] = $this->getConfigData('acquirer_' . $flag . ''); $azpay->config_card_payments['method'] = $parcels == '1' ? 1 : 2; $azpay->config_card_payments['flag'] = $payment->getCcType(); $azpay->config_card_payments['numberOfPayments'] = $parcels; $azpay->config_card_payments['cardHolder'] = $payment->getCcOwner(); $azpay->config_card_payments['cardNumber'] = Mage::helper('core')->decrypt($payment->getCcNumber()); $azpay->config_card_payments['cardSecurityCode'] = Mage::helper('core')->decrypt($payment->getCcCid()); $azpay->config_card_payments['cardExpirationDate'] = $payment->getCcExpYear() . $payment->getCcExpMonth(); if ($order->getCustomerId()) { $azpay->config_billing['customerIdentity'] = $order->getCustomerId(); } else { $azpay->config_billing['customerIdentity'] = $order->getRealOrderId(); } $azpay->config_billing['name'] = $order->getCustomerName(); $azpay->config_billing['address'] = $billingAddress->getStreet(1); $azpay->config_billing['addressNumber'] = $billingAddress->getStreet(2); $azpay->config_billing['address2'] = $billingAddress->getStreet(3) ? $billingAddress->getStreet(3) : ''; $azpay->config_billing['city'] = $billingAddress->getCity(); $azpay->config_billing['state'] = $billingAddress->getRegionCode(); $azpay->config_billing['postalCode'] = Zend_Filter::filterStatic($billingAddress->getPostcode(), 'Digits'); $azpay->config_billing['phone'] = $billingAddress->getTelephone(); $azpay->config_billing['email'] = $order->getCustomerEmail(); //Authorize method if ($requestType == "authorize") { //Fraud config $phoneData = Mage::helper('azpay')->splitTelephone($billingAddress->getTelephone()); $costumerIP = $payment->getAdditionalInformation('customer_ip'); $azpay->config_options['fraud'] = "true"; $azpay->config_options['costumerIP'] = $costumerIP; $azpay->config_billing['phonePrefix'] = $phoneData['ddd']; $azpay->config_billing['phoneNumber'] = $phoneData['number']; foreach ($order->getItemsCollection() as $_item) { $azpay->config_product['productName'] = $_item->getProduct()->getName(); $azpay->config_product['quantity'] = $_item->getQtyOrdered(); $azpay->config_product['price'] = $_item->getProduct()->getFinalPrice($_item->getQtyOrdered()); } //Prepare authorization to transaction $operation = $azpay->authorize(); //XML to save in log $azpay->getXml(); } //Sale method if ($requestType == "authorize_capture") { //Prepare authorization to direct sale $operation = $azpay->sale(); } //Log if ($this->getConfigData('log')) { Mage::log($azpay, null, "azpay_cc.log"); } //Execute operation $operation->execute(); } catch (AZPay_Error $e) { # HTTP 409 - AZPay Error $error = $azpay->responseError(); $response_message = $error['error_message']; Mage::log($e->getMessage(), null, "azpay_cc_error.log"); return Mage::throwException("Ocorreu um erro com o seu pagamento: " . $response_message); } catch (AZPay_Curl_Exception $e) { # Connection Error $response_message = $e->getMessage(); return Mage::throwException("Ocorreu um erro com o seu pagamento: " . $response_message); } catch (AZPay_Exception $e) { # General Error $response_message = $e->getMessage(); return Mage::throwException("Ocorreu um erro com o seu pagamento: " . $response_message); } //Response AZPay $gateway_response = $azpay->response(); //Check response return if (!isset($gateway_response)) { return Mage::throwException("Ocorreu um erro com a resposta do pagamento"); } $response_status = intval($gateway_response->status); $response_message = Config::$STATUS_MESSAGES[$response_status]['title']; if ($response_status == Config::$STATUS['AUTHORIZED'] || $response_status == Config::$STATUS['APPROVED']) { } else { return Mage::throwException("Ocorreu um erro com o seu pagamento: " . $response_message); } // azpay info $payment->setAzpayTransactionId($gateway_response->transactionId); return $this; }