Advertisement
Guest User

Untitled

a guest
May 26th, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. <?php
  2. class IWD_Opc_Model_Api_Nvp extends Mage_Paypal_Model_Api_Nvp
  3. {
  4.  
  5.  
  6.  
  7. /**
  8. * Return Paypal Api version
  9. *
  10. * @return string
  11. */
  12. public function getVersion()
  13. {
  14. return '94.0';
  15. }
  16.  
  17.  
  18. /**
  19. * SetExpressCheckout call
  20. * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout
  21. * TODO: put together style and giropay settings
  22. */
  23. public function callSetExpressCheckout()
  24. {
  25.  
  26. $this->_prepareExpressCheckoutCallRequest($this->_setExpressCheckoutRequest);
  27. $request = $this->_exportToRequest($this->_setExpressCheckoutRequest);
  28. $this->_exportLineItems($request);
  29.  
  30. // import/suppress shipping address, if any
  31. $options = $this->getShippingOptions();
  32. if ($this->getAddress()) {
  33. $request = $this->_importAddresses($request);
  34. $request['ADDROVERRIDE'] = 1;
  35. } elseif ($options && (count($options) <= 10)) { // doesn't support more than 10 shipping options
  36. $request['CALLBACK'] = $this->getShippingOptionsCallbackUrl();
  37. $request['CALLBACKTIMEOUT'] = 6; // max value
  38. $request['MAXAMT'] = $request['AMT'] + 999.00; // it is impossible to calculate max amount
  39. $this->_exportShippingOptions($request);
  40. }
  41. // @edelahorra
  42. $request['LANDINGPAGE'] = 'Billing';
  43.  
  44. // add recurring profiles information
  45. $i = 0;
  46. foreach ($this->_recurringPaymentProfiles as $profile) {
  47. $request["L_BILLINGTYPE{$i}"] = 'RecurringPayments';
  48. $request["L_BILLINGAGREEMENTDESCRIPTION{$i}"] = $profile->getScheduleDescription();
  49. $i++;
  50. }
  51.  
  52.  
  53.  
  54. $paypaltoken = Mage::helper('opc/paypal')->refreshAccessToken();
  55. if(isset($paypaltoken->access_token) && !empty($paypaltoken->access_token)) {
  56. $request["IDENTITYACCESSTOKEN"] = $paypaltoken->access_token;
  57. }
  58.  
  59.  
  60.  
  61.  
  62. $response = $this->call(self::SET_EXPRESS_CHECKOUT, $request);
  63. $this->_importFromResponse($this->_setExpressCheckoutResponse, $response);
  64. }
  65.  
  66.  
  67. /**
  68. * GetExpressCheckoutDetails call
  69. * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetExpressCheckoutDetails
  70. */
  71. function callGetExpressCheckoutDetails()
  72. {
  73. $this->_prepareExpressCheckoutCallRequest($this->_getExpressCheckoutDetailsRequest);
  74. $request = $this->_exportToRequest($this->_getExpressCheckoutDetailsRequest);
  75. $response = $this->call(self::GET_EXPRESS_CHECKOUT_DETAILS, $request);
  76.  
  77. Mage::log("PayPal IPN POST data: ".print_r($response, true).".", null, "paypal_ipn.log");
  78.  
  79. $this->_importFromResponse($this->_paymentInformationResponse, $response);
  80. $this->_exportAddressses($response);
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement