Mage_PaypalUk_Model_Direct Class Reference

Inheritance diagram for Mage_PaypalUk_Model_Direct:

Mage_Payment_Model_Method_Cc Mage_Payment_Model_Method_Abstract Varien_Object

List of all members.

Public Member Functions

 canUseForCurrency ($currencyCode)
 OtherCcType ($type)
 assignData ($data)
 getApi ()
 authorize (Varien_Object $payment, $amount)
 capture (Varien_Object $payment, $amount)
 canVoid (Varien_Object $payment)
 void (Varien_Object $payment)
 refund (Varien_Object $payment, $amount)

Protected Attributes

 $_code = 'paypaluk_direct'
 $_formBlockType = 'paypaluk/direct_form'
 $_infoBlockType = 'paypaluk/direct_info'
 $_canSaveCc = false
 $_isGateway = true
 $_canAuthorize = true
 $_canCapture = true
 $_canCapturePartial = false
 $_canRefund = false
 $_canVoid = true
 $_canUseInternal = true
 $_canUseCheckout = true
 $_canUseForMultishipping = true
 $_allowCurrencyCode = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD')


Detailed Description

PayPalUk Direct Module

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 33 of file Direct.php.


Member Function Documentation

assignData ( data  ) 

overwrites the method of Mage_Payment_Model_Method_Cc Assign data to info model instance

Parameters:
mixed $data
Returns:
Mage_Payment_Model_Info

Reimplemented from Mage_Payment_Model_Method_Cc.

Definition at line 85 of file Direct.php.

00086     {
00087 
00088         if (!($data instanceof Varien_Object)) {
00089             $data = new Varien_Object($data);
00090         }
00091         parent::assignData($data);
00092         $info = $this->getInfoInstance();
00093 
00094         if ($data->getCcType()=='SS') {
00095             $info->setCcSsIssue($data->getCcSsIssue())
00096                 ->setCcSsStartMonth($data->getCcSsStartMonth())
00097                 ->setCcSsStartYear($data->getCcSsStartYear())
00098             ;
00099         }
00100         return $this;
00101     }

authorize ( Varien_Object payment,
amount 
)

Authorize

Parameters:
Varien_Object $orderPayment
Returns:
Mage_Payment_Model_Abstract

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 113 of file Direct.php.

00114     {
00115         $api = $this->getApi()
00116             ->setTrxtype(Mage_PaypalUk_Model_Api_Pro::TRXTYPE_AUTH_ONLY)
00117             ->setAmount($amount)
00118             ->setBillingAddress($payment->getOrder()->getBillingAddress())
00119             ->setShippingAddress($payment->getOrder()->getShippingAddress())
00120             ->setPayment($payment);
00121 
00122          if($api->callDoDirectPayment()!==false) {
00123                $payment
00124                 ->setStatus('APPROVED')
00125                 ->setPaymentStatus('AUTHORIZE')
00126                 ->setCcTransId($api->getTransactionId())
00127                 ->setCcAvsStatus($api->getAvsCode())
00128                 ->setCcCidStatus($api->getCvv2Match());
00129          }else{
00130             $e = $api->getError();
00131             Mage::throwException($e['message']?$e['message']:Mage::helper('paypalUk')->__('There has been an error processing your payment. Please try later or contact us for help.'));
00132          }
00133 
00134     }

canUseForCurrency ( currencyCode  ) 

Check method for processing with base currency

Parameters:
string $currencyCode
Returns:
boolean

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 61 of file Direct.php.

00062     {
00063         if (!in_array($currencyCode, $this->_allowCurrencyCode)) {
00064             return false;
00065         }
00066         return true;
00067     }

canVoid ( Varien_Object payment  ) 

Check void availability

Parameters:
Varien_Object $invoicePayment
Returns:
bool

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 168 of file Direct.php.

00169     {
00170         if ($payment->getCcTransId()) {
00171          $api = $this->getApi()
00172             ->setTransactionId($payment->getCcTransId())
00173             ->setPayment($payment);
00174          if ($api->canVoid()!==false) {
00175              $payment->setStatus(self::STATUS_VOID);
00176          } else {
00177              $e = $api->getError();
00178              $payment->setStatus(self::STATUS_ERROR);
00179              $payment->setStatusDescription($e['message']);
00180          }
00181         } else {
00182             $payment->setStatus(self::STATUS_ERROR);
00183             $payment->setStatusDescription(Mage::helper('paypalUk')->__('Invalid transaction id'));
00184         }
00185         return $this;
00186     }

capture ( Varien_Object payment,
amount 
)

Capture payment

Parameters:
Varien_Object $orderPayment
Returns:
Mage_Payment_Model_Abstract

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 136 of file Direct.php.

00137     {
00138        if ($payment->getCcTransId()) {
00139            $trxType=Mage_PaypalUk_Model_Api_Pro::TRXTYPE_DELAYED_CAPTURE;
00140         } else {
00141            //when there is no transaction id, we do sales trxtype
00142            $trxType=Mage_PaypalUk_Model_Api_Pro::TRXTYPE_SALE;
00143         }
00144 
00145         $api = $this->getApi()
00146             ->setTrxtype($trxType)
00147             ->setAmount($amount)
00148             ->setTransactionId($payment->getCcTransId())
00149             ->setBillingAddress($payment->getOrder()->getBillingAddress())
00150             ->setShippingAddress($payment->getOrder()->getShippingAddress())
00151             ->setPayment($payment);
00152 
00153          if ($api->callDoDirectPayment()!==false) {
00154                $payment
00155                 ->setStatus('APPROVED')
00156                 ->setPaymentStatus('CAPTURE')
00157                 ->setCcTransId($api->getTransactionId())
00158                 ->setCcAvsStatus($api->getAvsCode())
00159                 ->setCcCidStatus($api->getCvv2Match());
00160          } else {
00161             $e = $api->getError();
00162             Mage::throwException($e['message']?$e['message']:Mage::helper('paypalUk')->__('There has been an error processing your payment. Please try later or contact us for help.'));
00163          }
00164 
00165          return $this;
00166     }

getApi (  ) 

Get Paypal API Model

Returns:
Mage_PaypalUk_Model_Api_Pro

Definition at line 108 of file Direct.php.

00109     {
00110         return Mage::getSingleton('paypaluk/api_pro');
00111     }

OtherCcType ( type  ) 

overwrites the method of Mage_Payment_Model_Method_Cc for switch or solo card

Reimplemented from Mage_Payment_Model_Method_Cc.

Definition at line 73 of file Direct.php.

00074     {
00075         return (parent::OtherCcType($type) || $type=='SS');
00076     }

refund ( Varien_Object payment,
amount 
)

Refund money

Parameters:
Varien_Object $invoicePayment
Returns:
Mage_Payment_Model_Abstract

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 212 of file Direct.php.

00213     {
00214         $error = false;
00215         if (($payment->getRefundTransactionId() && $amount>0)) {
00216          $api = $this->getApi()
00217             ->setTransactionId($payment->getRefundTransactionId())
00218             ->setPayment($payment)
00219             ->setAmount($amount);
00220 
00221          if ($api->refund()!==false) {
00222              $payment->setCcTransId($api->getTransactionId());
00223              $payment->setStatus(self::STATUS_SUCCESS);
00224          } else {
00225              $e = $api->getError();
00226              $error = $e['message'];
00227          }
00228         } else {
00229             $error = Mage::helper('paypalUk')->__('Error in refunding the payment');
00230         }
00231         if ($error !== false) {
00232             Mage::throwException($error);
00233         }
00234         return $this;
00235     }

void ( Varien_Object payment  ) 

Void payment

Parameters:
Varien_Object $invoicePayment
Returns:
Mage_Payment_Model_Abstract

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 188 of file Direct.php.

00189     {
00190         $error = false;
00191         if ($payment->getVoidTransactionId()) {
00192              $api = $this->getApi()
00193                 ->setTransactionId($payment->getVoidTransactionId())
00194                 ->setPayment($payment);
00195 
00196              if ($api->void()!==false) {
00197                  $payment->setCcTransId($api->getTransactionId());
00198                  $payment->setStatus(self::STATUS_VOID);
00199              } else {
00200                  $e = $api->getError();
00201                  $error = $e['message'];
00202              }
00203         } else {
00204             $error = Mage::helper('paypalUk')->__('Invalid transaction id');
00205         }
00206         if ($error !== false) {
00207             Mage::throwException($error);
00208         }
00209         return $this;
00210     }


Member Data Documentation

$_allowCurrencyCode = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD') [protected]

Definition at line 53 of file Direct.php.

$_canAuthorize = true [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 44 of file Direct.php.

$_canCapture = true [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 45 of file Direct.php.

$_canCapturePartial = false [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 46 of file Direct.php.

$_canRefund = false [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 47 of file Direct.php.

$_canSaveCc = false [protected]

Reimplemented from Mage_Payment_Model_Method_Cc.

Definition at line 38 of file Direct.php.

$_canUseCheckout = true [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 50 of file Direct.php.

$_canUseForMultishipping = true [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 51 of file Direct.php.

$_canUseInternal = true [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 49 of file Direct.php.

$_canVoid = true [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 48 of file Direct.php.

$_code = 'paypaluk_direct' [protected]

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 35 of file Direct.php.

$_formBlockType = 'paypaluk/direct_form' [protected]

Reimplemented from Mage_Payment_Model_Method_Cc.

Definition at line 36 of file Direct.php.

$_infoBlockType = 'paypaluk/direct_info' [protected]

Reimplemented from Mage_Payment_Model_Method_Cc.

Definition at line 37 of file Direct.php.

$_isGateway = true [protected]

Availability options

Reimplemented from Mage_Payment_Model_Method_Abstract.

Definition at line 43 of file Direct.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:34 2009 for Magento by  doxygen 1.5.8