/** * Try to create a card record from legacy data. */ public function importLegacyData(Varien_Object $payment) { // Customer ID -- pull from customer if possible, otherwise go to Authorize.Net. if ($this->getCustomer()->getAuthnetcimProfileId() != '') { $this->setProfileId($this->getCustomer()->getAuthnetcimProfileId()); } else { $this->_createCustomerProfile(); } // Payment ID -- pull from order if possible. $this->setPaymentId($payment->getOrder()->getExtCustomerId()); if ($this->getProfileId() == '' || $this->getPaymentId() == '') { Mage::helper('tokenbase')->log($this->getMethod(), 'Authorize.Net CIM: Unable to covert legacy data for processing. Please seek support.'); Mage::throwException(Mage::helper('tokenbase')->__('Authorize.Net CIM: Unable to covert legacy data for processing. Please seek support.')); } if ($payment->getCcType() != '') { $this->setAdditional('cc_type', $payment->getCcType()); } if ($payment->getCcLast4() != '') { $this->setAdditional('cc_last4', $payment->getCcLast4()); } if ($payment->getCcExpYear() > date('Y') || $payment->getCcExpYear() == date('Y') && $payment->getCcExpMonth() >= date('n')) { $this->setAdditional('cc_exp_year', $payment->getCcExpYear())->setAdditional('cc_exp_month', $payment->getCcExpMonth())->setExpires(sprintf("%s-%s-%s 23:59:59", $payment->getCcExpYear(), $payment->getCcExpMonth(), date('t', strtotime($payment->getCcExpYear() . '-' . $payment->getCcExpMonth())))); } return $this; }
public function order(Varien_Object $payment, $amount) { $order = $payment->getOrder(); $order_id = $order->getId(); $order_increment_id = $order->getIncrementId(); $store_id = $order->getStoreId(); $ccType = $payment->getCcType(); // reorder $reorder_increment_id = explode('-', $order_increment_id); // reorder $order_increment_id = $reorder_increment_id[0]; $order_suffix_id = @$reorder_increment_id[1]; $expiration = strtotime('+' . $this->_getStoreConfig($ccType, 'expiration') . 'days'); $transaction_expiration = date('Y-m-d', $expiration); $increment = $this->_getStoreConfig('slips', 'order_id_increment'); $order_increment_prefix = $this->_getOrderIncrementPrefix($store_id); $number = $order_increment_id - $order_increment_prefix; if (!empty($order_suffix_id)) { $number *= pow(10, strlen($order_suffix_id)); $number += $order_suffix_id; } $number += $increment; $data = array('order_id' => $order_id, 'amount' => $amount, 'expiration' => $transaction_expiration, 'number' => $number); $result = Mage::getModel('utils/sql')->insert('gamuza_slips_transactions', $data); if (!$result) { Mage::throwException(Mage::helper('slips')->__('Unable to save the Slip and Deposit informations. Please verify your database.')); } $this->setStore($payment->getOrder()->getStoreId()); $payment->setAmount($amount); $payment->setLastTransId($order_id); $payment->setStatus(self::STATUS_APPROVED); 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; }
/** * 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; }
public function order(Varien_Object $payment, $amount) { $order = $payment->getOrder(); $order_id = $order->getId(); $order_increment_id = $order->getIncrementId(); $quote = $order->getQuote(); $store_id = $order->getStoreId(); $ccType = $payment->getCcType(); // reorder $reorder_increment_id = explode('-', $order_increment_id); // reorder $order_increment_id = $reorder_increment_id[0]; $order_suffix_id = @$reorder_increment_id[1]; $code = $this->_getStoreConfig('settings/code'); $key = $this->_getStoreConfig('settings/key'); $obs = $this->_getStoreConfig('settings/obs'); $obsadd1 = $this->_getStoreConfig('settings/obsadd1'); $obsadd2 = $this->_getStoreConfig('settings/obsadd2'); $obsadd3 = $this->_getStoreConfig('settings/obsadd3'); $tax_vat = $order->getCustomerTaxvat(); $address = $quote->getBillingAddress(); $name = $address->getName(); list($street1, $street2) = $this->_getSplittedStreet($address, $store_id); $postcode = $address->getPostcode(); $city = $address->getCity(); $region = $address->getRegion(); $expiration = strtotime('+' . $this->_getStoreConfig('settings/expiration') . 'days'); $bank_expiration = date('dmY', $expiration); $transaction_expiration = date('Y-m-d', $expiration); $return_url = $this->_getStoreConfig('settings/return_url'); $increment = $this->_getStoreConfig('settings/order_id_increment'); $order_increment_prefix = $this->_getOrderIncrementPrefix($store_id); $number = $order_increment_id - $order_increment_prefix; if (!empty($order_suffix_id)) { $number *= pow(10, strlen($order_suffix_id)); $number += $order_suffix_id; } $number += $increment; $short_number = substr($number, -8); /* Order number max. length for ItauShopLine */ $submit_dc = Mage::getModel('itaushopline/itaucripto')->geraDados($code, $short_number, str_replace('.', "", number_format($amount, 2, ',', '.')), $obs, $key, $name, '01', $tax_vat, $street1, $street2, $postcode, $city, $region, $bank_expiration, $return_url, $obsadd1, $obsadd2, $obsadd3); if (strlen($submit_dc) < self::ITAU_SHOPLINE_SUBMIT_TRANSACTION_LENGTH) { Mage::throwException(Mage::helper('itaushopline')->__('Unable to generate submit transaction code. Please check your settings.')); } $query_dc = Mage::getModel('itaushopline/itaucripto')->geraConsulta($code, $short_number, '0', $key); if (strlen($query_dc) < self::ITAU_SHOPLINE_QUERY_TRANSACTION_LENGTH) { Mage::throwException(Mage::helper('itaushopline')->__('Unable to generate query transaction code. Please check your settings.')); } $data = array('order_id' => $order_id, 'amount' => $amount, 'expiration' => $transaction_expiration, 'number' => $short_number, 'submit_dc' => $submit_dc, 'query_dc' => $query_dc); $result = Mage::getModel('utils/sql')->insert('gamuza_itaushopline_transactions', $data); if (!$result) { Mage::throwException(Mage::helper('itaushopline')->__('Unable to save the Itau ShopLine informations. Please verify your database.')); } $this->setStore($payment->getOrder()->getStoreId()); $payment->setAmount($amount); $payment->setLastTransId($order_id); $payment->setStatus(self::STATUS_APPROVED); 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->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; }
/** * 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; }
/** * 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; }
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; }
public function create(Varien_Object $payment, $amount, $paymentMethod = null, $merchantAccount = null, $recurringType = 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(); $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; $this->deliveryAddress = new Adyen_Payment_Model_Adyen_Data_DeliveryAddress(); $this->billingAddress = new Adyen_Payment_Model_Adyen_Data_BillingAddress(); $billingAddress = $order->getBillingAddress(); $helper = Mage::helper('adyen'); if ($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->street = $helper->getStreet($billingAddress)->getName(); $this->deliveryAddress->houseNumberOrName = $helper->getStreet($billingAddress)->getHouseNumber(); $this->deliveryAddress->city = $billingAddress->getCity(); $this->deliveryAddress->postalCode = $billingAddress->getPostcode(); $this->deliveryAddress->stateOrProvince = $billingAddress->getRegionCode(); $this->deliveryAddress->country = $billingAddress->getCountryId(); } 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 ($paymentMethod == "adyen_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 is only needed for creditcards if ($payment->getAdditionalInformation("encrypted_data") != "") { $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 ($paymentMethod == 'cc') { // For CC encrypted data is needed if you use CSE Mage::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'); } 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; }
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; }
/** * 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; }
/** * Convert from Magento card types to Litle * * @deprecated * * @param Varien_Object $payment * @return string */ public function litleCcTypeEnum(Varien_Object $payment) { return $this->litleCcType($payment->getCcType()); }
/** * * @param Varien_Object $payment * @param type $amount * @return of type Velocity_CreditCard_Model_Payment class $this object. */ public function capture(Varien_Object $payment, $amount) { $this->_callVelocityGateway(); try { $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(); $avsData = array('Street' => $billingaddress->getData('street'), 'City' => $billingaddress->getData('city'), 'StateProvince' => $billingaddress->getData('region'), 'PostalCode' => $billingaddress->getData('postcode'), 'Country' => $billingaddress->getData('country_id')); $cardData = array('cardtype' => ucfirst(str_replace(' ', '', $type)), 'pan' => $payment->getCcNumber(), 'expire' => sprintf("%02d", $payment->getCcExpMonth()) . substr($payment->getCcExpYear(), -2), 'cvv' => $payment->getCcCid(), 'track1data' => '', 'track2data' => ''); $response = $this->velocityProcessor->verify(array('amount' => $totals, 'avsdata' => $avsData, 'carddata' => $cardData, 'entry_mode' => 'Keyed', 'IndustryType' => 'Ecommerce', 'Reference' => 'xyz', 'EmployeeId' => '11')); if (isset($response['Status']) && $response['Status'] == 'Successful') { try { $cap_response = $this->velocityProcessor->authorizeAndCapture(array('amount' => $totals, 'avsdata' => $avsData, 'token' => $response['PaymentAccountDataToken'], 'order_id' => $orderId, 'entry_mode' => 'Keyed', 'IndustryType' => 'Ecommerce', 'Reference' => 'xyz', 'EmployeeId' => '11')); Mage::log(print_r($cap_response, 1)); if (is_array($cap_response) && !empty($cap_response) && isset($cap_response['Status']) && $cap_response['Status'] == 'Successful') { $payment->setTransactionId($cap_response['TransactionId']); $payment->setIsTransactionClosed(1); $xml = VelocityXmlCreator::authorizeandcaptureXML(array('amount' => $totals, 'avsdata' => $avsData, 'token' => $response['PaymentAccountDataToken'], 'order_id' => $orderId, 'entry_mode' => 'Keyed', 'IndustryType' => 'Ecommerce', 'Reference' => 'xyz', 'EmployeeId' => '11')); $req = $xml->saveXML(); $obj_req = serialize($req); $insertData = array('transaction_id' => $cap_response['TransactionId'], 'transaction_status' => $cap_response['Status'], 'order_id' => $orderId, 'request_obj' => $obj_req, 'response_obj' => serialize($cap_response)); $collectionSet = Mage::getModel('creditcard/card'); $collectionSet->setData($insertData)->save(); } else { if (is_array($cap_response) && !empty($cap_response)) { $errorMsg = $this->_getHelper()->__($cap_response['StatusMessage']); } else { $errorMsg = $this->_getHelper()->__($cap_response); } } } catch (Exception $e) { Mage::throwException($e->getMessage()); } } else { if (isset($response['Status']) && $response['Status'] != 'Successful') { $errorMsg = $this->_getHelper()->__($response['StatusMessage']); } else { $errorMsg = $this->_getHelper()->__($response); } } } catch (Exception $e) { Mage::throwException($e->getMessage()); } if (isset($errorMsg) && !empty($errorMsg)) { Mage::throwException($errorMsg); } return $this; }
public function callApi(Varien_Object $payment, $amount, $type) { $order = $payment->getOrder(); $invoiceNumber = $order->getIncrementId(); if ($type != 'authorizeandcaptureAIM') { /** * This will build the profile for the customer */ $customerID = $order->getCustomerId(); $customerEmail = $order->getCustomerEmail(); if (!$customerID) { /** * This will build the guest customer ID since they do not exist in the database yet */ $this->_guest = 1; //$customerEmail = 'guest-'. $customerEmail = $order->getCustomerEmail(); $guestCheck = Mage::getModel('authorizenetcim/guests')->load($customerEmail, 'email'); if (!$guestCheck->getData()) { $guest = Mage::getModel('authorizenetcim/guests'); $guest->setEmail($customerEmail); $guest->save(); $customerID = $guest->getGuestId(); } else { $customerID = $guestCheck->getGuestId(); } } $billingInfo = $order->getBillingAddress(); $shippingInfo = $order->getShippingAddress(); $ccType = $payment->getCcType(); $ccNumber = $payment->getCcNumber(); $ccExpDate = $payment->getCcExpYear() . '-' . str_pad($payment->getCcExpMonth(), 2, '0', STR_PAD_LEFT); $ccCCV = $payment->getCcCid(); /** * Checks to see if there is a token for profile and payment already associated with the customer * If it is a guest, there will not be one * I believe this may be extra unncessary code */ $tokenProfileId = $payment->getTokenProfileId(); $tokenPaymentProfileId = $payment->getTokenPaymentProfileId(); $postData = Mage::app()->getRequest()->getPost('payment', array()); if (isset($postData['ccsave_id'])) { $ccSaveId = $postData['ccsave_id']; } if ($customerID == $order->getIncrementId()) { /** * Can combine it with the below code to make * it an || statement instead of having the extra * lines of code */ $profileData = Mage::getModel('authorizenetcim/authorizenetcim')->load($customerID, 'customer_id')->getData(); $tokenProfileId = $profileData['token_profile_id']; $tokenPaymentProfileId = $profileData['token_payment_profile_id']; } elseif (isset($ccSaveId)) { $profileData = Mage::getModel('authorizenetcim/authorizenetcim')->load($ccSaveId)->getData(); $tokenProfileId = $profileData['token_profile_id']; $tokenPaymentProfileId = $profileData['token_payment_profile_id']; } if ($tokenProfileId == 0 && $tokenPaymentProfileId == 0 && ($type == 'authorize' || $type == 'capture' || $type == 'authorizeandcapture')) { /** * If token doesn't exist and type is = authorize, capture or authorizeandcapture * then it will create the token for you through authorize.net * and save it to the database */ if (isset($ccSaveId)) { /** * Can most likely be removed since it was done above already * Ambiguous call to the database */ $profileData = Mage::getModel('authorizenetcim/authorizenetcim')->load($ccSaveId)->getData(); $tokenProfileId = $profileData['token_profile_id']; $tokenPaymentProfileId = $profileData['token_payment_profile_id']; } else { $profile = Mage::getModel('authorizenetcim/authorizenetcim'); $profileCollection = $profile->getCollection()->addFieldToFilter('customer_id', $customerID)->addFieldToFilter('store_id', Mage::app()->getStore()->getStoreId()); if (count($profileCollection) == 0) { /** * If customer doesn't already exist in our database, it will try * to create it through the authorize.net section. It will also create the first initial * payment profile id */ $responseXML = $this->createCustomerProfileRequest($customerID, $customerEmail, $billingInfo, $shippingInfo, $ccNumber, $ccExpDate, $ccCCV, $ccType, $this->_guest); $tokenProfileId = $responseXML->customerProfileId; $tokenPaymentProfileId = $responseXML->customerPaymentProfileIdList->numericString; } else { /** * If customer already exists, it will get the profileID and then create the new * customer payment profile ID */ $tokenProfileId = $profileCollection->getFirstItem()->getTokenProfileId(); /** * Before we create a new payment profile id, we need to check * and see if it already exists */ // gets the last 4 of the cc $ccLast4 = substr($ccNumber, -4, 4); $tokenCheck = Mage::getModel('authorizenetcim/authorizenetcim')->getCollection()->addFieldToFilter('token_profile_id', $tokenProfileId)->addFieldToFilter('cc_last4', $ccLast4)->addFieldToSelect('token_payment_profile_id')->addFieldToSelect('token_profile_id'); $token = $tokenCheck->getFirstItem()->getData(); if (empty($token)) { $tokenPaymentProfileId = $this->createCustomerPaymentProfileRequest($customerID, $tokenProfileId, $billingInfo, $ccNumber, $ccExpDate, $ccCCV, $ccType); } else { $tokenProfileId = $token['token_profile_id']; $tokenPaymentProfileId = $token['token_payment_profile_id']; } } } } } //call xml creation functions switch ($type) { case 'authorize': $response = $this->runAuthorize($payment, $customerID, $amount, (string) $tokenProfileId, (string) $tokenPaymentProfileId, $invoiceNumber, $ccCCV); break; case 'capture': $response = $this->runCapture($payment, $invoiceNumber, $amount, $tokenProfileId, $tokenPaymentProfileId); break; case 'authorizeandcapture': $response = $this->runAuthorizeAndCapture($payment, $amount, $tokenProfileId, $tokenPaymentProfileId, $invoiceNumber, $ccCCV); break; case 'void': $response = $this->runVoid($payment, $tokenProfileId, $tokenPaymentProfileId, $refundTransactionId); break; case 'refund': $response = $this->runRefund($payment, $invoiceNumber, $amount, $tokenProfileId, $tokenPaymentProfileId); break; case 'authorizeandcaptureAIM': $response = $this->createAuthorizeCaptureAIM($amount, $payment, $order); break; case 'captureAIM': $response = $this->captureAIM($tokenProfileId); break; case 'createauthorizeaim': $response = $this->createAuthorizeAim($amount, $payment, $order); break; case 'refundAIM': $response = $this->createRefundAIM($amount, $payment, $order); break; } return $response; }
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 _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; }
/** * Get the API SDK for the payment auth request. * @param Varien_Object $payment * @return Api\IBidirectionalApi */ protected function _getApi(Varien_Object $payment) { $config = $this->_helper->getConfigModel(); return $this->_coreHelper->getSdkApi($config->apiService, $config->apiOperation, [$this->_helper->getTenderTypeForCcType($payment->getCcType())], $this->_apiLogger); }
private function callApi(Varien_Object $payment, $amount, $type) { $storeId = 'Store Id' . ' ' . Mage::app()->getStore()->getId(); $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(); $currencyDesc = $order->getBaseCurrencyCode(); Stripe::setApiKey($this->getConfigData('api_username')); try { $createtoken = Stripe_Token::create(array("card" => array("number" => $payment->getCcNumber(), "exp_month" => $payment->getCcExpMonth(), "exp_year" => $payment->getCcExpYear(), "cvc" => $payment->getCcCid(), "name" => $billingaddress->getData('firstname') . ' ' . $billingaddress->getData('lastname'), "address_line1" => $billingaddress->getData('street'), "address_city" => $billingaddress->getData('city'), "address_state" => $billingaddress->getData('region'), "address_zip" => $billingaddress->getData('postcode'), "address_country" => $billingaddress->getData('country_id'), "customer" => Mage::getSingleton('customer/session')->getCustomerId()))); $createcharge = Stripe_Charge::create(array("amount" => $totals * 100, "currency" => $currencyDesc, "card" => $createtoken->id, "statement_descriptor" => "COLTORTI", "description" => sprintf('COL#%s, %s', $orderId, $order->getCustomerEmail()))); return array('status' => 1, 'transaction_id' => $createcharge->id, 'fraud' => rand(0, 1)); } catch (Exception $e) { $this->debugData($e->getMessage()); Mage::throwException(Mage::helper('paygate')->__($e->getMessage())); die; } }
private function newRegistrationInfo($customerId, $gwapOrder) { $response = $this->fetchCustomerRegistration($gwapOrder); //Captura instantanea if ($this->_rg) { $cc = new Varien_Object($this->_rg); //Lote } else { $cc = new Varien_Object(unserialize(Mage::helper('core')->decrypt($gwapOrder->getRegistrationCc()))); } if ($this->_resultCode != '90') { $gwapOrder->setRegistrationCc(null); $gwapOrder->save(); Mage::throwException('Payment code: ' . $response['PAYMENT.CODE'] . ' (' . $response['PROCESSING.REASON'] . ' - ' . $response['PROCESSING.RETURN'] . ')'); } //Cria registro na tabela oneclick $newRegistry = Mage::getModel('gwap/oneclick'); $newRegistry->setCustomerId($customerId); $newRegistry->setRegistrationId($response['IDENTIFICATION.UNIQUEID']); $newRegistry->setCcLast4(substr($cc->getCcNumber(), -4)); $newRegistry->setType($cc->getCcType()); $newRegistry->setCreatedAt(Mage::getModel('core/date')->date("Y-m-d H:i:s")); $newRegistry->save(); $log = Mage::getModel('allpago_mc/log'); $log->add($gwapOrder->getOrderId(), 'Payment', 'capture()', Allpago_Mc_Model_Mc::STATUS_REGISTRATION, 'Cliente registrado (oneclick)'); return $newRegistry->getRegistrationId(); }
/** * 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; }
/** * 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; }
public function litleCcTypeEnum(Varien_Object $payment) { $typeEnum = ''; if ($payment->getCcType() == 'AE') { $typeEnum = 'AX'; } elseif ($payment->getCcType() == 'JCB') { $typeEnum = 'JC'; } else { $typeEnum = $payment->getCcType(); } return $typeEnum; }
/** * 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; }
/** * 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; }
/** * Create new AccessCode * @param Varien_Object $billing * @param Varien_Object $infoInstance * @param string $method * @param null $request * @return Eway_Rapid31_Model_Response */ public function createAccessCode(Varien_Object $billing, Varien_Object $infoInstance, $method = 'AccessCodes', $request = null) { // Empty Varien_Object's data $tokenCustomerID = $request->get('TokenCustomerID'); $this->unsetData(); $customerParam = Mage::getModel('ewayrapid/field_customer'); $customerParam->setTokenCustomerID($tokenCustomerID)->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())->setComments('')->setFax($billing->getFax())->setUrl(''); $returnUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/saveToken?ccType=' . $infoInstance->getCcType() . '&expYear=' . $infoInstance->getCcExpYear(); if ($request->get('is_default') == 'on') { $returnUrl .= '&is_default=on'; } if ($infoInstance->getCcStartMonth()) { $returnUrl .= '&startMonth=' . $infoInstance->getCcStartMonth(); } if ($infoInstance->getCcStartYear()) { $returnUrl .= '&startYear=' . $infoInstance->getCcStartYear(); } if ($infoInstance->getCcIssueNumber()) { $returnUrl .= '&issueNumber=' . $infoInstance->getCcIssueNumber(); } // Binding address on url param $returnUrl .= '&street1=' . base64_encode($billing->getStreet1()) . '&street2=' . base64_encode($billing->getStreet2()); $tokenId = $request->get('token_id'); if (!empty($tokenId)) { // ID token customer will be defined to update $returnUrl = $returnUrl . '&token_id=' . $tokenId; } $this->setCustomer($customerParam); $this->setRedirectUrl($returnUrl); $this->setCancelUrl($returnUrl); $this->setMethod(!empty($tokenCustomerID) ? 'UpdateTokenCustomer' : 'CreateTokenCustomer'); $this->setCustomerIP($_SERVER["REMOTE_ADDR"]); $this->setDeviceID(''); $this->setTransactionType("Purchase"); $this->setCustomerReadOnly(true); // Create new access code //$formMethod = !empty($tokenCustomerID) ? 'PUT' : 'POST'; $response = $this->_doRapidAPI($method); return $response; }