Definition at line 35 of file Pro.php.
_generateRequestId | ( | ) | [protected] |
callDoDirectPayment | ( | ) |
Definition at line 97 of file Pro.php.
00098 { 00099 $p = $this->getPayment(); 00100 $a = $this->getBillingAddress(); 00101 if ($this->getShippingAddress()) { 00102 $s = $this->getShippingAddress(); 00103 } else { 00104 $s = $a; 00105 } 00106 00107 $proArr = array( 00108 'TENDER' => self::TENDER_CC, 00109 'AMT' => $this->getAmount(), 00110 'BUTTONSOURCE' => $this->getButtonSourceDp(), 00111 ); 00112 00113 if($this->getTrxtype()==self::TRXTYPE_AUTH_ONLY || $this->getTrxtype()==self::TRXTYPE_SALE){ 00114 $proArr = array_merge(array( 00115 'ACCT' => $p->getCcNumber(), 00116 'EXPDATE' => sprintf('%02d',$p->getCcExpMonth()).substr($p->getCcExpYear(),-2,2), 00117 'CVV2' => $p->getCcCid(), 00118 'CURRENCY' => $this->getCurrencyCode(), 00119 'EMAIL' => $p->getOrder()->getCustomerEmail(), 00120 00121 'FIRSTNAME' => $a->getFirstname(), 00122 'LASTNAME' => $a->getLastname(), 00123 'STREET' => $a->getStreet(1), 00124 'CITY' => $a->getCity(), 00125 'STATE' => $a->getRegionCode(), 00126 'ZIP' => $a->getPostcode(), 00127 'COUNTRY' => $a->getCountry(), 00128 00129 'SHIPTOFIRSTNAME' => $s->getFirstname(), 00130 'SHIPTOLASTNAME' => $s->getLastname(), 00131 'SHIPTOSTREET' => $s->getStreet(1), 00132 'SHIPTOSTREET2' => $s->getStreet(2), 00133 'SHIPTOCITY' => $s->getCity(), 00134 'SHIPTOSTATE' => $s->getRegion(), 00135 'SHIPTOZIP' => $s->getPostcode(), 00136 'SHIPTOCOUNTRY' => $s->getCountry(), 00137 ), $proArr); 00138 00139 if($p->getCcSsIssue()){ 00140 $proArr = array_merge(array( 00141 'CARDISSUE' => $p->getCcSsIssue(), 00142 ), $proArr); 00143 } 00144 if($p->getCcSsStartYear() || $p->getCcSsStartMonth()){ 00145 $proArr = array_merge(array( 00146 'CARDSTART' => sprintf('%02d',$p->getCcSsStartMonth()).substr($p->getCcSsStartYear(),-2,2), 00147 ), $proArr); 00148 } 00149 00150 }else{ 00151 $proArr = array_merge(array( 00152 'ORIGID' => $this->getTransactionId(), 00153 ), $proArr); 00154 } 00155 00156 $result = $this->postRequest($proArr); 00157 00158 if ($result && $result->getResultCode()==self::RESPONSE_CODE_APPROVED) { 00159 $this->setTransactionId($result->getPnref()); 00160 $this->setAvsZip($result->getAvszip()); 00161 $this->setAvsCode($result->getAvszip()); 00162 $this->setCvv2Match($result->getCvv2match()); 00163 } else { 00164 $errorArr['code'] = $result->getResultCode(); 00165 $errorArr['message'] = $result->getRespmsg(); 00166 $this->setError($errorArr); 00167 return false; 00168 } 00169 00170 return $this; 00171 }
callDoExpressCheckoutPayment | ( | ) |
Definition at line 290 of file Pro.php.
00291 { 00292 /* Gather the information to make the final call to 00293 finalize the PayPal payment. The variable nvpstr 00294 holds the name value pairs 00295 */ 00296 00297 $proArr = array( 00298 'TENDER' => self::TENDER_PAYPAL, 00299 'ACTION' => self::ACIONT_DO_EXPRESS, 00300 'TOKEN' => $this->getToken(), 00301 'PAYERID' => $this->getPayerId(), 00302 'AMT' => $this->getAmount(), 00303 'CURRENCY' => $this->getCurrencyCode(), 00304 'BUTTONSOURCE' => $this->getButtonSourceEc(), 00305 ); 00306 00307 $result = $this->postRequest($proArr); 00308 00309 if ($result && $result->getResultCode()==self::RESPONSE_CODE_APPROVED) { 00310 $this->setTransactionId($result->getPnref()); 00311 } else { 00312 //$errorArr['code'] = $result->getResultCode(); 00313 //$errorArr['message'] = $result->getRespmsg(); 00314 //$this->setError($errorArr); 00315 return false; 00316 } 00317 00318 return $this; 00319 }
callGetExpressCheckoutDetails | ( | ) |
Definition at line 239 of file Pro.php.
00240 { 00241 $proArr = array( 00242 'TENDER' => self::TENDER_PAYPAL, 00243 'ACTION' => self::ACIONT_GET_EXPRESS, 00244 'TOKEN' => $this->getToken(), 00245 ); 00246 00247 $result = $this->postRequest($proArr); 00248 00249 if ($result && $result->getResultCode()==self::RESPONSE_CODE_APPROVED) { 00250 $this->setPayerId($result->getPayerid()); 00251 $this->setCorrelationId($result->getCorrelationid()); 00252 $this->setPayerStatus($result->getPayerstatus()); 00253 $this->setPaypalPayerEmail($result->getEmail()); 00254 00255 //$this->setAddressId($result->getAddressId()); 00256 //$this->setAddressStatus($result->getAddressStatus()); 00257 00258 if (!$this->getShippingAddress()) { 00259 $this->setShippingAddress(Mage::getModel('customer/address')); 00260 } 00261 //print_r($result->getData()); 00262 $a = $this->getShippingAddress(); 00263 $a->setEmail($result->getEmail()); 00264 $a->setFirstname($result->getFirstname()); 00265 $a->setLastname($result->getLastname()); 00266 $street = array($result->getShiptostreet()); 00267 if ($result->getShiptostreet2()) { 00268 $street[] = $result->getShiptostreet2(); 00269 } 00270 $a->setStreet($street); 00271 $a->setCity($result->getShiptocity()); 00272 $a->setRegion($result->getShiptostate()); 00273 $a->setPostcode($result->getShiptozip()); 00274 $a->setCountry($result->getShiptocountry()); 00275 $a->setTelephone(Mage::helper('paypalUk')->__('N/A')); 00276 //echo "<hr>"; 00277 //print_r($a->getData()); 00278 //echo "<hr>"; 00279 //print_r($this->getData()); 00280 } else { 00281 $errorArr['code'] = $result->getResultCode(); 00282 $errorArr['message'] = $result->getRespmsg(); 00283 $this->setError($errorArr); 00284 return false; 00285 } 00286 00287 return $this; 00288 }
callSetExpressCheckout | ( | ) |
Definition at line 193 of file Pro.php.
00194 { 00195 $proArr = array( 00196 'TENDER' => self::TENDER_PAYPAL, 00197 'AMT' => $this->getAmount(), 00198 'ACTION' => self::ACIONT_SET_EXPRESS, 00199 'CURRENCY' => $this->getCurrencyCode(), 00200 "RETURNURL" => $this->getReturnUrl(), 00201 'CANCELURL' => $this->getCancelUrl(), 00202 ); 00203 00204 $this->setUserAction(self::USER_ACTION_CONTINUE); 00205 00206 // for mark SetExpressCheckout API call 00207 if ($a = $this->getShippingAddress()) { 00208 $proArr = array_merge($proArr, array( 00209 'ADDROVERRIDE' => 1, 00210 'SHIPTONAME' => $a->getName(), 00211 'SHIPTOSTREET' => $a->getStreet(1), 00212 'SHIPTOSTREET2' => $a->getStreet(2), 00213 'SHIPTOCITY' => $a->getCity(), 00214 'SHIPTOSTATE' => $a->getRegionCode(), 00215 'SHIPTOCOUNTRY' => $a->getCountry(), 00216 'SHIPTOZIP' => $a->getPostcode(), 00217 'PHONENUM' => $a->getTelephone(), 00218 )); 00219 $this->setUserAction(self::USER_ACTION_COMMIT); 00220 } 00221 00222 $result = $this->postRequest($proArr); 00223 00224 if ($result && $result->getResultCode()==self::RESPONSE_CODE_APPROVED) { 00225 $this->setToken($result->getToken()); 00226 $this->setRedirectUrl($this->getPaypalUrl()); 00227 } else if ($result) { 00228 $errorArr['code'] = $result->getResultCode(); 00229 $errorArr['message'] = $result->getRespmsg(); 00230 $this->setError($errorArr); 00231 return false; 00232 } else { 00233 return false; 00234 } 00235 00236 return $this; 00237 }
canVoid | ( | ) |
canVoid
public checking the transaction id is valid or not and transction id was not settled
Definition at line 471 of file Pro.php.
00472 { 00473 $payment = $this->getPayment(); 00474 00475 $proArr = array( 00476 'TENDER' => self::TENDER_CC, 00477 'ORIGID' => $this->getTransactionId(), 00478 ); 00479 00480 $this->getTrxtype(self::TRXTYPE_DELAYED_INQUIRY); 00481 $result = $this->postRequest($proArr); 00482 00483 if ($result && $result->getResultCode()==self::RESPONSE_CODE_APPROVED) { 00484 if ($result->getTransstate()>1000) { 00485 $errorArr['code'] = $result->getResultCode(); 00486 $errorArr['message'] = Mage::helper('paypalUk')->__('Voided transaction'); 00487 $this->setError($errorArr); 00488 return false; 00489 } elseif(in_array($result->getTransstate(),$this->_validVoidTransState)) { 00490 $this->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_VOID); 00491 return $this; 00492 } 00493 } 00494 00495 $errorArr['code'] = $result->getResultCode(); 00496 $errorArr['message'] = $result->getRespmsg() ? $result->getRespmsg() : Mage::helper('paypalUk')->__('Error in inquriing the transaction'); 00497 $this->setError($errorArr); 00498 return false; 00499 }
deformatNVP | ( | $ | nvpstr | ) |
Definition at line 330 of file Pro.php.
00331 { 00332 $intial=0; 00333 $nvpArray = array(); 00334 00335 $nvpstr = strpos($nvpstr, "\r\n\r\n")!==false ? substr($nvpstr, strpos($nvpstr, "\r\n\r\n")+4) : $nvpstr; 00336 00337 while(strlen($nvpstr)) { 00338 //postion of Key 00339 $keypos= strpos($nvpstr,'='); 00340 //position of value 00341 $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr); 00342 00343 /*getting the Key and Value values and storing in a Associative Array*/ 00344 $keyval=substr($nvpstr,$intial,$keypos); 00345 $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1); 00346 //decoding the respose 00347 $nvpArray[urldecode($keyval)] =urldecode( $valval); 00348 $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr)); 00349 } 00350 return $nvpArray; 00351 }
getPaypalUrl | ( | ) |
Definition at line 175 of file Pro.php.
00176 { 00177 if (!$this->hasPaypalUrl()) { 00178 $url=$this->getApiUrl(); 00179 if (stripos($url,'pilot') || stripos($url,'test')) { 00180 $default = 'https://www.sandbox.paypal.com/'; 00181 } else { 00182 $default = 'https://www.paypal.com/cgi-bin/'; 00183 } 00184 $default .= 'webscr?cmd=_express-checkout&useraction='.$this->getUserAction().'&token='; 00185 00186 $url = $this->getConfigData('paypal_url', $default); 00187 } else { 00188 $url = $this->getData('paypal_url'); 00189 } 00190 return $url . $this->getToken(); 00191 }
postRequest | ( | array $ | proArr | ) |
Definition at line 353 of file Pro.php.
00354 { 00355 $proArr = array_merge(array( 00356 'PARTNER' => $this->getPartner(), 00357 'USER' => $this->getApiUser(), 00358 'VENDOR' => $this->getApiVendor(), 00359 'PWD' => $this->getApiPassword(), 00360 'TRXTYPE' => $this->getTrxtype(), 00361 'REQUEST_ID'=> $this->_generateRequestId() 00362 ), $proArr); 00363 00364 $proReq = ''; 00365 $proReqDebug = ''; 00366 foreach ($proArr as $k=>$v) { 00367 //payflow gateway doesn't allow urlencoding. 00368 //$proReq .= '&'.$k.'='.urlencode($v); 00369 $proReq .= '&'.$k.'='.$v; 00370 $proReqDebug .= '&'.$k.'='; 00371 if (in_array($k, $this->_debugReplacePrivateDataKeys)) { 00372 $proReqDebug .= '***'; 00373 } else { 00374 $proReqDebug .= $v; 00375 } 00376 } 00377 $proReq = substr($proReq, 1); 00378 $proReqDebug = substr($proReqDebug, 1); 00379 00380 if ($this->getDebug()) { 00381 $debug = Mage::getModel('paypaluk/api_debug') 00382 ->setRequestBody($proReqDebug) 00383 ->save(); 00384 } 00385 $http = new Varien_Http_Adapter_Curl(); 00386 $config = array('timeout' => 30); 00387 $http->setConfig($config); 00388 $http->write(Zend_Http_Client::POST, $this->getApiUrl(), '1.1', array(), $proReq); 00389 $response = $http->read(); 00390 $response = preg_split('/^\r?$/m', $response, 2); 00391 $response = trim($response[1]); 00392 00393 if ($this->getDebug()) { 00394 $debug->setResponseBody($response)->save(); 00395 } 00396 00397 if ($http->getErrno()) { 00398 $http->close(); 00399 $this->setError(array( 00400 'type'=>'CURL', 00401 'code'=>$http->getErrno(), 00402 'message'=>$http->getError() 00403 )); 00404 $this->setRedirectUrl($this->getApiErrorUrl()); 00405 return false; 00406 } 00407 $http->close(); 00408 00409 $result = Mage::getModel('paypaluk/api_result'); 00410 $valArray = $this->deformatNVP($response); 00411 00412 foreach($valArray as $k=>$v) { 00413 $result->setData(strtolower($k), $v); 00414 } 00415 $result->setResultCode($result->getResult()) 00416 ->setRespmsg($result->getRespmsg()); 00417 00418 /* 00419 $client = new Varien_Http_Client(); 00420 $uri = $this->getApiUrl(); 00421 $client->setUri($uri) 00422 ->setConfig(array( 00423 'maxredirects'=>5, 00424 'timeout'=>30, 00425 )) 00426 ->setMethod(Zend_Http_Client::POST) 00427 ->setParameterPost($proArr) 00428 ->setHeaders('X-VPS-VIT-CLIENT-CERTIFICATION-ID: 33baf5893fc2123d8b191d2d011b7fdc') 00429 ->setHeaders('X-VPS-Request-ID: ' . $this->_generateRequestId()) 00430 ->setHeaders('X-VPS-CLIENT-TIMEOUT: ' . $this->_clientTimeout) 00431 ->setUrlEncodeBody(false); 00432 00433 $result = Mage::getModel('paypaluk/api_result'); 00434 00435 try { 00436 $response = $client->request(); 00437 $response = strstr($response->getBody(), 'RESULT'); 00438 $valArray = explode('&', $response); 00439 foreach($valArray as $val) { 00440 $valArray2 = explode('=', $val); 00441 $result->setData(strtolower($valArray2[0]), $valArray2[1]); 00442 } 00443 00444 $result->setResultCode($result->getResult()) 00445 ->setRespmsg($result->getRespmsg()); 00446 if ($this->getDebug()) { 00447 $debug->setResponseBody($response) 00448 ->save(); 00449 } 00450 00451 } catch (Exception $e) { 00452 $result->setResultCode(-1) 00453 ->setRespmsg($e->getMessage()); 00454 } 00455 */ 00456 00457 return $result; 00458 }
refund | ( | ) |
refund the amount with transaction id
public
Definition at line 533 of file Pro.php.
00534 { 00535 $payment = $this->getPayment(); 00536 00537 $proArr = array( 00538 'TENDER' => self::TENDER_CC, 00539 'ORIGID' => $this->getTransactionId(), 00540 'AMT' => $this->getAmount() 00541 ); 00542 $this->getTrxtype(self::TRXTYPE_CREDIT); 00543 $result = $this->postRequest($proArr); 00544 00545 if ($result && $result->getResultCode()==self::RESPONSE_CODE_APPROVED) { 00546 $this->setTransactionId($result->getPnref()); 00547 return $this; 00548 } 00549 00550 $errorArr['code'] = $result->getResultCode(); 00551 $errorArr['message'] = $result->getRespmsg() ? $result->getRespmsg() : Mage::helper('paypalUk')->__('Error in voiding the transaction'); 00552 $this->setError($errorArr); 00553 return false; 00554 }
void | ( | ) |
void
public
Definition at line 506 of file Pro.php.
00507 { 00508 $payment = $this->getPayment(); 00509 00510 $proArr = array( 00511 'TENDER' => self::TENDER_CC, 00512 'ORIGID' => $this->getTransactionId(), 00513 ); 00514 $this->getTrxtype(self::TRXTYPE_DELAYED_VOID); 00515 $result = $this->postRequest($proArr); 00516 00517 if ($result && $result->getResultCode()==self::RESPONSE_CODE_APPROVED) { 00518 $this->setTransactionId($result->getPnref()); 00519 return $this; 00520 } 00521 $errorArr['code'] = $result->getResultCode(); 00522 $errorArr['message'] = $result->getRespmsg() ? $result->getRespmsg() : Mage::helper('paypalUk')->__('Error in voiding the transaction'); 00523 $this->setError($errorArr); 00524 return false; 00525 }
$_debugReplacePrivateDataKeys [protected] |
const ACIONT_DO_EXPRESS = 'D' |
const ACIONT_GET_EXPRESS = 'G' |
const ACIONT_SET_EXPRESS = 'S' |
const RESPONSE_CODE_APPROVED = 0 |
const RESPONSE_CODE_CAPTURE_ERROR = 111 |
const RESPONSE_CODE_DECLINED = 12 |
const RESPONSE_DELIM_CHAR = ',' |
const TENDER_AUTOMATED = 'A' |
const TENDER_ECHEK = 'E' |
const TENDER_PAYPAL = 'P' |
const TENDER_PINLESS_DEBIT = 'D' |
const TENDER_TELECHECK = 'K' |
const TRXTYPE_AUTH_ONLY = 'A' |
const TRXTYPE_CREDIT = 'C' |
const TRXTYPE_DELAYED_CAPTURE = 'D' |
const TRXTYPE_DELAYED_INQUIRY = 'I' |
const TRXTYPE_DELAYED_VOICE = 'F' |
const TRXTYPE_DELAYED_VOID = 'V' |
const TRXTYPE_SALE = 'S' |