Example #1
0
 public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $items = Mage::helper('iugu')->getItemsFromOrder($payment->getOrder());
     $payer = Mage::helper('iugu')->getPayerInfoFromOrder($payment->getOrder());
     $data = new Varien_Object();
     $data->setMethod(Inovarti_Iugu_Model_Api::PAYMENT_METHOD_BOLETO)->setEmail($order->getCustomerEmail())->setItems($items)->setPayer($payer)->setNotificationUrl(Mage::getUrl('iugu/notification'));
     // Discount
     if ($order->getBaseDiscountAmount()) {
         $data->setDiscountCents(Mage::helper('iugu')->formatAmount(abs($order->getBaseDiscountAmount())));
     }
     // Tax
     if ($order->getBaseTaxAmount()) {
         $data->setTaxCents($this->formatAmount($order->getBaseTaxAmount()));
     }
     $result = Mage::getSingleton('iugu/api')->charge($data);
     if ($result->getErrors()) {
         $messages = array();
         if (is_array($result->getErrors())) {
             foreach ($result->getErrors() as $field => $errors) {
                 foreach ($errors as $error) {
                     $messages[] = $field . ': ' . $error . '.';
                 }
             }
         } else {
             $messages[] = $result->getErrors();
         }
         Mage::throwException(implode("\n", $messages));
     }
     // iugu info
     $payment->setIuguInvoiceId($result->getInvoiceId())->setIuguUrl($result->getUrl())->setIuguPdf($result->getPdf());
     return $this;
 }
Example #2
0
 /**
  * Checks if partial capture
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return bool
  */
 public function determineIsPartial($payment, $amount)
 {
     $grandTotal = $payment->getOrder()->getGrandTotal();
     if ($grandTotal != $amount) {
         return true;
     } else {
         return false;
     }
 }
Example #3
0
 public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $customer = Mage::helper('pagarme')->getCustomerInfoFromOrder($payment->getOrder());
     $data = new Varien_Object();
     $data->setPaymentMethod(Inovarti_Pagarme_Model_Api::PAYMENT_METHOD_BOLETO)->setAmount(Mage::helper('pagarme')->formatAmount($amount))->setBoletoExpirationDate($this->_generateExpirationDate())->setCustomer($customer)->setPostbackUrl(Mage::getUrl('pagarme/transaction_boleto/postback'));
     $pagarme = Mage::getModel('pagarme/api');
     $transaction = $pagarme->charge($data);
     if ($transaction->getErrors()) {
         $messages = array();
         foreach ($transaction->getErrors() as $error) {
             $messages[] = $error->getMessage() . '.';
         }
         Mage::throwException(implode("\n", $messages));
     }
     // pagar.me info
     $payment->setPagarmeTransactionId($transaction->getId())->setPagarmeBoletoUrl($transaction->getBoletoUrl())->setPagarmeBoletoBarcode($transaction->getBoletoBarcode())->setPagarmeBoletoExpirationDate($transaction->getBoletoExpirationDate());
     return $this;
 }
 /**
  * Order ID getter
  * Attempts to get ID from set order payment object, if any, or from data by key 'order_id'
  * @return int|null
  */
 public function getOrderId()
 {
     $orderId = $this->_getData('order_id');
     if ($orderId) {
         return $orderId;
     }
     if ($this->_paymentObject) {
         return $this->_paymentObject->getOrder() ? $this->_paymentObject->getOrder()->getId() : $this->_paymentObject->getParentId();
     }
 }
Example #5
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Method_Agreement
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setBillingAgreementId($payment->getBillingAgreementId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)->setInvNum($order->getIncrementId());
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_pro->importPaymentInfo($api, $payment);
     $payment->setAdditionalInformation(CLS_Paypal_Model_Paypaluk_Api_Nvp::RESPONSE_MSG, $api->getResponseMsg())->setPreparedMessage(Mage::helper('cls_paypal')->__('Payflow PNREF: #%s.', $api->getTransactionId()))->setTransactionAdditionalInfo(Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId());
     $payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(0);
     return $this;
 }
Example #6
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return CLS_Paypal_Model_Paypal_Method_Orderstored_Agreement
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setReferenceId($payment->getBillingAgreementId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)->setInvNum($order->getIncrementId());
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_pro->importPaymentInfo($api, $payment);
     $api->callGetTransactionDetails();
     $this->_pro->importPaymentInfo($api, $payment);
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
     return $this;
 }
Example #7
0
 public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     try {
         $order = $payment->getOrder();
         $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_boleto/postback');
         /*$azpay->config_boleto['acquirer'] = $this->getConfigData('operator');
           $azpay->config_boleto['expire'] = $this->_generateExpirationDate();
           $azpay->config_boleto['nrDocument'] = substr($order->getRealOrderId(), 1);
           $azpay->config_boleto['amount'] = Mage::helper('azpay')->formatAmount($amount);
           $azpay->config_boleto['instructions'] = $this->getConfigData('instructions');*/
         $azpay->config_online_debit['acquirer'] = $this->getConfigData('operator');
         $billingAddress = $order->getBillingAddress();
         if ($order->getCustomerTaxvat()) {
             $azpay->config_billing['customerIdentity'] = $order->getCustomerTaxvat();
         } else {
             $azpay->config_billing['customerIdentity'] = $order->getRealOrderId();
         }
         $azpay->config_billing['name'] = $order->getCustomerName();
         $azpay->config_billing['address'] = $billingAddress->getStreet(1) . ',' . $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'] = Mage::helper('azpay')->splitTelephone($billingAddress->getTelephone());
         $azpay->config_billing['email'] = $order->getCustomerEmail();
         $azpay->config_options['urlReturn'] = Mage::getUrl('azpay/transaction_boleto/postback');
         // Execute
         $azpay->online_debit()->execute();
         $azpay->getXml();
         // usado para salvar o XML gerado no log
         // Log
         if ($this->getConfigData('log')) {
             Mage::log($azpay, null, "azpay_boleto.log");
         }
     } catch (AZPay_Error $e) {
         Mage::log($e->getMessage(), null, "azpay_boleto_error.log");
         $error = $azpay->responseError();
         return Mage::throwException("Ocorreu um problema com o seu pedido. Tente novamente ou entre em contato conosco informando este código: " . $error['status_message']);
     }
     // Response
     $gateway_response = $azpay->response();
     $paymentDetails['azpayboletourl'] = (string) $gateway_response->processor->Transfer->urlTransfer;
     $payment->setAdditionalData(serialize($paymentDetails));
     // azpay info
     $payment->setAzpayTransactionId($gateway_response->transactionId)->setAzpayBoletoUrl((string) $gateway_response->processor->Transfer->urlTransfer);
     return $this;
 }
 /**
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return 	array
  */
 protected function getVaultParams($payment)
 {
     $params = array();
     $params['card_number'] = $payment->getCcNumber();
     $params['card_expiry_month'] = $payment->getCcExpMonth() < 10 ? '0' . $payment->getCcExpMonth() : $payment->getCcExpMonth();
     $params['card_expiry_year'] = $payment->getCcExpYear();
     $params['cvc'] = $payment->getCcCid();
     $params['multi_use'] = 1;
     //Add card holder
     $billing = $payment->getOrder()->getBillingAddress();
     $defaultOwner = $billing->getFirstname() && $billing->getLastname() ? $billing->getFirstname() . ' ' . $billing->getLastname() : $billing->getEmail();
     $params['card_holder'] = $payment->getCcOwner() ? $payment->getCcOwner() : $defaultOwner;
     $this->_debug($params);
     return $params;
 }
Example #9
0
 /**
  * Set order instance for transaction depends on transaction behavior
  * If $order equals to true, method isn't loading new order instance.
  *
  * @param Mage_Sales_Model_Order|null|boolean $order
  * @return Mage_Sales_Model_Order_Payment_Transaction
  */
 public function setOrder($order = null)
 {
     if (null === $order || $order === true) {
         if (null !== $this->_paymentObject && $this->_paymentObject->getOrder()) {
             $this->_order = $this->_paymentObject->getOrder();
         } elseif ($this->getOrderId() && $order === null) {
             $this->_order = Mage::getModel('sales/order')->load($this->getOrderId());
         } else {
             $this->_order = false;
         }
     } elseif (!$this->getId() || $this->getOrderId() == $order->getId()) {
         $this->_order = $order;
     } else {
         Mage::throwException(Mage::helper('sales')->__('Set order for existing transactions not allowed'));
     }
     return $this;
 }
Example #10
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Method_Agreement
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $billingAgreement = Mage::getModel('sales/billing_agreement')->load($payment->getAdditionalInformation(Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::TRANSPORT_BILLING_AGREEMENT_ID));
     $api = $this->_pro->getApi()->setReferenceId($billingAgreement->getReferenceId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_pro->importPaymentInfo($api, $payment);
     $api->callGetTransactionDetails();
     $this->_pro->importPaymentInfo($api, $payment);
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
     if ($api->getBillingAgreementId()) {
         $order->addRelatedObject($billingAgreement);
         $billingAgreement->setIsObjectChanged(true);
         $billingAgreement->addOrderRelation($order);
     }
     return $this;
 }
Example #11
0
 /**
  * Build the request with necessary parameters for doAuthorisation() and doTransaction()
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param $amount
  * @return Eway_Rapid31_Model_Request_Direct
  */
 protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     // Empty Varien_Object's data
     $this->unsetData();
     $methodInstance = $payment->getMethodInstance();
     $infoInstance = $methodInstance->getInfoInstance();
     $order = $payment->getOrder();
     $billing = $order->getBillingAddress();
     $shipping = $order->getShippingAddress();
     $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
     if (Mage::helper('ewayrapid')->isBackendOrder()) {
         $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
     } else {
         $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
     }
     $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion());
     $this->setShippingMethod('Other');
     $paymentParam = Mage::getModel('ewayrapid/field_payment');
     $paymentParam->setTotalAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode());
     $this->setPayment($paymentParam);
     $customerParam = Mage::getModel('ewayrapid/field_customer');
     $customerParam->setTitle($billing->getPrefix())->setFirstName($billing->getFirstname())->setLastName($billing->getLastname())->setCompanyName($billing->getCompany())->setJobDescription('')->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('')->setComments('')->setFax($billing->getFax())->setUrl('');
     $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
     $cardDetails->setName($infoInstance->getCcOwner())->setNumber($infoInstance->getCcNumber())->setExpiryMonth($infoInstance->getCcExpMonth())->setExpiryYear($infoInstance->getCcExpYear())->setCVN($infoInstance->getCcCid());
     $customerParam->setCardDetails($cardDetails);
     $this->setCustomer($customerParam);
     $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
     $shippingParam->setFirstName($shipping->getFirstname())->setLastName($shipping->getLastname())->setStreet1($shipping->getStreet1())->setStreet2($shipping->getStreet2())->setCity($shipping->getCity())->setState($shipping->getRegion())->setPostalCode($shipping->getPostcode())->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))->setEmail($shipping->getEmail())->setPhone($shipping->getTelephone())->setFax($shipping->getFax());
     $this->setShippingAddress($shippingParam);
     if ($methodInstance->getConfigData('transfer_cart_items')) {
         $orderItems = $order->getAllVisibleItems();
         $lineItems = array();
         foreach ($orderItems as $orderItem) {
             /* @var Mage_Sales_Model_Order_Item $orderItem */
             $lineItem = Mage::getModel('ewayrapid/field_lineItem');
             $lineItem->setSKU($orderItem->getSku());
             $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
             $lineItem->setQuantity($orderItem->getQtyOrdered());
             $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
             $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
             $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
             $lineItems[] = $lineItem;
         }
         $this->setItems($lineItems);
     }
     return $this;
 }
Example #12
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Method_Agreement
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $billingAgreement = Mage::getModel('sales/billing_agreement')->load($payment->getAdditionalInformation(Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::TRANSPORT_BILLING_AGREEMENT_ID));
     $api = $this->_pro->getApi()->setReferenceId($billingAgreement->getReferenceId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'));
     // add line items
     if ($this->_pro->getConfig()->lineItemsEnabled) {
         list($items, $totals) = Mage::helper('paypal')->prepareLineItems($order);
         if (Mage::helper('paypal')->areCartLineItemsValid($items, $totals, $amount)) {
             $api->setLineItems($items)->setLineItemTotals($totals);
         }
     }
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_pro->importPaymentInfo($api, $payment);
     $api->callGetTransactionDetails();
     $this->_pro->importPaymentInfo($api, $payment);
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
     if ($api->getBillingAgreementId()) {
         $billingAgreement->addOrderRelation($order->getId());
     }
     return $this;
 }
Example #13
0
 /**
  * Prepares the invoice object to be sent to BitPay's API. This method sets
  * all the other info that we have to rely on other objects for.
  *
  * @param Bitpay\Invoice                  $invoice
  * @param  Mage_Sales_Model_Order_Payment $payment
  * @param  float                          $amount
  * @return Bitpay\Invoice
  */
 private function prepareInvoice($invoice, $payment, $amount)
 {
     if (false === isset($invoice) || true === empty($invoice) || false === isset($payment) || true === empty($payment) || false === isset($amount) || true === empty($amount)) {
         $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::prepareInvoice(): missing or invalid invoice, payment or amount parameter.');
         throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::prepareInvoice(): missing or invalid invoice, payment or amount parameter.');
     } else {
         $this->debugData('[INFO] In Bitpay_Core_Model_Method_Bitcoin::prepareInvoice(): entered function with good invoice, payment and amount parameters.');
     }
     $invoice->setOrderId($payment->getOrder()->getIncrementId());
     $invoice->setPosData(json_encode(array('id' => $payment->getOrder()->getIncrementId())));
     $invoice = $this->addCurrencyInfo($invoice, $payment->getOrder());
     $invoice = $this->addPriceInfo($invoice, $amount);
     $invoice = $this->addBuyerInfo($invoice, $payment->getOrder());
     return $invoice;
 }
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Express
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     // prepare api call
     $token = $payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
     $api = $this->_pro->getApi()->setToken($token)->setPayerId($payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))->setAmount($amount)->setPaymentAction($this->_pro->getConfig()->paymentAction)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setInvNum($order->getIncrementId())->setCurrencyCode($order->getBaseCurrencyCode())->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
     // call api and get details from it
     $api->callDoExpressCheckoutPayment();
     $this->_importToPayment($api, $payment);
     return $this;
 }
 /**
  *
  * Requests coming from admin are offline transactions. These don't need to be sent via the PinPayments gateway
  * as they've already been processed.  Simply record the transaction ID supplied by the admin.
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param $amount
  * @param $transactionId
  */
 protected function _placeOfflineTransaction($payment, $amount)
 {
     $payment->setAmount($amount);
     $payment->getOrder()->setCustomerNote("Creating offline PinPayments transaction");
     $transactionId = $payment->getAdditionalInformation('offline_transaction_id');
     $payment->setCcTransId($transactionId);
     $payment->setTransactionId($transactionId);
 }
Example #16
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Express
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     // prepare api call
     $token = $payment->getAdditionalInformation(Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
     $api = $this->_pro->getApi()->setToken($token)->setPayerId($payment->getAdditionalInformation(Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))->setAmount($amount)->setPaymentAction($this->_pro->getConfig()->paymentAction)->setNotifyUrl(Mage::getUrl('paypalmx/ipn/'))->setInvNum($order->getIncrementId() . "MGT" . date("YmdHis"))->setCurrencyCode($order->getBaseCurrencyCode())->setPaypalCart(Mage::getModel('paypalmx/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
     if ($order->getIsVirtual()) {
         $api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
     } else {
         $api->setAddress($order->getShippingAddress());
         $api->setBillingAddress($order->getBillingAddress());
     }
     // call api and get details from it
     $api->callDoExpressCheckoutPayment();
     $this->_importToPayment($api, $payment);
     return $this;
 }
Example #17
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Direct
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setPaymentAction($this->_pro->getConfig()->paymentAction)->setIpAddress(Mage::app()->getRequest()->getClientIp(false))->setAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode())->setInvNum($order->getIncrementId())->setEmail($order->getCustomerEmail())->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setCreditCardType($payment->getCcType())->setCreditCardNumber($payment->getCcNumber())->setCreditCardExpirationDate($this->_getFormattedCcExpirationDate($payment->getCcExpMonth(), $payment->getCcExpYear()))->setCreditCardCvv2($payment->getCcCid())->setMaestroSoloIssueNumber($payment->getCcSsIssue());
     if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) {
         $year = sprintf('%02d', substr($payment->getCcSsStartYear(), -2, 2));
         $api->setMaestroSoloIssueDate($this->_getFormattedCcExpirationDate($payment->getCcSsStartMonth(), $year));
     }
     if ($this->getIsCentinelValidationEnabled()) {
         $this->getCentinelValidator()->exportCmpiData($api);
     }
     // add shipping and billing addresses
     if ($order->getIsVirtual()) {
         $api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
     } else {
         $api->setAddress($order->getShippingAddress());
         $api->setBillingAddress($order->getBillingAddress());
     }
     // add line items
     $api->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
     // call api and import transaction and other payment information
     $api->callDoDirectPayment();
     $this->_importResultToPayment($api, $payment);
     try {
         $api->callGetTransactionDetails();
     } catch (Mage_Core_Exception $e) {
         // if we recieve errors, but DoDirectPayment response is Success, then set Pending status for transaction
         $payment->setIsTransactionPending(true);
     }
     $this->_importResultToPayment($api, $payment);
     return $this;
 }
Example #18
0
 /**
  * Set capture transaction ID and enable Void to invoice for informational purposes
  * @param Mage_Sales_Model_Order_Invoice $invoice
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Mage_Payment_Model_Method_Abstract
  */
 public function processInvoice($invoice, $payment)
 {
     if ($payment->getLastTransId()) {
         $invoice->setTransactionId($payment->getLastTransId());
         $invoice->setCanVoidFlag(true);
         if (Mage::helper('sales')->canSendNewInvoiceEmail($payment->getOrder()->getStoreId())) {
             $invoice->setEmailSent(true);
             $invoice->sendEmail();
         }
         return $this;
     }
     return false;
 }
Example #19
0
 /**
  * Prepares the invoice object to be sent to BitPay's API. This method sets
  * all the other info that we have to rely on other objects for.
  *
  * @param Bitpay\Invoice                  $invoice
  * @param  Mage_Sales_Model_Order_Payment $payment
  * @param  float                          $amount
  * @return Bitpay\Invoice
  */
 private function prepareInvoice($invoice, $payment, $amount)
 {
     if (false === isset($invoice) || true === empty($invoice) || false === isset($payment) || true === empty($payment) || false === isset($amount) || true === empty($amount)) {
         $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::prepareInvoice(): missing or invalid invoice, payment or amount parameter.');
         throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::prepareInvoice(): missing or invalid invoice, payment or amount parameter.');
     } else {
         $this->debugData('[INFO] In Bitpay_Core_Model_Method_Bitcoin::prepareInvoice(): entered function with good invoice, payment and amount parameters.');
     }
     $quote = Mage::getSingleton('checkout/session')->getQuote();
     if (Mage::getStoreConfig('payment/bitpay/fullscreen')) {
         $invoice->setOrderId($payment->getOrder()->getIncrementId());
         $invoice->setPosData(json_encode(array('orderId' => $payment->getOrder()->getIncrementId())));
     } else {
         $invoice->setOrderId($quote->getId());
         $invoice->setPosData(json_encode(array('quoteId' => $quote->getId())));
     }
     // Necessary? Passes order to addBuyerInfo and addCurrencyInfo, since order does not exist yet
     $convertQuote = Mage::getSingleton('sales/convert_quote');
     $order = $convertQuote->toOrder($quote);
     $invoice = $this->addCurrencyInfo($invoice, $order);
     $invoice = $this->addPriceInfo($invoice, $amount);
     $invoice = $this->addBuyerInfo($invoice, $order);
     return $invoice;
 }
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Express
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     // prepare api call
     $order = $payment->getOrder();
     $token = $payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
     $api = $this->_pro->getApi()->setToken($token)->setPayerId($payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))->setAmount($amount)->setPaymentAction($this->_pro->getConfig()->paymentAction)->setNotifyUrl(Mage::getUrl($this->_ipnAction))->setInvNum($order->getIncrementId())->setCurrencyCode($order->getBaseCurrencyCode());
     // add line items
     if ($this->_pro->getConfig()->lineItemsEnabled && Mage::helper('paypal')->doLineItemsMatchAmount($order, $amount)) {
         //For transfering line items order amount must be equal to cart total amount
         list($items, $totals) = Mage::helper('paypal')->prepareLineItems($order);
         $api->setLineItems($items)->setLineItemTotals($totals);
     }
     // call api and get details from it
     $api->callDoExpressCheckoutPayment();
     $this->_importToPayment($api, $payment);
     return $this;
 }
Example #21
0
 /**
  * Update payment status to complete
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  */
 protected function _updatePaymentStatusCompleted(Mage_Sales_Model_Order_Payment $payment)
 {
     $comment = $this->_helper()->__('The transaction completed successfully.');
     $payment->setTransactionId($this->_transactionId)->setPreparedMessage($comment)->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())->setIsTransactionApproved(true)->setIsTransactionClosed(true)->registerCaptureNotification($this->getOrder()->getTotalDue())->save();
     $this->getOrder()->save();
     // notify customer
     if ($invoice = $payment->getCreatedInvoice()) {
         $comment = $this->_helper()->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
         if (!$this->getOrder()->getEmailSent()) {
             $this->getOrder()->queueNewOrderEmail()->setIsCustomerNotified(true)->addStatusHistoryComment($comment)->save();
         } else {
             $this->getOrder()->sendOrderUpdateEmail(true, $comment)->addStatusHistoryComment($comment)->save();
         }
     }
 }
Example #22
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return CLS_Paypal_Model_Paypal_Stored_Orderstored_Direct
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     // Get Reference ID
     $paymentInfo = $this->getInfoInstance();
     $referenceId = $paymentInfo->getAdditionalInformation('orderstored_transaction_id');
     if (!$referenceId) {
         Mage::throwException(Mage::helper('cls_paypal')->__('Unable to get the stored card data'));
     }
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setReferenceId($referenceId)->setPaymentAction($this->getConfigData('payment_action'))->setIpAddress(Mage::app()->getRequest()->getClientIp(false))->setAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode())->setInvNum($order->getIncrementId())->setEmail($order->getCustomerEmail());
     // add line items
     $api->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_importResultToPayment($api, $payment);
     try {
         $api->callGetTransactionDetails();
     } catch (Mage_Core_Exception $e) {
         // if we recieve errors, but DoDirectPayment response is Success, then set Pending status for transaction
         $payment->setIsTransactionPending(true);
     }
     $this->_importResultToPayment($api, $payment);
     return $this;
 }
Example #23
0
 /**
  * @param Mage_Sales_Model_Order_Payment $payment
  */
 protected function init(Mage_Sales_Model_Order_Payment $payment)
 {
     $this->setOrder($payment->getOrder());
     $this->setPaymentMethod($payment->getMethodInstance());
 }
Example #24
0
 /**
  * sets the canRefund information depending on the last refund operation code
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  */
 public function setCanRefundToPayment(Mage_Sales_Model_Order_Payment $payment)
 {
     $refundOperationCode = $payment->getAdditionalInformation('lastRefundOperationCode');
     if (in_array(strtoupper(trim($refundOperationCode)), array(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL, Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL))) {
         /*
          * a further refund is possible if the transaction remains open, that means either the merchant
          * did not close the transaction or the refunded amount is less than the orders amount
          */
         $canRefund = $refundOperationCode == Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL;
         Mage::helper('ops/data')->log(sprintf("set canRefund to '%s' for payment of order '%s'", var_export($canRefund, true), $payment->getOrder()->getIncrementId()));
         $payment->setAdditionalInformation('canRefund', $canRefund)->save();
     }
 }
 /**
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  */
 protected function _preauthorizeCapture($payment, $amount)
 {
     $transactionId = $payment->getLastTransId();
     $gatewayParams = array('operation' => 'capture', 'amount' => $amount);
     $this->_debug($gatewayParams);
     /* @var $request Allopass_Hipay_Model_Api_Request */
     $request = Mage::getModel('hipay/api_request', array($this));
     $uri = Allopass_Hipay_Model_Api_Request::GATEWAY_ACTION_MAINTENANCE . $transactionId;
     $gatewayResponse = $request->gatewayRequest($uri, $gatewayParams, $payment->getOrder()->getStoreId());
     $this->_debug($gatewayResponse->debug());
     switch ($gatewayResponse->getStatus()) {
         case "116":
             $this->addTransaction($payment, $gatewayResponse->getTransactionReference(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, array('is_transaction_closed' => 0), array(), Mage::helper('hipay')->getTransactionMessage($payment, self::OPERATION_MAINTENANCE_ACCEPT_CHALLENGE, $gatewayResponse->getTransactionReference(), $amount));
             $payment->setIsTransactionPending(true);
             break;
         case "117":
             //Capture requested
         //Capture requested
         case "118":
             //Capture
         //Capture
         case "119":
             //Partially Capture
             $this->addTransaction($payment, $gatewayResponse->getTransactionReference(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, array('is_transaction_closed' => 0), array(), Mage::helper('hipay')->getTransactionMessage($payment, self::OPERATION_MAINTENANCE_CAPTURE, $gatewayResponse->getTransactionReference(), $amount));
             $payment->setIsTransactionPending(true);
             break;
         default:
             Mage::throwException($gatewayResponse->getStatus() . " ==> " . $gatewayResponse->getMessage() . " is not processed!");
             break;
     }
     return $this;
 }
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Direct
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setPaymentAction($this->_pro->getConfig()->paymentAction)->setIpAddress(Mage::app()->getRequest()->getClientIp(false))->setAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode())->setInvNum($order->getIncrementId())->setEmail($order->getCustomerEmail())->setNotifyUrl(Mage::getUrl($this->_notifyAction))->setCreditCardType($payment->getCcType())->setCreditCardNumber($payment->getCcNumber())->setCreditCardExpirationDate(sprintf('%02d%02d', $payment->getCcExpMonth(), $payment->getCcExpYear()))->setCreditCardCvv2($payment->getCcCid())->setMaestroSoloIssueNumber($payment->getCcSsIssue());
     if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) {
         $api->setMaestroSoloIssueDate(sprintf('%02d%02d', $payment->getCcSsStartMonth(), preg_replace('~\\d\\d(\\d\\d)~', '$1', $payment->getCcSsStartYear())));
     }
     if ($this->getIsCentinelValidationEnabled()) {
         $this->getCentinelValidator()->exportCmpiData($api);
     }
     // add shipping address
     if ($order->getIsVirtual()) {
         $api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
     } else {
         $api->setAddress($order->getShippingAddress());
     }
     // add line items
     if ($this->_pro->getConfig()->lineItemsEnabled && Mage::helper('paypal')->doLineItemsMatchAmount($order, $amount)) {
         //For transfering line items order amount must be equal to cart total amount
         list($items, $totals) = Mage::helper('paypal')->prepareLineItems($order);
         $api->setLineItems($items)->setLineItemTotals($totals);
     }
     // call api and import transaction and other payment information
     $api->callDoDirectPayment();
     $this->_importResultToPayment($api, $payment);
     return $this;
 }
Example #27
0
 /**
  * Import payment data to billing agreement
  *
  * $payment->getBillingAgreementData() contains array with following structure :
  *  [billing_agreement_id]  => string
  *  [method_code]           => string
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Mage_Sales_Model_Billing_Agreement
  */
 public function importOrderPayment(Mage_Sales_Model_Order_Payment $payment)
 {
     $baData = $payment->getBillingAgreementData();
     $this->_paymentMethodInstance = isset($baData['method_code']) ? Mage::helper('payment')->getMethodInstance($baData['method_code']) : $payment->getMethodInstance();
     if ($this->_paymentMethodInstance) {
         $this->_paymentMethodInstance->setStore($payment->getMethodInstance()->getStore());
         $this->setCustomerId($payment->getOrder()->getCustomerId())->setMethodCode($this->_paymentMethodInstance->getCode())->setReferenceId($baData['billing_agreement_id'])->setStatus(self::STATUS_ACTIVE);
     }
     return $this;
 }
Example #28
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Direct
  */
 protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     $api = $this->_pro->getApi()->setPaymentAction($this->_pro->getConfig()->paymentAction)->setIpAddress(Mage::app()->getRequest()->getClientIp(false))->setAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode())->setInvNum($order->getIncrementId())->setEmail($order->getCustomerEmail())->setNotifyUrl(Mage::getUrl('paypal/ipn/direct'))->setCreditCardType($payment->getCcType())->setCreditCardNumber($payment->getCcNumber())->setCreditCardExpirationDate(sprintf('%02d%02d', $payment->getCcExpMonth(), $payment->getCcExpYear()))->setCreditCardCvv2($payment->getCcCid());
     // add shipping address
     if ($order->getIsVirtual()) {
         $api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
     } else {
         $api->setAddress($order->getShippingAddress());
     }
     // add line items
     if ($this->_pro->getConfig()->lineItemsEnabled) {
         list($items, $totals) = Mage::helper('paypal')->prepareLineItems($order);
         $api->setLineItems($items)->setLineItemTotals($totals);
     }
     // call api and import transaction and other payment information
     $api->callDoDirectPayment();
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0)->setIsPaid($api->isPaid($api->getPaymentStatus()));
     Mage::getModel('paypal/info')->importToPayment($api, $payment);
     return $this;
 }
Example #29
0
 /**
  * Refund order
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return string Amazon Transaction Id
  */
 public function refund($payment, $amount)
 {
     $_document = '<?xml version="1.0" encoding="UTF-8"?>
         <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
         <Header>
             <DocumentVersion>1.01</DocumentVersion>
             <MerchantIdentifier>' . $this->getMerchantIdentifier() . '</MerchantIdentifier>
         </Header>
         <MessageType>OrderAdjustment</MessageType>';
     $_shippingAmount = $payment->getCreditmemo()->getShippingAmount();
     $_messageId = 1;
     foreach ($payment->getCreditmemo()->getAllItems() as $item) {
         /* @var $item Mage_Sales_Model_Order_Creditmemo_Item */
         if ($item->getOrderItem()->getParentItemId()) {
             continue;
         }
         $shipping = 0;
         $amazon_amounts = unserialize($item->getOrderItem()->getProductOptionByCode('amazon_amounts'));
         if ($amazon_amounts['shipping'] > $_shippingAmount) {
             $shipping = $_shippingAmount;
         } else {
             $shipping = $amazon_amounts['shipping'];
         }
         $_shippingAmount -= $shipping;
         $_document .= '<Message>
                         <MessageID>' . $_messageId . '</MessageID>
                         <OrderAdjustment>
                             <AmazonOrderID>' . $payment->getOrder()->getExtOrderId() . '</AmazonOrderID>
                             <AdjustedItem>
                                 <AmazonOrderItemCode>' . $item->getOrderItem()->getExtOrderItemId() . '</AmazonOrderItemCode>
                                 <AdjustmentReason>GeneralAdjustment</AdjustmentReason>
                                 <ItemPriceAdjustments>
                                     <Component>
                                         <Type>Principal</Type>
                                         <Amount currency="USD">' . $this->formatAmount($item->getBaseRowTotal()) . '</Amount>
                                     </Component>
                                     <Component>
                                         <Type>Tax</Type>
                                         <Amount currency="USD">' . $this->formatAmount($item->getBaseTaxAmount()) . '</Amount>
                                     </Component>' . '<Component>
                                         <Type>Shipping</Type>
                                         <Amount currency="USD">' . $this->formatAmount($shipping) . '</Amount>
                                     </Component>' . '</ItemPriceAdjustments>';
         $_document .= '</AdjustedItem>
                     </OrderAdjustment>
                 </Message>';
         $_messageId++;
     }
     $_document .= '</AmazonEnvelope>';
     $params = array('merchant' => $this->getMerchantInfo(), 'messageType' => self::MESSAGE_TYPE_ADJUSTMENT, 'doc' => $this->_createAttachment($_document));
     $this->_proccessRequest('postDocument', $params);
     return $this->_result;
 }
