Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class IWD_Opc_Model_Api_Nvp extends Mage_Paypal_Model_Api_Nvp
- {
- /**
- * Return Paypal Api version
- *
- * @return string
- */
- public function getVersion()
- {
- return '94.0';
- }
- /**
- * SetExpressCheckout call
- * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout
- * TODO: put together style and giropay settings
- */
- public function callSetExpressCheckout()
- {
- $this->_prepareExpressCheckoutCallRequest($this->_setExpressCheckoutRequest);
- $request = $this->_exportToRequest($this->_setExpressCheckoutRequest);
- $this->_exportLineItems($request);
- // import/suppress shipping address, if any
- $options = $this->getShippingOptions();
- if ($this->getAddress()) {
- $request = $this->_importAddresses($request);
- $request['ADDROVERRIDE'] = 1;
- } elseif ($options && (count($options) <= 10)) { // doesn't support more than 10 shipping options
- $request['CALLBACK'] = $this->getShippingOptionsCallbackUrl();
- $request['CALLBACKTIMEOUT'] = 6; // max value
- $request['MAXAMT'] = $request['AMT'] + 999.00; // it is impossible to calculate max amount
- $this->_exportShippingOptions($request);
- }
- // @edelahorra
- $request['LANDINGPAGE'] = 'Billing';
- // add recurring profiles information
- $i = 0;
- foreach ($this->_recurringPaymentProfiles as $profile) {
- $request["L_BILLINGTYPE{$i}"] = 'RecurringPayments';
- $request["L_BILLINGAGREEMENTDESCRIPTION{$i}"] = $profile->getScheduleDescription();
- $i++;
- }
- $paypaltoken = Mage::helper('opc/paypal')->refreshAccessToken();
- if(isset($paypaltoken->access_token) && !empty($paypaltoken->access_token)) {
- $request["IDENTITYACCESSTOKEN"] = $paypaltoken->access_token;
- }
- $response = $this->call(self::SET_EXPRESS_CHECKOUT, $request);
- $this->_importFromResponse($this->_setExpressCheckoutResponse, $response);
- }
- /**
- * GetExpressCheckoutDetails call
- * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetExpressCheckoutDetails
- */
- function callGetExpressCheckoutDetails()
- {
- $this->_prepareExpressCheckoutCallRequest($this->_getExpressCheckoutDetailsRequest);
- $request = $this->_exportToRequest($this->_getExpressCheckoutDetailsRequest);
- $response = $this->call(self::GET_EXPRESS_CHECKOUT_DETAILS, $request);
- Mage::log("PayPal IPN POST data: ".print_r($response, true).".", null, "paypal_ipn.log");
- $this->_importFromResponse($this->_paymentInformationResponse, $response);
- $this->_exportAddressses($response);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement