Changeset 1597
- Timestamp:
- 12/20/2007 06:12:59 PM (13 months ago)
- Location:
- trunk/system/libraries
- Files:
-
- 1 added
- 4 modified
-
Payment.php (modified) (4 diffs)
-
drivers/Payment_Authorize.php (modified) (4 diffs)
-
drivers/Payment_Paypal.php (modified) (5 diffs)
-
drivers/Payment_Trident.php (added)
-
drivers/Payment_Trustcommerce.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/libraries/Payment.php
r1449 r1597 16 16 // The driver string 17 17 'driver' => NULL, 18 // Curl config, see http://us.php.net/manual/en/function.curl-setopt.php for details19 'curl_config' => array20 (21 CURLOPT_HEADER => FALSE,22 CURLOPT_RETURNTRANSFER => TRUE,23 CURLOPT_SSL_VERIFYPEER => FALSE24 ),25 18 // Test mode is set to true by default 26 19 'test_mode' => TRUE, … … 28 21 29 22 protected $driver = NULL; 30 private $fields = array();31 23 32 24 /** … … 121 113 public function set_fields($fields) 122 114 { 123 $this->driver->set_fields( array_merge($this->fields, (array) $fields));115 $this->driver->set_fields((array) $fields); 124 116 125 117 return $this; … … 135 127 public function process() 136 128 { 137 $this->set_fields($this->fields);138 129 return $this->driver->process(); 139 130 } -
trunk/system/libraries/drivers/Payment_Authorize.php
r1297 r1597 83 83 } 84 84 85 $fields = "";85 $fields = ''; 86 86 foreach( $this->authnet_values as $key => $value ) 87 87 { … … 92 92 'https://certification.authorize.net/gateway/transact.dll' : // Test mode URL 93 93 'https://secure.authorize.net/gateway/transact.dll'; // Live URL 94 94 95 95 $ch = curl_init($post_url); 96 96 97 97 // Set custom curl options 98 98 curl_setopt_array($ch, $this->curl_config); 99 99 100 100 // Set the curl POST fields 101 curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& "));101 curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($fields, '& ')); 102 102 103 103 //execute post and get results 104 104 $resp = curl_exec($ch); 105 105 curl_close ($ch); 106 if (!$resp) 107 throw new Kohana_Exception('payment.gateway_connection_error'); 106 108 107 109 // This could probably be done better, but it's taken right from the Authorize.net manual 108 110 // Need testing to opimize probably 109 $h = substr_count($resp, "|");110 111 $h = substr_count($resp, '|'); 112 111 113 for($j=1; $j <= $h; $j++) 112 114 { 113 $p = strpos($resp, "|");115 $p = strpos($resp, '|'); 114 116 115 117 if ($p !== FALSE) … … 119 121 $pstr_trimmed = substr($pstr, 0, -1); // removes "|" at the end 120 122 121 if($pstr_trimmed== "")123 if($pstr_trimmed=='') 122 124 { 123 125 throw new Kohana_Exception('payment.gateway_connection_error'); … … 137 139 } 138 140 } 139 } 141 } // End Payment_Authorize_Driver Class 140 142 141 143 /** -
trunk/system/libraries/drivers/Payment_Paypal.php
r1493 r1597 16 16 class Payment_Paypal_Driver { 17 17 18 private $required_fields = array( 19 'API_UserName' => FALSE, 20 'API_Password' => FALSE, 21 'API_Signature' => FALSE, 22 'API_Endpoint' => TRUE, 23 'version' => TRUE, 24 'Amt' => FALSE, 25 'PAYMENTACTION' => TRUE, 26 'ReturnUrl' => FALSE, 27 'CANCELURL' => FALSE, 28 'CURRENCYCODE' => TRUE 29 ); 30 31 private $paypal_values = array( 32 'API_UserName' => '', 33 'API_Password' => '', 34 'API_Signature' => '', 35 'API_Endpoint' => 'https://api-3t.paypal.com/nvp', 36 'version' => '3.0', 37 'Amt' => 0, 38 'PAYMENTACTION' => 'Sale', 39 'ReturnUrl' => '', 40 'CANCELURL' => '', 41 'error_url' => '', 42 'CURRENCYCODE' => 'USD', 43 'payerid' => '' 44 ); 18 private $required_fields = array('API_UserName' => FALSE, 19 'API_Password' => FALSE, 20 'API_Signature' => FALSE, 21 'API_Endpoint' => TRUE, 22 'version' => TRUE, 23 'Amt' => FALSE, 24 'PAYMENTACTION' => TRUE, 25 'ReturnUrl' => FALSE, 26 'CANCELURL' => FALSE, 27 'CURRENCYCODE' => TRUE); 28 29 private $paypal_values = array('API_UserName' => '', 30 'API_Password' => '', 31 'API_Signature' => '', 32 'API_Endpoint' => 'https://api-3t.paypal.com/nvp', 33 'version' => '3.0', 34 'Amt' => 0, 35 'PAYMENTACTION' => 'Sale', 36 'ReturnUrl' => '', 37 'CANCELURL' => '', 38 'error_url' => '', 39 'CURRENCYCODE' => 'USD', 40 'payerid' => ''); 45 41 46 42 private $paypal_url = ''; … … 64 60 65 61 $this->paypal_url = ($config['test_mode']) 66 ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='67 : 'https://www.paypal.com/webscr&cmd=_express-checkout&token=';62 ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' 63 : 'https://www.paypal.com/webscr&cmd=_express-checkout&token='; 68 64 69 65 $this->required_fields['API_UserName'] = !empty($config['API_UserName']); … … 104 100 105 101 $this->paypal_values[$key] = $value; 106 102 107 103 if (array_key_exists($key, $this->required_fields) AND !empty($value)) 108 104 { … … 221 217 { 222 218 $final_data = 'METHOD='.urlencode($method). 223 '&VERSION='.urlencode($this->paypal_values['version']).224 '&PWD='.urlencode($this->paypal_values['API_Password']).225 '&USER='.urlencode($this->paypal_values['API_UserName']).226 'SIGNATURE='.urlencode($this->paypal_values['API_Signature']).$data;219 '&VERSION='.urlencode($this->paypal_values['version']). 220 '&PWD='.urlencode($this->paypal_values['API_Password']). 221 '&USER='.urlencode($this->paypal_values['API_UserName']). 222 'SIGNATURE='.urlencode($this->paypal_values['API_Signature']).$data; 227 223 228 224 $ch = curl_init($this->paypal_values['API_Endpoint']); … … 288 284 return $nvpArray; 289 285 } 290 } 286 } // End Payment_Paypal_Driver Class -
trunk/system/libraries/drivers/Payment_Trustcommerce.php
r1297 r1597 127 127 return Kohana::lang('payment.error', Kohana::lang('payment.errors.Trustcommerce.'.$result['status'].'.'.$result['error'])); 128 128 } 129 } 129 } // End Payment_Trustcommerce_Driver Class
