/**
  * Import payment info to payment
  *
  * @param Mage_Paypal_Model_Api_Nvp
  * @param Mage_Sales_Model_Order_Payment
  */
 protected function _importToPayment($api, $payment)
 {
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0)->setAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT, $api->getRedirectRequired());
     if ($api->getBillingAgreementId()) {
         $payment->setBillingAgreementData(array('billing_agreement_id' => $api->getBillingAgreementId(), 'method_code' => Mage_Paypal_Model_Config::METHOD_BILLING_AGREEMENT));
     }
     $this->_pro->importPaymentInfo($api, $payment);
 }
Beispiel #2
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;
 }
Beispiel #3
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;
 }
Beispiel #4
0
 /**
  * Import direct payment results to payment
  *
  * @param Mage_Paypal_Model_Api_Nvp
  * @param Mage_Sales_Model_Order_Payment
  */
 protected function _importResultToPayment($api, $payment)
 {
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
     $this->_pro->importPaymentInfo($api, $payment);
 }