Development

Changeset 5748

You must first sign up to be able to contribute.

Changeset 5748

Show
Ignore:
Timestamp:
10/29/07 18:22:18 (1 year ago)
Author:
slickrick
Message:
  • Formatted spacing for sf code standards
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPaypalLitePlugin/lib/sfPaypalLitePlugin.class.php

    r5747 r5748  
    11<?php 
    22class sfPaypalLite 
    3 {   
    4  private $security_type = 'Certificate'; 
    5    
    6  private $api_certificate_path; 
    7    
    8  private $test_mode = false; 
    9    
    10  private $uri = null; 
    11    
    12  private $params = array(); 
    13    
    14  private $response = array(); 
    15    
    16  private $errors = array(); 
    17    
    18  public function __construct($security_type = 'Certificate', $test_mode = false) 
    19  {    
    20     $this->setApiMethod('DoDirectPayment');    
    21    $this->setApiVersion('2.3'); 
    22    $this->setApiPaymentAction('Sale'); 
    23    $this->setSecurityType($security_type); 
    24    $this->setIPAddress($_SERVER["REMOTE_ADDR"]); 
    25      
    26    if ($test_mode !== false) 
    27    
    28      $this->setTestMode(true); 
    29    
    30 
    31    
    32  public function setTestMode($mode = true) 
    33 
    34    $this->test_mode = (bool) $mode; 
    35 
    36    
    37  /** 
    38  * Determine if the api is in test mode 
    39 
    40  * @return boolean 
    41  */ 
    42  public function isTestMode() 
    43 
    44    return $this->test_mode; 
    45 
    46    
    47  /** 
    48  * Set the PayPal security type 
    49  * Valid options: Certificate, Signature 
    50  * NOTE: Signature based authentication requires a username and password 
    51 
    52  * @param unknown_type $value 
    53  */ 
    54  public function setSecurityType($value) 
    55 
    56    $this->security_type = $value; 
    57 
    58    
    59  public function getSecurityType() 
    60 
    61    return $this->security_type; 
    62 
    63    
    64  public function setApiCertificatePath($string) 
    65 
    66    $this->api_certificate_path = $string; 
    67 
    68      
    69  public function getApiCertificatePath() 
    70 
    71    return $this->api_certificate_path; 
    72 
    73    
    74  public function setApiSignature($value) 
    75 
    76    $this->addParam('SIGNATURE', $value); 
    77 
    78    
    79  public function setError($msg) 
    80 
    81    $this->errors[] = $msg; 
    82 
    83    
    84  public function getErrors() 
    85 
    86    return $this->errors; 
    87 
    88    
    89  public function hasErrors() 
    90 
    91    return (count($this->getErrors()) > 0) ? true : false; 
    92 
    93    
    94  public function getUrl($with_uri = true) 
    95 
    96    if ($this->isTestMode()) 
    97    
    98      if ($this->getSecurityType() == 'Certificate') 
    99       {  
    100        $url = "https://api.sandbox.paypal.com/nvp"; 
    101      
    102      else  
    103      
    104        $url = "https://api-3t.sandbox.paypal.com/nvp"; 
    105      
    106    
    107    else  
    108    
    109      if ($this->getSecurityType() == 'Certificate') 
    110      
    111        $url = "https://api.paypal.com/nvp"; 
    112      
    113      else  
    114      
    115        $url = "https://api-3t.paypal.com/nvp"; 
    116      
    117    
    118      
    119    if ($with_uri == true && $uri = $this->getUri()) 
    120    
    121      $url = $url . "?" . $uri; 
    122    
    123      
    124    return $url; 
    125 
    126    
    127  public function setUri($value) 
    128 
    129    $this->uri = $value; 
    130 
    131    
    132  public function getUri() 
    133 
    134    if ($this->uri && substr($this->uri, -1) == '&') 
    135    
    136      return substr($this->uri, 0, -1); 
    137    
    138      
    139    return $this->uri; 
    140 
    141    
    142  public function appendUri($value) 
    143 
    144    $this->uri .= $value . '&'; 
    145 
    146    
    147  public function getParams() 
    148 
    149    return $this->params; 
    150 
    151      
    152  public function getParam($field) 
    153 
    154    if (array_key_exists($field, $this->getParams())) 
    155    
    156      return $this->params[$field]; 
    157    
    158      
    159    return null; 
    160 
    161    
    162  public function addParam($field, $value, $line = null) 
    163 
    164    $value = urlencode(trim($value)); 
    165      
    166    if (is_numeric($line)) 
    167    
    168       $this->params['L_' . $field . $line] = $value;   
    169    
    170    else  
    171    
    172       $this->params[$field] = $value;  
    173    
    174 
    175    
    176  public function getResponse() 
    177 
    178    return $this->response; 
    179 
    180    
    181  public function getResponseParam($field) 
    182 
    183    if (array_key_exists($field, $this->getResponse())) 
    184    
    185      return $this->response[$field]; 
    186    
    187      
    188    return null; 
    189 
    190    
    191  public function addResponseParam($field, $value) 
    192 
    193    $this->response[$field] = urldecode($value); 
    194 
    195    
    196  public function setApiVersion($value) 
    197 
    198    $this->addParam('VERSION', $value); 
    199 
    200      
    201  public function setApiUsername($value) 
    202 
    203    $this->addParam('USER', $value); 
    204 
    205      
    206  public function setApiPassword($value) 
    207 
    208    $this->addParam('PWD', $value); 
    209 
    210    
    211  public function setApiMethod($value) 
    212 
    213    $this->addParam('METHOD', $value); 
    214 
    215  
    216  /** 
    217  * Acceptible Values: Sale, Authorization 
    218 
    219  * @param unknown_type $value 
    220  */ 
    221  public function setApiPaymentAction($value) 
    222 
    223    $this->addParam('PAYMENTACTION', $value); 
    224 
    225  
    226  public function setIPAddress($value) 
    227 
    228    $this->addParam('IPADDRESS', $value); 
    229 
    230    
    231  public function setAmount($decimal) 
    232 
    233    $this->addParam('AMT', (float) $decimal); 
    234 
    235    
    236  /** 
    237  * Acceptable Values are:  
    238  *   Visa, MasterCard, Discover, Amex, Switch, Solo 
    239 
    240  * @param string $value 
    241  */ 
    242  public function setCreditCardType($value) 
    243 
    244    $this->addParam('CREDITCARDTYPE', $value); 
    245 
    246  
    247  public function setCreditCardNumber($value) 
    248 
    249    $this->addParam('ACCT', $value); 
    250 
    251    
    252  /** 
    253  * Format: MMYYYY 
    254  * Do not include any spaces or special characters 
    255 
    256  * @param integer $int 
    257  */ 
    258  public function setCreditCardExpiration($int) 
    259 
    260    $this->addParam('EXPDATE', $int); 
    261 
    262    
    263  /** 
    264  * Card Verification Value, version 2. 
    265  * NOTE: Your Merchant Account settings determine whether this field is required.  
    266  * Contact your PayPal Account Manager for more information. 
    267  * Character length for Visa, MasterCard, and Discover: exactly three digits. 
    268  * Character length for American Express: exactly four digits. 
    269  * IMPORTANT: To comply with credit card processing regulations, once a 
    270  * transaction has been completed, you must not store the value of CVV2. 
    271 
    272  * @param integer $int 
    273  */ 
    274  public function setCreditCardCVV2($int) 
    275 
    276    $this->addParam('CVV2', $int); 
    277 
    278  
    279  /** 
    280  * Month and year that Switch or Solo card was issued. 
    281  * Format: MMYYYY 
    282  * Character length and limitations: Six single-byte numeric characters, 
    283  * including leading zero. 
    284 
    285  * @param integer $int 
    286  */ 
    287  public function setCreditCardStartDate($int) 
    288 
    289    $this->addParam('STARTDATE', $int); 
    290 
    291    
    292  /** 
    293  * Issue number of Switch or Solo card. 
    294  * Character length: two numeric digits maximum. 
    295 
    296  * @param string $value 
    297  */ 
    298  public function setCreditCardIssueNumber($value) 
    299 
    300    $this->addParam('ISSUENUMBER', $value); 
    301   }  
    302    
    303  /** 
    304  * Maximum of 25 characters accepted 
    305 
    306  * @param string $value 
    307  */ 
    308  public function setFirstName($value) 
    309 
    310    $this->addParam('FIRSTNAME', $value); 
    311 
    312    
    313  /** 
    314  * Maximum of 25 characters accepted 
    315 
    316  * @param string $value 
    317  */ 
    318  public function setLastName($value) 
    319 
    320    $this->addParam('LASTNAME', $value); 
    321 
    322    
    323  /** 
    324  * Phone number. 
    325  * Character length and limitations: 20 characters 
    326 
    327  * @param string $value 
    328  */ 
    329  public function setPhoneNumber($value) 
    330 
    331    $this->addParam('PHONENUM', $value); 
    332   }  
    333    
    334  /** 
    335  * Email address of payer. 
    336  * Character length and limitations: 127 characters 
    337 
    338  * @param string $value 
    339  */ 
    340  public function setEmail($value) 
    341 
    342    $this->addParam('EMAIL', $value); 
    343   }  
    344    
    345  /** 
    346  * Maximum of 100 characters accepted 
    347 
    348  * @param string $value 
    349  */ 
    350  public function setStreet($value) 
    351 
    352    $this->addParam('STREET', $value); 
    353 
    354    
    355  /** 
    356  * Second street address. 
    357  * Character length and limitations: 100 characters 
    358 
    359  * @param string $value 
    360  */ 
    361  public function setStreet2($value) 
    362 
    363    $this->addParam('STREET2', $value); 
    364   }  
    365  
    366  /** 
    367  * Maximum of 40 characters accepted. 
    368 
    369  * @param string $value 
    370  */ 
    371  public function setCity($value) 
    372 
    373    $this->addParam('CITY', $value); 
    374 
    375  
    376  /** 
    377  * 2 letter state/provice code accepted.  
    378 
    379  * @param string $value 
    380  */ 
    381  public function setState($value) 
    382 
    383    $this->addParam('STATE', $value); 
    384 
    385    
    386  /** 
    387  * 2 letter country code accepted. 
    388  *  
    389  * @param string $value 
    390  */ 
    391  public function setCountry($value) 
    392 
    393    $this->addParam('COUNTRYCODE', $value); 
    394 
    395    
    396  /** 
    397  * U.S. ZIP code or other country-specific postal code. 
    398  * Maximum of 20 characters accepted. 
    399 
    400  * @param string $value 
    401  */ 
    402  public function setZip($value) 
    403 
    404    $this->addParam('ZIP', $value); 
    405 
    406    
    407  /** 
    408  * Person’s name associated with this address. 
    409  * Character length and limitations: 32 characters 
    410 
    411  * @param string $value 
    412  */ 
    413  public function setShipToName($value) 
    414 
    415    $this->addParam('SHIPTONAME', $value); 
    416 
    417  
    418  /** 
    419  * First street address. 
    420  * Character length and limitations: 100 characters 
    421 
    422  * @param string $value 
    423  */ 
    424  public function setShipToStreet($value) 
    425 
    426    $this->addParam('SHIPTOSTREET', $value); 
    427 
    428    
    429  /** 
    430  * Second street address. 
    431  * Character length and limitations: 100 characters 
    432 
    433  * @param string $value 
    434  */ 
    435  public function setShipToStreet2($value) 
    436 
    437    $this->addParam('SHIPTOSTREET2', $value); 
    438   }  
    439    
    440  /** 
    441  * Name of city. 
    442  * Character length and limitations: 40 characters 
    443 
    444  * @param string $value 
    445  */ 
    446  public function setShipToCity($value) 
    447 
    448    $this->addParam('SHIPTOCITY', $value); 
    449 
    450  
    451  /** 
    452  * U.S. ZIP code or other country-specific postal code. 
    453  * Character length and limitations: 20 characters 
    454 
    455  * @param string $value 
    456  */ 
    457  public function setShipToZip($value) 
    458 
    459    $this->addParam('SHIPTOZIP', $value); 
    460 
    461  
    462  /** 
    463  * Country code. 
    464  * Character limit: Two single-byte characters 
    465 
    466  * @param string $value 
    467  */ 
    468  public function setShipToCountryCode($value) 
    469 
    470    $this->addParam('SHIPTOCOUNTRYCODE', $value); 
    471 
    472    
    473  /** 
    474  * Phone number. 
    475  * Character length and limitations: 20 characters 
    476 
    477  * @param string $value 
    478  */ 
    479  public function setShipToPhoneNumber($value) 
    480 
    481    $this->addParam('SHIPTOPHONENUM', $value); 
    482   }  
    483    
    484  /** 
    485  * Your URL for receiving Instant Payment Notification (IPN) about this transaction. 
    486  * NOTE: If you do not specify this URL in the request, the notification URL 
    487  * from your Merchant Profile is used, if one exists. 
    488  *  
    489  * @param string $value 
    490  */ 
    491  public function setNotifyUrl($value) 
    492 
    493    $this->addParam('NOTIFYURL', $value); 
    494 
    495    
    496  /** 
    497  * A three-character currency code. Default: USD. 
    498 
    499  * @param string $value 
    500    */  
    501  public function setCurrencyCode($value) 
    502 
    503    $this->addParam('CURRENCYCODE', $value); 
    504 
    505    
    506  /** 
    507  * Sum of cost of all items in this order. 
    508  * Limitations: The value must be a positive number and cannot exceed 
    509  * $10,000 USD in any currency. No currency symbol. Must have two 
    510  * decimal places, decimal separator must be a period (.), and the optional 
    511  * thousands separator must be a comma (,). 
    512 
    513  * @param decimal $decimal 
    514    */    
    515  public function setItemAmountTotal($decimal) 
    516 
    517    $this->addParam('ITEMAMT', $value); 
    518 
    519    
    520  /** 
    521  * Total shipping costs for this order. 
    522  * Limitations: The value must be zero or greater and cannot exceed 
    523  * $10,000 USD in any currency. No currency symbol. Must have two 
    524  * decimal places, decimal separator must be a period (.), and the optional 
    525  * thousands separator must be a comma (,). 
    526 
    527  * @param decimal $decimal 
    528    */    
    529  public function setShippingAmountTotal($decimal) 
    530 
    531    $this->addParam('SHIPPINGAMT', $value); 
    532 
    533  
    534  /** 
    535  * Total handling costs for this order. 
    536  * Limitations: The value must be zero or greater and cannot exceed 
    537  * $10,000 USD in any currency. No currency symbol. Must have two 
    538  * decimal places, decimal separator must be a period (.), and the optional 
    539  * thousands separator must be a comma (,). 
    540 
    541  * @param decimal $decimal 
    542    */    
    543  public function setHandlingAmountTotal($decimal) 
    544 
    545    $this->addParam('HANDLINGAMT', $value); 
    546 
    547  
    548  /** 
    549  * Total handling costs for this order. 
    550  * Limitations: The value must be zero or greater and cannot exceed 
    551  * $10,000 USD in any currency. No currency symbol. Must have two 
    552  * decimal places, decimal separator must be a period (.), and the optional 
    553  * thousands separator must be a comma (,). 
    554 
    555  * @param decimal $decimal 
    556    */    
    557  public function setTaxAmountTotal($decimal) 
    558 
    559    $this->addParam('TAXAMT', $value); 
    560 
    561    
    562  /** 
    563  * Description of items the customer is purchasing. 
    564  * Character length and limitations: 127 alphanumeric characters 
    565 
    566  * @param string $value 
    567    */  
    568  public function setDescription($value) 
    569 
    570    $this->addParam('DESC', $value); 
    571 
    572    
    573  /** 
    574  * A free-form field for your own use. 
    575  * Character length and limitations: 256 alphanumeric characters 
    576 
    577  * @param string $value 
    578    */  
    579  public function setCustom($value) 
    580 
    581    $this->addParam('CUSTOM', $value); 
    582 
    583  
    584  /** 
    585  * Your own invoice or tracking number. 
    586  * Character length and limitations: 127 alphanumeric characters 
    587 
    588  * @param string $value 
    589    */  
    590  public function setInvoiceNumber($value) 
    591 
    592    $this->addParam('INVNUM', $value); 
    593 
    594    
    595  /** 
    596  * An identification code for use by third-party applications to identify transactions. 
    597  * Character length and limitations: 32 alphanumeric characters 
    598 
    599  * @param string $value 
    600    */  
    601  public function setButtonSource($value) 
    602 
    603    $this->addParam('BUTTONSOURCE', $value); 
    604 
    605  
    606  public function addLineItemName($name, $value, $line) 
    607 
    608    $this->addParam('NAME', $value, $line); 
    609 
    610    
    611  public function addLineItemNumber($name, $value, $line) 
    612 
    613    $this->addParam('NUMBER', $value, $line); 
    614 
    615    
    616  public function addLineItemQuantity($name, $value, $line) 
    617 
    618    $this->addParam('QTY', $value, $line); 
    619 
    620  
    621  public function addLineItemTaxAmount($name, $value, $line) 
    622 
    623    $this->addParam('TAXAMT', $value, $line); 
    624 
    625  
    626  public function addLineItemAmount($name, $value, $line) 
    627 
    628    $this->addParam('AMT', $value, $line); 
    629 
    630        
    631  public function verifyCredentials() 
    632 
    633    if (!$this->getParam('USER')) 
    634    
    635      $this->setError('With all security types, you must supply a username.'); 
    636       return false;  
    637    
    638      
    639    if (!$this->getParam('PWD')) 
    640    
    641      $this->setError('With all security types, you must supply a password.'); 
    642       return false;  
    643     }    
    644      
    645    if ($this->getSecurityType() == 'Certificate') 
    646    
    647      if (!$certificate_path = $this->getApiCertificatePath()) 
    648      
    649        $this->setError('When using "Certificate" based authentication, you must supply the path to a valid certificate.'); 
    650        return false; 
    651      
    652        
    653      if (!file_exists($certificate_path)) 
    654      
    655        $this->setError('The specified certificate file could not be found: ' . $certificate_path); 
    656         return false;        
    657      
    658    
    659    else  
    660    
    661      if (!$this->getParam('SIGNATURE')) 
    662      
    663        $this->setError('When using "Signature" based authentication, you must supply a signature key.'); 
    664         return false;  
    665       }      
    666    
    667      
    668    return true; 
    669 
    670    
    671  public function prepareRequest() 
    672 
    673    if ($params = $this->getParams()) 
    674    
    675      foreach ($params as $field => $value) 
    676      
    677        $this->appendUri($field . '=' . $value); 
    678      
    679    
    680   }  
    681    
    682  public function execute() 
    683 
    684    if (!in_array("curl", get_loaded_extensions())) 
    685    
    686        throw new sfException('Could not load cURL libraries. Make sure PHP is compiled with cURL'); 
    687    
    688           
    689    if (!$this->verifyCredentials()) 
    690    
    691      return false; 
    692    
    693      
    694    $this->prepareRequest(); 
    695      
    696    $ch = curl_init($this->getUrl(false)); 
    697    curl_setopt($ch, CURLOPT_POST, 1); 
    698    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    699    curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getUri()); 
    700    curl_setopt($ch, CURLOPT_REFERER, ""); 
    701      
    702    if ($this->getSecurityType() == 'Certificate') 
    703    
    704      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    705      curl_setopt($ch, CURLOPT_SSLCERT, $this->getApiCertificatePath()); 
    706    
    707          
    708    $response = curl_exec($ch); 
    709     curl_close($ch);     
    710      
    711    $this->prepareResponse($response); 
    712      
    713    return ($this->getResponseParam('ACK') == 'Success') ? true: false; 
    714 
    715    
    716  public function prepareResponse($response) 
    717 
    718    if (!empty($response)) 
    719    
    720      if ($response = explode("&", $response)) 
    721      
    722        foreach ($response as $nvp) 
    723        
    724          $nvp = explode('=', $nvp); 
    725            
    726          $this->addResponseParam($nvp[0], $nvp[1]); 
    727            
    728          if ($nvp[0] == 'L_LONGMESSAGE0') 
    729          
    730            $this->setError($this->getResponseParam($nvp[0])); 
    731          
    732        
    733      
    734    
    735 
     3{   
     4  private $security_type = 'Certificate'; 
     5   
     6  private $api_certificate_path; 
     7   
     8  private $test_mode = false; 
     9   
     10  private $uri = null; 
     11   
     12  private $params = array(); 
     13   
     14  private $response = array(); 
     15   
     16  private $errors = array(); 
     17   
     18  public function __construct($security_type = 'Certificate', $test_mode = false) 
     19  {    
     20    $this->setApiMethod('DoDirectPayment');    
     21    $this->setApiVersion('2.3'); 
     22    $this->setApiPaymentAction('Sale'); 
     23    $this->setSecurityType($security_type); 
     24    $this->setIPAddress($_SERVER["REMOTE_ADDR"]); 
     25     
     26    if ($test_mode !== false) 
     27   
     28      $this->setTestMode(true); 
     29   
     30 
     31   
     32  public function setTestMode($mode = true) 
     33 
     34    $this->test_mode = (bool) $mode; 
     35 
     36   
     37  /** 
     38  * Determine if the api is in test mode 
     39 
     40  * @return boolean 
     41  */ 
     42  public function isTestMode() 
     43 
     44    return $this->test_mode; 
     45 
     46   
     47  /** 
     48  * Set the PayPal security type 
     49  * Valid options: Certificate, Signature 
     50  * NOTE: Signature based authentication requires a username and password 
     51 
     52  * @param unknown_type $value 
     53  */ 
     54  public function setSecurityType($value) 
     55 
     56    $this->security_type = $value; 
     57 
     58   
     59  public function getSecurityType() 
     60 
     61    return $this->security_type; 
     62 
     63   
     64  public function setApiCertificatePath($string) 
     65 
     66    $this->api_certificate_path = $string; 
     67 
     68     
     69  public function getApiCertificatePath() 
     70 
     71    return $this->api_certificate_path; 
     72 
     73   
     74  public function setApiSignature($value) 
     75 
     76    $this->addParam('SIGNATURE', $value); 
     77 
     78   
     79  public function setError($msg) 
     80 
     81    $this->errors[] = $msg; 
     82 
     83   
     84  public function getErrors() 
     85 
     86    return $this->errors; 
     87 
     88   
     89  public function hasErrors() 
     90 
     91    return (count($this->getErrors()) > 0) ? true : false; 
     92 
     93   
     94  public function getUrl($with_uri = true) 
     95 
     96    if ($this->isTestMode()) 
     97   
     98      if ($this->getSecurityType() == 'Certificate') 
     99      {   
     100        $url = "https://api.sandbox.paypal.com/nvp"; 
     101     
     102      else  
     103     
     104        $url = "https://api-3t.sandbox.paypal.com/nvp"; 
     105     
     106   
     107    else  
     108   
     109      if ($this->getSecurityType() == 'Certificate') 
     110     
     111        $url = "https://api.paypal.com/nvp"; 
     112     
     113      else  
     114     
     115        $url = "https://api-3t.paypal.com/nvp"; 
     116     
     117   
     118     
     119    if ($with_uri == true && $uri = $this->getUri()) 
     120   
     121      $url = $url . "?" . $uri; 
     122   
     123     
     124    return $url; 
     125 
     126   
     127  public function setUri($value) 
     128 
     129    $this->uri = $value; 
     130 
     131   
     132  public function getUri() 
     133 
     134    if ($this->uri && substr($this->uri, -1) == '&') 
     135   
     136      return substr($this->uri, 0, -1); 
     137   
     138     
     139    return $this->uri; 
     140 
     141   
     142  public function appendUri($value) 
     143 
     144    $this->uri .= $value . '&'; 
     145 
     146   
     147  public function getParams() 
     148 
     149    return $this->params; 
     150 
     151     
     152  public function getParam($field) 
     153 
     154    if (array_key_exists($field, $this->getParams())) 
     155   
     156      return $this->params[$field]; 
     157   
     158     
     159    return null; 
     160 
     161   
     162  public function addParam($field, $value, $line = null) 
     163 
     164    $value = urlencode(trim($value)); 
     165     
     166    if (is_numeric($line)) 
     167   
     168      $this->params['L_' . $field . $line] = $value;   
     169   
     170    else  
     171   
     172      $this->params[$field] = $value;   
     173   
     174 
     175   
     176  public function getResponse() 
     177 
     178    return $this->response; 
     179 
     180   
     181  public function getResponseParam($field) 
     182 
     183    if (array_key_exists($field, $this->getResponse())) 
     184   
     185      return $this->response[$field]; 
     186   
     187     
     188    return null; 
     189 
     190   
     191  public function addResponseParam($field, $value) 
     192 
     193    $this->response[$field] = urldecode($value); 
     194 
     195   
     196  public function setApiVersion($value) 
     197 
     198    $this->addParam('VERSION', $value); 
     199 
     200     
     201  public function setApiUsername($value) 
     202 
     203    $this->addParam('USER', $value); 
     204 
     205     
     206  public function setApiPassword($value) 
     207 
     208    $this->addParam('PWD', $value); 
     209 
     210   
     211  public function setApiMethod($value) 
     212 
     213    $this->addParam('METHOD', $value); 
     214 
     215 
     216  /** 
     217  * Acceptible Values: Sale, Authorization 
     218 
     219  * @param unknown_type $value 
     220  */ 
     221  public function setApiPaymentAction($value) 
     222 
     223    $this->addParam('PAYMENTACTION', $value); 
     224 
     225 
     226  public function setIPAddress($value) 
     227 
     228    $this->addParam('IPADDRESS', $value); 
     229 
     230   
     231  public function setAmount($decimal) 
     232 
     233    $this->addParam('AMT', (float) $decimal); 
     234 
     235   
     236  /** 
     237  * Acceptable Values are:  
     238  *   Visa, MasterCard, Discover, Amex, Switch, Solo 
     239 
     240  * @param string $value 
     241  */ 
     242  public function setCreditCardType($value) 
     243 
     244    $this->addParam('CREDITCARDTYPE', $value); 
     245 
     246 
     247  public function setCreditCardNumber($value) 
     248 
     249    $this->addParam('ACCT', $value); 
     250 
     251   
     252  /** 
     253  * Format: MMYYYY 
     254  * Do not include any spaces or special characters 
     255 
     256  * @param integer $int 
     257  */ 
     258  public function setCreditCardExpiration($int) 
     259 
     260    $this->addParam('EXPDATE', $int); 
     261 
     262   
     263  /** 
     264  * Card Verification Value, version 2. 
     265  * NOTE: Your Merchant Account settings determine whether this field is required.  
     266  * Contact your PayPal Account Manager for more information. 
     267  * Character length for Visa, MasterCard, and Discover: exactly three digits. 
     268  * Character length for American Express: exactly four digits. 
     269  * IMPORTANT: To comply with credit card processing regulations, once a 
     270  * transaction has been completed, you must not store the value of CVV2. 
     271 
     272  * @param integer $int 
     273  */ 
     274  public function setCreditCardCVV2($int) 
     275 
     276    $this->addParam('CVV2', $int); 
     277 
     278 
     279  /** 
     280  * Month and year that Switch or Solo card was issued. 
     281  * Format: MMYYYY 
     282  * Character length and limitations: Six single-byte numeric characters, 
     283  * including leading zero. 
     284 
     285  * @param integer $int 
     286  */ 
     287  public function setCreditCardStartDate($int) 
     288 
     289    $this->addParam('STARTDATE', $int); 
     290 
     291   
     292  /** 
     293  * Issue number of Switch or Solo card. 
     294  * Character length: two numeric digits maximum. 
     295 
     296  * @param string $value 
     297  */ 
     298  public function setCreditCardIssueNumber($value) 
     299 
     300    $this->addParam('ISSUENUMBER', $value); 
     301  }   
     302   
     303  /** 
     304  * Maximum of 25 characters accepted 
     305 
     306  * @param string $value 
     307  */ 
     308  public function setFirstName($value) 
     309 
     310    $this->addParam('FIRSTNAME', $value); 
     311 
     312   
     313  /** 
     314  * Maximum of 25 characters accepted 
     315 
     316  * @param string $value 
     317  */ 
     318  public function setLastName($value) 
     319 
     320    $this->addParam('LASTNAME', $value); 
     321 
     322   
     323  /** 
     324  * Phone number. 
     325  * Character length and limitations: 20 characters 
     326 
     327  * @param string $value 
     328  */ 
     329  public function setPhoneNumber($value) 
     330 
     331    $this->addParam('PHONENUM', $value); 
     332  }   
     333   
     334  /** 
     335  * Email address of payer. 
     336  * Character length and limitations: 127 characters 
     337 
     338  * @param string $value 
     339  */ 
     340  public function setEmail($value) 
     341 
     342    $this->addParam('EMAIL', $value); 
     343  }   
     344   
     345  /** 
     346  * Maximum of 100 characters accepted 
     347 
     348  * @param string $value 
     349  */ 
     350  public function setStreet($value) 
     351 
     352    $this->addParam('STREET', $value); 
     353 
     354   
     355  /** 
     356  * Second street address. 
     357  * Character length and limitations: 100 characters 
     358 
     359  * @param string $value 
     360  */ 
     361  public function setStreet2($value) 
     362 
     363    $this->addParam('STREET2', $value); 
     364  }   
     365 
     366  /** 
     367  * Maximum of 40 characters accepted. 
     368 
     369  * @param string $value 
     370  */ 
     371  public function setCity($value) 
     372 
     373    $this->addParam('CITY', $value); 
     374 
     375 
     376  /** 
     377  * 2 letter state/provice code accepted.  
     378 
     379  * @param string $value 
     380  */ 
     381  public function setState($value) 
     382 
     383    $this->addParam('STATE', $value); 
     384 
     385   
     386  /** 
     387  * 2 letter country code accepted. 
     388  *  
     389  * @param string $value 
     390  */ 
     391  public function setCountry($value) 
     392 
     393    $this->addParam('COUNTRYCODE', $value); 
     394 
     395   
     396  /** 
     397  * U.S. ZIP code or other country-specific postal code. 
     398  * Maximum of 20 characters accepted. 
     399 
     400  * @param string $value 
     401  */ 
     402  public function setZip($value) 
     403 
     404    $this->addParam('ZIP', $value); 
     405 
     406   
     407  /** 
     408  * Person’s name associated with this address. 
     409  * Character length and limitations: 32 characters 
     410 
     411  * @param string $value 
     412  */ 
     413  public function setShipToName($value) 
     414 
     415    $this->addParam('SHIPTONAME', $value); 
     416 
     417 
     418  /** 
     419  * First street address. 
     420  * Character length and limitations: 100 characters 
     421 
     422  * @param string $value 
     423  */ 
     424  public function setShipToStreet($value) 
     425 
     426    $this->addParam('SHIPTOSTREET', $value); 
     427 
     428   
     429  /** 
     430  * Second street address. 
     431  * Character length and limitations: 100 characters 
     432 
     433  * @param string $value 
     434  */ 
     435  public function setShipToStreet2($value) 
     436 
     437    $this->addParam('SHIPTOSTREET2', $value); 
     438  }   
     439   
     440  /** 
     441  * Name of city. 
     442  * Character length and limitations: 40 characters 
     443 
     444  * @param string $value 
     445  */ 
     446  public function setShipToCity($value) 
     447 
     448    $this->addParam('SHIPTOCITY', $value); 
     449 
     450 
     451  /** 
     452  * U.S. ZIP code or other country-specific postal code. 
     453  * Character length and limitations: 20 characters 
     454 
     455  * @param string $value 
     456  */ 
     457  public function setShipToZip($value) 
     458 
     459    $this->addParam('SHIPTOZIP', $value); 
     460 
     461 
     462  /** 
     463  * Country code. 
     464  * Character limit: Two single-byte characters 
     465 
     466  * @param string $value 
     467  */ 
     468  public function setShipToCountryCode($value) 
     469 
     470    $this->addParam('SHIPTOCOUNTRYCODE', $value); 
     471 
     472   
     473  /** 
     474  * Phone number. 
     475  * Character length and limitations: 20 characters 
     476 
     477  * @param string $value 
     478  */ 
     479  public function setShipToPhoneNumber($value) 
     480 
     481    $this->addParam('SHIPTOPHONENUM', $value); 
     482  }   
     483   
     484  /** 
     485  * Your URL for receiving Instant Payment Notification (IPN) about this transaction. 
     486  * NOTE: If you do not specify this URL in the request, the notification URL 
     487  * from your Merchant Profile is used, if one exists. 
     488  *  
     489  * @param string $value 
     490  */ 
     491  public function setNotifyUrl($value) 
     492 
     493    $this->addParam('NOTIFYURL', $value); 
     494 
     495   
     496  /** 
     497  * A three-character currency code. Default: USD. 
     498 
     499  * @param string $value 
     500   */   
     501  public function setCurrencyCode($value) 
     502 
     503    $this->addParam('CURRENCYCODE', $value); 
     504 
     505   
     506  /** 
     507  * Sum of cost of all items in this order. 
     508  * Limitations: The value must be a positive number and cannot exceed 
     509  * $10,000 USD in any currency. No currency symbol. Must have two 
     510  * decimal places, decimal separator must be a period (.), and the optional 
     511  * thousands separator must be a comma (,). 
     512 
     513  * @param decimal $decimal 
     514   */     
     515  public function setItemAmountTotal($decimal) 
     516 
     517    $this->addParam('ITEMAMT', $value); 
     518 
     519   
     520  /** 
     521  * Total shipping costs for this order. 
     522  * Limitations: The value must be zero or greater and cannot exceed 
     523  * $10,000 USD in any currency. No currency symbol. Must have two 
     524  * decimal places, decimal separator must be a period (.), and the optional 
     525  * thousands separator must be a comma (,). 
     526 
     527  * @param decimal $decimal 
     528   */     
     529  public function setShippingAmountTotal($decimal) 
     530 
     531    $this->addParam('SHIPPINGAMT', $value); 
     532 
     533 
     534  /** 
     535  * Total handling costs for this order. 
     536  * Limitations: The value must be zero or greater and cannot exceed 
     537  * $10,000 USD in any currency. No currency symbol. Must have two 
     538  * decimal places, decimal separator must be a period (.), and the optional 
     539  * thousands separator must be a comma (,). 
     540 
     541  * @param decimal $decimal 
     542   */     
     543  public function setHandlingAmountTotal($decimal) 
     544 
     545    $this->addParam('HANDLINGAMT', $value); 
     546 
     547 
     548  /** 
     549  * Total handli