Definition at line 33 of file Express.php.
_getExpressCheckoutDetails | ( | ) | [protected] |
Definition at line 251 of file Express.php.
00252 { 00253 $api = $this->getApi() 00254 ->setPayment($this->getPayment()) 00255 ->setTrxtype($this->getPaymentAction()); 00256 00257 if ($api->callGetExpressCheckoutDetails()===false) { 00258 //here need to take care where is the page should land 00259 Mage::throwException(Mage::helper('paypalUk')->__('There has been an error processing your payment. Please try later or contact us for help.')); 00260 } 00261 00262 $q = $this->getQuote(); 00263 $a = $api->getShippingAddress(); 00264 00265 $a->setCountryId( 00266 Mage::getModel('directory/country')->loadByCode($a->getCountry())->getId() 00267 ); 00268 $a->setRegionId( 00269 Mage::getModel('directory/region')->loadByCode($a->getRegion(), $a->getCountryId())->getId() 00270 ); 00271 00272 /* 00273 we want to set the billing information 00274 only if the customer checkout from shortcut(shopping cart) or 00275 if the customer checkout from mark(one page) and guest 00276 */ 00277 if ($this->getSession()->getExpressCheckoutMethod()=='shortcut' || 00278 ($this->getSession()->getExpressCheckoutMethod()!='shortcut' && $q->getCheckoutMethod()!=Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)){ 00279 $q->getBillingAddress() 00280 ->setFirstname($a->getFirstname()) 00281 ->setLastname($a->getLastname()) 00282 ->setEmail($a->getEmail()); 00283 } 00284 00285 $q->getShippingAddress() 00286 ->importCustomerAddress($a) 00287 ->setCollectShippingRates(true); 00288 00289 //$q->setCheckoutMethod('paypaluk_express'); 00290 00291 $q->getPayment() 00292 ->setMethod('paypaluk_express') 00293 ->setPaypalCorrelationId($api->getCorrelationId()) 00294 ->setPaypalPayerId($api->getPayerId()) 00295 ->setPaypalPayerStatus($api->getPayerStatus()) 00296 ->setAdditionalData($api->getPaypalPayerEmail()) 00297 ; 00298 00299 $q->collectTotals()->save(); 00300 }
authorize | ( | Varien_Object $ | payment, | |
$ | amount | |||
) |
Authorize
Varien_Object | $orderPayment |
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 332 of file Express.php.
00333 { 00334 $this->placeOrder($payment); 00335 return $this; 00336 }
canUseForCurrency | ( | $ | currencyCode | ) |
Check method for processing with base currency
string | $currencyCode |
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 63 of file Express.php.
00064 { 00065 if (!in_array($currencyCode, $this->_allowCurrencyCode)) { 00066 return false; 00067 } 00068 return true; 00069 }
canVoid | ( | Varien_Object $ | payment | ) |
Check void availability
Varien_Object | $invoicePayment |
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 373 of file Express.php.
00374 { 00375 if ($payment->getCcTransId()) { 00376 $api = $this->getApi() 00377 ->setTransactionId($payment->getCcTransId()) 00378 ->setPayment($payment); 00379 if ($api->canVoid()!==false) { 00380 $payment->setStatus(self::STATUS_VOID); 00381 } else { 00382 $e = $api->getError(); 00383 $payment->setStatus(self::STATUS_ERROR); 00384 $payment->setStatusDescription($e['message']); 00385 } 00386 } else { 00387 $payment->setStatus(self::STATUS_ERROR); 00388 $payment->setStatusDescription(Mage::helper('paypalUk')->__('Invalid transaction id')); 00389 } 00390 return $this; 00391 }
capture | ( | Varien_Object $ | payment, | |
$ | amount | |||
) |
Capture payment
Varien_Object | $orderPayment |
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 344 of file Express.php.
00345 { 00346 if ($payment->getCcTransId()) { 00347 $trxType=Mage_PaypalUk_Model_Api_Pro::TRXTYPE_DELAYED_CAPTURE; 00348 $api = $this->getApi() 00349 ->setTrxtype($trxType) 00350 ->setAmount($amount) 00351 ->setTransactionId($payment->getCcTransId()) 00352 ->setBillingAddress($payment->getOrder()->getBillingAddress()) 00353 ->setPayment($payment); 00354 00355 if ($api->callDoDirectPayment()!==false) { 00356 $payment 00357 ->setStatus('APPROVED') 00358 ->setPaymentStatus('CAPTURE') 00359 //->setCcTransId($api->getTransactionId()) 00360 ->setLastTransId($api->getTransactionId()) 00361 ->setCcAvsStatus($api->getAvsCode()) 00362 ->setCcCidStatus($api->getCvv2Match()); 00363 } else { 00364 $e = $api->getError(); 00365 Mage::throwException($e['message']?$e['message']:Mage::helper('paypalUk')->__('Error in capture payment')); 00366 } 00367 } else { 00368 $this->placeOrder($payment); 00369 } 00370 return $this; 00371 }
catchError | ( | ) |
Definition at line 188 of file Express.php.
00189 { 00190 if ($this->getApi()->hasError() || !$this->getRedirectUrl()) { 00191 $s = $this->getCheckout(); 00192 $e = $this->getApi()->getError(); 00193 $s->addError(Mage::helper('paypalUk')->__('There was an error connecting to the Paypal server: %s', $e['message'])); 00194 $this->getApi()->setRedirectUrl(Mage::getUrl('checkout/cart')); 00195 } 00196 return $this; 00197 }
createFormBlock | ( | $ | name | ) |
Definition at line 154 of file Express.php.
00155 { 00156 $block = $this->getLayout()->createBlock('paypaluk/express_form', $name) 00157 ->setMethod('paypaluk_express') 00158 ->setPayment($this->getPayment()) 00159 ->setTemplate('paypaluk/express/form.phtml'); 00160 00161 return $block; 00162 }
getApi | ( | ) |
Get Paypal API Model
Definition at line 76 of file Express.php.
00077 { 00078 return Mage::getSingleton('paypalUk/api_pro'); 00079 }
getCheckout | ( | ) |
Get checkout session namespace
Definition at line 106 of file Express.php.
00107 { 00108 return Mage::getSingleton('checkout/session'); 00109 }
getOrderPlaceRedirectUrl | ( | ) |
getPaymentAction | ( | $ | paymentAction = null |
) |
Getting paypal action url
Definition at line 126 of file Express.php.
00127 { 00128 if (is_null($paymentAction)) { 00129 $paymentAction = $this->getConfigData('payment_action'); 00130 } 00131 if (!$paymentAction) { 00132 $paymentAction = Mage_PaypalUk_Model_Api_Pro::TRXTYPE_AUTH_ONLY; 00133 } else { 00134 if ($paymentAction==Mage_PaypalUk_Model_Api_Abstract::PAYMENT_TYPE_AUTH) { 00135 $paymentAction = Mage_PaypalUk_Model_Api_Pro::TRXTYPE_AUTH_ONLY; 00136 } else { 00137 $paymentAction = Mage_PaypalUk_Model_Api_Pro::TRXTYPE_SALE; 00138 } 00139 } 00140 return $paymentAction; 00141 }
getQuote | ( | ) |
Get current quote
Definition at line 116 of file Express.php.
00117 { 00118 return $this->getCheckout()->getQuote(); 00119 }
getRedirectUrl | ( | ) |
Retrieve redirect url
Definition at line 86 of file Express.php.
00087 { 00088 return $this->getApi()->getRedirectUrl(); 00089 }
getSession | ( | ) |
Get paypal session namespace
Definition at line 96 of file Express.php.
00097 { 00098 return Mage::getSingleton('paypaluk/session'); 00099 }
initialize | ( | $ | paymentAction, | |
$ | stateObject | |||
) |
initialize payment transaction in case we doing checkout through onepage checkout
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 446 of file Express.php.
00447 { 00448 if ($this->getQuote()->isVirtual()) { 00449 $address = $this->getQuote()->getBillingAddress(); 00450 } else { 00451 $address = $this->getQuote()->getShippingAddress(); 00452 } 00453 00454 $this->getApi() 00455 ->setPayment($this->getPayment()) 00456 ->setTrxtype($this->getPaymentAction($paymentAction)) 00457 ->setAmount($address->getBaseGrandTotal()) 00458 ->setCurrencyCode($this->getQuote()->getBaseCurrencyCode()) 00459 ->setShippingAddress($address) 00460 ->setInvNum($this->getQuote()->getReservedOrderId()) 00461 ->callSetExpressCheckout(); 00462 00463 $this->throwError(); 00464 00465 $stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT); 00466 $stateObject->setStatus('pending_paypal'); 00467 $stateObject->setIsNotified(false); 00468 00469 Mage::getSingleton('paypal/session')->unsExpressCheckoutMethod(); 00470 00471 return $this; 00472 }
isInitializeNeeded | ( | ) |
Rewrite standard logic
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 479 of file Express.php.
00480 { 00481 return is_object(Mage::registry('_singleton/checkout/type_onepage')); 00482 }
placeOrder | ( | Varien_Object $ | payment | ) |
Definition at line 302 of file Express.php.
00303 { 00304 $api = $this->getApi() 00305 ->setPayment($payment) 00306 ->setAmount($payment->getOrder()->getBaseGrandTotal()) 00307 ->setTrxtype($this->getPaymentAction()) 00308 ->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode()); 00309 00310 if ($api->callDoExpressCheckoutPayment()!==false) { 00311 $payment->setStatus('APPROVED') 00312 ->setPayerId($api->getPayerId()); 00313 if ($this->getPaymentAction()==Mage_PaypalUk_Model_Api_Pro::TRXTYPE_AUTH_ONLY) { 00314 $payment->setCcTransId($api->getTransactionId()); 00315 } else { 00316 $payment->setLastTransId($api->getTransactionId()); 00317 } 00318 } else { 00319 $e = $api->getError(); 00320 die($e['message']); 00321 } 00322 return $this; 00323 }
refund | ( | Varien_Object $ | payment, | |
$ | amount | |||
) |
Refund money
Varien_Object | $invoicePayment |
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 417 of file Express.php.
00418 { 00419 $error = false; 00420 if (($payment->getRefundTransactionId() && $amount>0)) { 00421 $api = $this->getApi() 00422 ->setTransactionId($payment->getRefundTransactionId()) 00423 ->setPayment($payment) 00424 ->setAmount($amount); 00425 if ($api->refund()!==false) { 00426 $payment->setCcTransId($api->getTransactionId()); 00427 $payment->setStatus(self::STATUS_SUCCESS); 00428 } else { 00429 $e = $api->getError(); 00430 $error = $e['message']; 00431 } 00432 00433 } else { 00434 $error = Mage::helper('paypalUk')->__('Error in refunding the payment'); 00435 } 00436 if ($error !== false) { 00437 Mage::throwException($error); 00438 } 00439 return $this; 00440 }
returnFromPaypal | ( | ) |
Making API call to check transaction's status when customer returns from paypal
Definition at line 221 of file Express.php.
00222 { 00223 $error=''; 00224 try { 00225 $this->_getExpressCheckoutDetails(); 00226 } catch (Exception $e) { 00227 $error=$e->getMessage(); 00228 $this->getSession()->addError($e->getMessage()); 00229 $this->_redirect('paypaluk/express/review'); 00230 } 00231 00232 switch ($this->getApi()->getUserAction()) { 00233 case Mage_Paypal_Model_Api_Nvp::USER_ACTION_CONTINUE: 00234 $this->getApi()->setRedirectUrl(Mage::getUrl('paypaluk/express/review')); 00235 break; 00236 case Mage_Paypal_Model_Api_Nvp::USER_ACTION_COMMIT: 00237 if ($this->getSession()->getExpressCheckoutMethod() == 'shortcut') { 00238 $this->getApi()->setRedirectUrl(Mage::getUrl('paypaluk/express/saveOrder')); 00239 } else { 00240 $this->getApi()->setRedirectUrl(Mage::getUrl('paypaluk/express/updateOrder')); 00241 } 00242 00243 break; 00244 } 00245 return $this; 00246 }
shortcutSetExpressCheckout | ( | ) |
Definition at line 168 of file Express.php.
00169 { 00170 $this->getQuote()->reserveOrderId(); 00171 $this->getApi() 00172 ->setPayment($this->getPayment()) 00173 ->setTrxtype($this->getPaymentAction()) 00174 ->setAmount($this->getQuote()->getBaseGrandTotal()) 00175 ->setCurrencyCode($this->getQuote()->getBaseCurrencyCode()) 00176 ->callSetExpressCheckout(); 00177 00178 $this->catchError(); 00179 00180 $this->getSession()->setExpressCheckoutMethod('shortcut'); 00181 00182 return $this; 00183 }
throwError | ( | ) |
Works same as catchError method but instead of saving error message in session throws exception
Definition at line 205 of file Express.php.
00206 { 00207 if ($this->getApi()->hasError() || !$this->getRedirectUrl()) { 00208 $s = $this->getCheckout(); 00209 $e = $this->getApi()->getError(); 00210 Mage::throwException(Mage::helper('paypalUk')->__('There was an error connecting to the Paypal server: %s', $e['message'])); 00211 } 00212 return $this; 00213 }
void | ( | Varien_Object $ | payment | ) |
Void payment
Varien_Object | $invoicePayment |
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 393 of file Express.php.
00394 { 00395 $error = false; 00396 if ($payment->getVoidTransactionId()) { 00397 $api = $this->getApi() 00398 ->setTransactionId($payment->getVoidTransactionId()) 00399 ->setPayment($payment); 00400 00401 if ($api->void()!==false) { 00402 $payment->setCcTransId($api->getTransactionId()); 00403 $payment->setStatus(self::STATUS_VOID); 00404 } else { 00405 $e = $api->getError(); 00406 $error = $e['message']; 00407 } 00408 } else { 00409 $error = Mage::helper('paypalUk')->__('Invalid transaction id'); 00410 } 00411 if ($error !== false) { 00412 Mage::throwException($error); 00413 } 00414 return $this; 00415 }
$_allowCurrencyCode = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD') [protected] |
Definition at line 55 of file Express.php.
$_canAuthorize = true [protected] |
$_canCapture = true [protected] |
$_canCapturePartial = false [protected] |
$_canRefund = false [protected] |
$_canUseCheckout = true [protected] |
$_canUseForMultishipping = false [protected] |
$_canUseInternal = false [protected] |
$_canVoid = true [protected] |
$_code = 'paypaluk_express' [protected] |
$_formBlockType = 'paypaluk/express_form' [protected] |
$_infoBlockType = 'paypaluk/express_info' [protected] |
$_isGateway = false [protected] |
Availability options
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 42 of file Express.php.
$_isInitializeNeeded = true [protected] |