Example #30
0
 protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
 {
     // Empty Varien_Object's data
     $this->unsetData();
     // in case recurring profile, $methodInstance is not exist, and $payment->getIsRecurring() is used
     if (!$payment->getIsRecurring()) {
         $methodInstance = $payment->getMethodInstance();
         $infoInstance = $methodInstance->getInfoInstance();
         Mage::helper('ewayrapid')->unserializeInfoInstace($infoInstance);
     }
     $order = $payment->getOrder();
     $shipping = $order->getShippingAddress();
     $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
     if (Mage::helper('ewayrapid')->isBackendOrder()) {
         $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
     } elseif ($payment->getIsRecurring()) {
         $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_RECURRING);
     } else {
         $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
     }
     $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion());
     $this->setShippingMethod('Other');
     $paymentParam = Mage::getModel('ewayrapid/field_payment');
     $paymentParam->setTotalAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode());
     $this->setPayment($paymentParam);
     $customerParam = Mage::getModel('ewayrapid/field_customer');
     $customerTokenId = null;
     /** get $customerTokenId if product is recurring profile  */
     if ($payment->getIsRecurring()) {
         /** @todo save customer id and tokent id into payment when place order */
         $customer = Mage::getModel('customer/customer')->load($payment->getCustomerId());
         $customerHelper = Mage::helper('ewayrapid/customer');
         $customerHelper->setCurrentCustomer($customer);
         $customerTokenId = $customerHelper->getCustomerTokenId($payment->getTokenId());
     } else {
         /** get $customerTokenId if product is normal item */
         if ($infoInstance->getSavedToken()) {
             $customerHelper = Mage::helper('ewayrapid/customer');
             $customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken());
         } else {
             Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
         }
     }
     if ($customerTokenId) {
         $customerParam->setTokenCustomerID($customerTokenId);
         if ($this->getTransactionType() == Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE) {
             $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
             $cardDetails->setCVN($infoInstance->getCcCid());
             $customerParam->setCardDetails($cardDetails);
         }
         $this->setCustomer($customerParam);
     } else {
         Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
     }
     $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
     $shippingParam->setFirstName($shipping->getFirstname())->setLastName($shipping->getLastname())->setStreet1($shipping->getStreet1())->setStreet2($shipping->getStreet2())->setCity($shipping->getCity())->setState($shipping->getRegion())->setPostalCode($shipping->getPostcode())->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))->setEmail($shipping->getEmail())->setPhone($shipping->getTelephone())->setFax($shipping->getFax());
     $this->setShippingAddress($shippingParam);
     if (isset($methodInstance) && $methodInstance->getConfigData('transfer_cart_items') || $payment->getIsRecurring() || !$payment->getIsInitialFee()) {
         $orderItems = $order->getAllVisibleItems();
         $lineItems = array();
         foreach ($orderItems as $orderItem) {
             /* @var Mage_Sales_Model_Order_Item $orderItem */
             $lineItem = Mage::getModel('ewayrapid/field_lineItem');
             $lineItem->setSKU($orderItem->getSku());
             $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
             $lineItem->setQuantity($orderItem->getQtyOrdered());
             $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
             $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
             $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
             $lineItems[] = $lineItem;
         }
         $this->setItems($lineItems);
     }
     return $this;
 }