Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Paypal {
- private $user = '';
- private $password = '';
- private $signature = '';
- private $endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
- public $errors = array();
- public function __construct($user = 'seller_api1.linox.com',$password = 'E8BEUX7T447ADU4K',$signature = 'AFcWxV21C7fd0v3bYYYRCpSSRl31Aq2ySAZ-mZO5WnXxfeVsJRGsAdq-',$sandbox = true)
- {
- $this->user = $user;
- $this->password = $password;
- $this->signature = $signature;
- $this->sandbox = $sandbox;
- if(!$sandbox)
- {
- $this->endpoint = str_replace('sandbox.','',$this->endpoint);
- }
- }
- public function request($method,$params)
- {
- $params = array_merge($params, array(
- 'METHOD' => $method,
- 'USER' => $this->user,
- 'PWD' => $this->password,
- 'SIGNATURE' => $this->signature,
- 'VERSION' => '74.0'
- ));
- $params = http_build_query($params);
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $this->endpoint,
- CURLOPT_POST => 1,
- CURLOPT_POSTFIELDS => $params,
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_SSL_VERIFYPEER => false,
- CURLOPT_SSL_VERIFYHOST => false,
- CURLOPT_VERBOSE => 1
- ));
- $response = curl_exec($curl);
- $responseArray = array();
- parse_str($response,$responseArray);
- if(curl_errno($curl))
- {
- $this->errors = curl_error($curl);
- curl_close($curl);
- return false;
- }
- else {
- if($responseArray['ACK'] == 'Success')
- {
- return $responseArray;
- curl_close($curl);
- }else{
- $this->errors = $responseArray;
- curl_close($curl);
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement