/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Method_Purchaseorder */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $this->getInfoInstance()->setPoNumber($data->getPoNumber()); return $this; }
public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $info->setPoNumber($data->getPoNumber())->setPoAmount($data->getPoAmount())->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; }
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 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; }
/** * Prepare request to gateway * * @link http://www.authorize.net/support/AIM_guide.pdf * @param Mage_Payment_Model_Info $payment * @return Mage_Paygate_Model_Authorizenet_Request */ protected function _buildRequest(Varien_Object $payment) { $order = $payment->getOrder(); $this->setStore($order->getStoreId()); $request = $this->_getRequest()->setXType($payment->getAnetTransType())->setXMethod(self::REQUEST_METHOD_CC); if ($order && $order->getIncrementId()) { $request->setXInvoiceNum($order->getIncrementId()); } if ($payment->getAmount()) { $request->setXAmount($payment->getAmount(), 2); $request->setXCurrencyCode($order->getBaseCurrencyCode()); } switch ($payment->getAnetTransType()) { case self::REQUEST_TYPE_AUTH_CAPTURE: $request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False'); if ($payment->getAdditionalInformation($this->_splitTenderIdKey)) { $request->setXSplitTenderId($payment->getAdditionalInformation($this->_splitTenderIdKey)); } break; case self::REQUEST_TYPE_AUTH_ONLY: $request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False'); if ($payment->getAdditionalInformation($this->_splitTenderIdKey)) { $request->setXSplitTenderId($payment->getAdditionalInformation($this->_splitTenderIdKey)); } break; case self::REQUEST_TYPE_CREDIT: /** * Send last 4 digits of credit card number to authorize.net * otherwise it will give an error */ $request->setXCardNum($payment->getCcLast4()); $request->setXTransId($payment->getXTransId()); break; case self::REQUEST_TYPE_VOID: $request->setXTransId($payment->getXTransId()); break; case self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE: $request->setXTransId($payment->getXTransId()); break; case self::REQUEST_TYPE_CAPTURE_ONLY: $request->setXAuthCode($payment->getCcAuthCode()); break; } if ($this->getIsCentinelValidationEnabled()) { $params = $this->getCentinelValidator()->exportCmpiData(array()); $request = Varien_Object_Mapper::accumulateByMap($params, $request, $this->_centinelFieldMap); } if (!empty($order)) { $billing = $order->getBillingAddress(); if (!empty($billing)) { $request->setXFirstName($billing->getFirstname())->setXLastName($billing->getLastname())->setXCompany($billing->getCompany())->setXAddress($billing->getStreet(1))->setXCity($billing->getCity())->setXState($billing->getRegion())->setXZip($billing->getPostcode())->setXCountry($billing->getCountry())->setXPhone($billing->getTelephone())->setXFax($billing->getFax())->setXCustId($order->getCustomerId())->setXCustomerIp($order->getRemoteIp())->setXCustomerTaxId($billing->getTaxId())->setXEmail($order->getCustomerEmail())->setXEmailCustomer($this->getConfigData('email_customer'))->setXMerchantEmail($this->getConfigData('merchant_email')); } $shipping = $order->getShippingAddress(); if (!empty($shipping)) { $request->setXShipToFirstName($shipping->getFirstname())->setXShipToLastName($shipping->getLastname())->setXShipToCompany($shipping->getCompany())->setXShipToAddress($shipping->getStreet(1))->setXShipToCity($shipping->getCity())->setXShipToState($shipping->getRegion())->setXShipToZip($shipping->getPostcode())->setXShipToCountry($shipping->getCountry()); } $request->setXPoNum($payment->getPoNumber())->setXTax($order->getBaseTaxAmount())->setXFreight($order->getBaseShippingAmount()); } if ($payment->getCcNumber()) { $request->setXCardNum($payment->getCcNumber())->setXExpDate(sprintf('%02d-%04d', $payment->getCcExpMonth(), $payment->getCcExpYear()))->setXCardCode($payment->getCcCid()); } return $request; }
/** * Prepare request to gateway * * @link http://www.authorize.net/support/AIM_guide.pdf * @param Mage_Sales_Model_Document $order * @return unknown */ protected function _buildRequest(Varien_Object $payment) { $order = $payment->getOrder(); $this->setStore($order->getStoreId()); if (!$payment->getAnetTransMethod()) { $payment->setAnetTransMethod(self::REQUEST_METHOD_CC); } $request = Mage::getModel('paygate/authorizenet_request')->setXVersion(3.1)->setXDelimData('True')->setXDelimChar(self::RESPONSE_DELIM_CHAR)->setXRelayResponse('False'); if ($order && $order->getIncrementId()) { $request->setXInvoiceNum($order->getIncrementId()); } $request->setXTestRequest($this->getConfigData('test') ? 'TRUE' : 'FALSE'); $request->setXLogin($this->getConfigData('login'))->setXTranKey($this->getConfigData('trans_key'))->setXType($payment->getAnetTransType())->setXMethod($payment->getAnetTransMethod()); if ($payment->getAmount()) { $request->setXAmount($payment->getAmount(), 2); $request->setXCurrencyCode($order->getBaseCurrencyCode()); } switch ($payment->getAnetTransType()) { case self::REQUEST_TYPE_CREDIT: case self::REQUEST_TYPE_VOID: case self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE: $request->setXTransId($payment->getCcTransId()); break; case self::REQUEST_TYPE_CAPTURE_ONLY: $request->setXAuthCode($payment->getCcAuthCode()); break; } if (!empty($order)) { $billing = $order->getBillingAddress(); if (!empty($billing)) { $request->setXFirstName($billing->getFirstname())->setXLastName($billing->getLastname())->setXCompany($billing->getCompany())->setXAddress($billing->getStreet(1))->setXCity($billing->getCity())->setXState($billing->getRegion())->setXZip($billing->getPostcode())->setXCountry($billing->getCountry())->setXPhone($billing->getTelephone())->setXFax($billing->getFax())->setXCustId($billing->getCustomerId())->setXCustomerIp($order->getRemoteIp())->setXCustomerTaxId($billing->getTaxId())->setXEmail($order->getCustomerEmail())->setXEmailCustomer($this->getConfigData('email_customer'))->setXMerchantEmail($this->getConfigData('merchant_email')); } $shipping = $order->getShippingAddress(); if (!empty($shipping)) { $request->setXShipToFirstName($shipping->getFirstname())->setXShipToLastName($shipping->getLastname())->setXShipToCompany($shipping->getCompany())->setXShipToAddress($shipping->getStreet(1))->setXShipToCity($shipping->getCity())->setXShipToState($shipping->getRegion())->setXShipToZip($shipping->getPostcode())->setXShipToCountry($shipping->getCountry()); } $request->setXPoNum($payment->getPoNumber())->setXTax($order->getTaxAmount())->setXFreight($order->getShippingAmount()); } switch ($payment->getAnetTransMethod()) { case self::REQUEST_METHOD_CC: if ($payment->getCcNumber()) { $request->setXCardNum($payment->getCcNumber())->setXExpDate(sprintf('%02d-%04d', $payment->getCcExpMonth(), $payment->getCcExpYear()))->setXCardCode($payment->getCcCid()); } break; case self::REQUEST_METHOD_ECHECK: $request->setXBankAbaCode($payment->getEcheckRoutingNumber())->setXBankName($payment->getEcheckBankName())->setXBankAcctNum($payment->getEcheckAccountNumber())->setXBankAcctType($payment->getEcheckAccountType())->setXBankAcctName($payment->getEcheckAccountName())->setXEcheckType($payment->getEcheckType()); break; } return $request; }
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; }
protected function _call(Varien_Object $payment, $callby = '', $amountcalled) { if ($this->getDebug()) { $writer = new Zend_Log_Writer_Stream($this->getLogPath()); $logger = new Zend_Log($writer); $logger->info("paymentAction: " . $this->getPaymentAction()); $storeId = $payment->getOrder()->getStoreId(); $logger->info("Storeid: " . $storeId); } //print "<pre>"; print_r($payment); print "</pre>"; exit; $ExpirationDate = $payment->getCcExpYear() . '-' . str_pad($payment->getCcExpMonth(), 2, '0', STR_PAD_LEFT); $invoiceno = $payment->getOrder()->getIncrementId(); $CustomerEmail = $payment->getOrder()->getCustomerEmail(); $CustomerId20 = $payment->getOrder()->getCustomerId(); $storeId = $payment->getOrder()->getStoreId(); $billToWho = $payment->getOrder()->getBillingAddress(); $shipToWho = $payment->getOrder()->getShippingAddress(); $tax = $payment->getOrder()->getTaxAmount(); $cvv = $payment->getCcCid(); if ($this->getStrictCVV()) { if (!$cvv) { $cvv = "111"; } } $ccnum = $payment->getCcNumber(); $ponum = $payment->getPoNumber(); if ($ccnum == '') { $ccnum = "tkn-{$ponum}"; } if ($ponum == '') { $ponum = $ccnum; } $cim = $payment->getCcSsStartMonth(); if ($this->getDebug()) { $logger->info("CcNumber PoNumber: {$ccnum}, {$ponum} SaveCimCC: {$cim}\n"); } if ($amountcalled < 1) { $amountcalled = $this->getAmount(); } $url = $this->getGatewayUrl(); if (strpos($ccnum, 'tkn') !== FALSE) { $fields = preg_split('/-/', $ccnum); $CustomerProfileID = $fields[1]; $PaymentProfileID = $fields[2]; $fields2 = preg_split('/-/', $ponum); $Approval = $fields2[2]; $fullcarddata = true; } else { $fields = preg_split('/-/', $ponum); $CustomerProfileID = $fields[0]; $fullcarddata = true; if (isset($fields[1]) and $callby != 'authorize' and strpos($ccnum, '-') !== FALSE) { $PaymentProfileID = $fields[1]; } else { $PaymentProfileID = 0; } if (isset($fields[2])) { $Approval = $fields[2]; } else { $Approval = 0; } } $authtransID = $payment->getOrder()->getTransactionId(); if ($authtransID < 1) { $authtransID = $payment->getParentTransactionId(); } if ($authtransID < 1) { $authtransID = $payment->getCcTransId(); } $authtrans2 = preg_split('/-/', $authtransID); $authtransID = $authtrans2[0]; if ($this->getDebug()) { $logger->info("from database: {$CustomerProfileID}, {$PaymentProfileID}, {$authtransID}\n"); } /* If we have the Customer ID and Payment ID, we can just do the transaction */ if ($CustomerProfileID > 0 and $PaymentProfileID > 0) { $TxRqXML = $this->createTransXML($amountcalled, $tax, $CustomerProfileID, $PaymentProfileID, $callby, $invoiceno, $authtransID, $Approval, $storeId); $TxRqResponse = $this->processRequest($url, $TxRqXML); if (isset($shipToWho['lastname']) and $shipToWho['lastname'] > '') { $createCustomerShippingAddressXML = $this->createCustomerShippingAddressXML($CustomerProfileID, $shipToWho, $storeId); $response = $this->processRequest($url, $createCustomerShippingAddressXML); if ($this->getDebug()) { $logger->info("\n\n Shipping Address Response: {$response}\n\n"); } } } else { /* First try to create a Customer Profile */ $CustProfileXML = $this->createCustomerXML($ccnum, $CustomerEmail, $ExpirationDate, $CustomerId20, $billToWho, $cvv, $storeId); $response = $this->processRequest($url, $CustProfileXML); $resultErrorCode = $this->parseXML('<code>', '</code>', $response); /* Get Customer Profile ID */ $CustomerProfileID = (int) $this->parseXML('<customerProfileId>', '</customerProfileId>', $response); /* Get Payment Profile ID */ $PaymentProfileID = (int) $this->parseXML('<customerPaymentProfileIdList><numericString>', '</numericString></customerPaymentProfileIdList>', $response); $ExistingCustProfile = $CustomerProfileID; $resultText = $this->parseXML('<text>', '</text>', $response); $resultCode = $this->parseXML('<resultCode>', '</resultCode>', $response); if ($resultErrorCode == 'E00039') { if ($this->getDebug()) { $logger->info("\n\n ALREADY HAVE A CUST PROFILE \n\n"); } $split = preg_split('/ /', $resultText); $ExistingCustProfile = $split[5]; $CustomerProfileID = $ExistingCustProfile; $addPaymentProfileXML = $this->addPaymentProfileXML($ExistingCustProfile, $ccnum, $ExpirationDate, $billToWho, $cvv, $storeId); $response = $this->processRequest($url, $addPaymentProfileXML); $PaymentProfileID = (int) $this->parseXML('<customerPaymentProfileId>', '</customerPaymentProfileId>', $response); $resultErrorCode = $this->parseXML('<code>', '</code>', $response); if ($resultErrorCode == 'E00039') { // Using an existing card already if ($this->getDebug()) { $logger->info("\n\n ALREADY HAVE A PAYMENT PROFILE WITH THE CARD \n\n"); } //Get Correct PaymentProfileID $getCustXML = $this->getProfileXML($ExistingCustProfile, $storeId); $responseGET = $this->processRequest($url, $getCustXML); $PaymentProfileID = $this->parseMultiXML($responseGET, $ccnum); if ($fullcarddata) { $updatePaymentProfileXML = $this->updatePaymentProfileXML($ExistingCustProfile, $PaymentProfileID, $ccnum, $ExpirationDate, $billToWho, $cvv, $storeId); $response = $this->processRequest($url, $updatePaymentProfileXML); if ($this->getDebug()) { $logger->info("\n\n UPDATED PROFILE {$PaymentProfileID} \n\n"); } } if ($this->getDebug()) { $logger->info("\n\ngetCustXML: {$getCustXML} ...\n...\nresponseGET{$responseGET} \n\n"); } } if ($PaymentProfileID == '0') { // Using an existing card already if ($this->getDebug()) { $logger->info("\n\n PROFILE ERROR \n\n"); } //Get Correct PaymentProfileID $getCustXML = $this->getProfileXML($ExistingCustProfile, $storeId); $responseGET = $this->processRequest($url, $getCustXML); $PaymentProfileID = $this->parseMultiXML($responseGET, $ccnum); if ($this->getDebug()) { $logger->info("\n\ngetCustXML: {$getCustXML} ...\n...\nresponseGET{$responseGET} \n\n"); } } if ($this->getDebug()) { $logger->info("\nUSING {$CustomerProfileID} - {$PaymentProfileID}"); } } if (isset($shipToWho['lastname']) and $shipToWho['lastname'] > '') { $createCustomerShippingAddressXML = $this->createCustomerShippingAddressXML($ExistingCustProfile, $shipToWho, $storeId); $response = $this->processRequest($url, $createCustomerShippingAddressXML); if ($this->getDebug()) { $logger->info("\n\n Shipping Address Response: {$response}\n\n"); } } $TxRqXML = $this->createTransXML($amountcalled, $tax, $CustomerProfileID, $PaymentProfileID, $callby, $invoiceno, $authtransID, $Approval, $storeId); $TxRqResponse = $this->processRequest($url, $TxRqXML); } $resultText = $this->parseXML('<text>', '</text>', $TxRqResponse); $resultCode = $this->parseXML('<resultCode>', '</resultCode>', $TxRqResponse); $resultErrorCode = $this->parseXML('<code>', '</code>', $TxRqResponse); $transauthidar = $this->parseXML('<directResponse>', '</directResponse>', $TxRqResponse); $fieldsAU = preg_split('/,/', $transauthidar); $responsecode = $fieldsAU[0]; if (!$responsecode == "1") { $resultCode = "No"; } if (isset($fieldsAU[4])) { $approval = $fieldsAU[4]; } else { $approval = 0; } if (strlen($approval) < 6) { $approval = $Approval; } if (isset($fieldsAU[6])) { $transno = $fieldsAU[6]; } else { $transno = 0; } if ($this->getDebug()) { $logger->info("TransID = {$transno} \n"); } if ($this->getDebug()) { $logger->info("Approval Code = {$approval} \n"); } $paymentInfo = $this->getInfoInstance(); if ($CustomerProfileID > '0' and $PaymentProfileID > '0') { $token = "{$CustomerProfileID}-{$PaymentProfileID}-{$approval}"; $paymentInfo->setCybersourceToken($token); $paymentInfo->setPoNumber($token); $paymentInfo->getOrder()->setTransactionId(); if ($paymentInfo->getCcSsStartMonth() == "on") { $paymentInfo->setCcSsStartMonth('1'); } else { if ($paymentInfo->getCcSsStartMonth() != "1") { $paymentInfo->setCcSsStartMonth('0'); } } } $result['Status']['transno'] = $transno; $result['Status']['approval'] = $approval; $result['Status']['CustomerProfileID'] = $CustomerProfileID; $result['Status']['PaymentProfileID'] = $PaymentProfileID; $result['Status']['statusCode'] = $resultCode; $result['Status']['code'] = $resultErrorCode; $result['Status']['statusDescription'] = $resultText; if ($this->getDebug()) { $logger->info("STATUS CODE = {$resultErrorCode} - {$resultCode} - {$resultText}"); } return $result; }
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; }