コード例 #1
0
ファイル: SkrillPSP.php プロジェクト: mayeco/skrillpsp
 /**
  * Allows you the add json name/value outside of the SKRILL PSP predefined json name/values.
  * Name/value pairs will be added in the params member of the JSON Request object.
  * NOTE: You must not set valid parameter group as key of associative array
  * @link http://www.jsonrpc.org/specification#request_object
  * @see SkrillPSP::setParameters() 
  * <code>
  * $objDebit = new SkrillPsp_Debit();
  * $objDebit->addParameters(array('country' => array('city' => 'Sofia'))); ==> {'country' : {'city':'Sofia'}}
  * </code>
  * @param mixed $params
  * @throws OutOfBoundsException
  */
 public function addParameters($params)
 {
     // check for assoc array
     if (is_array($params) && SkrillPsp_Util::isAssocArray($params)) {
         foreach ($params as $key => $value) {
             if (!array_key_exists($key, $this->json['params'])) {
                 $this->json['params'][$key] = $value;
             } else {
                 throw new OutOfBoundsException("Not allowed to override predefined parameters!");
             }
         }
     } else {
         // check for index array
         if (is_array($params)) {
             $arr = array_diff($params, $this->validGroups);
             if (count($arr) === 0) {
                 throw new OutOfBoundsException("Not allowed to override predefined parameters!");
             }
         }
         if (in_array($params, $this->validGroups)) {
             throw new OutOfBoundsException("Not allowed to override predefined parameters!");
         }
         array_push($this->json['params'], $params);
     }
 }
コード例 #2
0
ファイル: Http.php プロジェクト: mayeco/skrillpsp
 /**
  * Executes POST request
  * @see self::verifyResponse()
  * @param string $url 
  * @param array $params
  * @return SkrillPsp_Response_Success|SkrillPsp_Response_Error 
  * @throws SkrillPsp_Exception
  */
 public static function post($url, $params = null)
 {
     $response = self::_doUrlRequest(self::$post, $url, $params);
     $responseCode = $response['status'];
     if ($responseCode === 200 || $responseCode === 201) {
         // return $response['body'];
         return self::verifyResponse($response['body']);
     } else {
         SkrillPsp_Util::statusCodeException($responseCode);
     }
 }