œ_#ÁÕ§TE NAŒ“KeÉ:”(åŽÖJÞùY’‚ñùž7; «]Û ý`8g“¯B© jdÖÖ¸ðzœ¸¦4Ç3Kó^(ÍÖ¼ Õ€pvìwšõB4df$Èü^0˜…åÌC$#2FŽÑ§±¦ÛZ/÷š&m£ñzÒÖ ’.Î]!Î;ƒ(Õ–¢d/—#Kª+tZyuÏB>NÛÖ†(¸ŒSà'³„Y˜´-_•¦¼´˜OlNK§¶ÒàŠˆTHµƒeTPå·fïM’…þuÏÍüp6دªE£åü‡ZØ'CKF#â«;‹eyO Qp„†l"ö1èíÙP ÏŒúl! BÝ2ñª•_VÁÉ÷3eu`–F¸ìI--ö<¿žë¯4õ캿¢)34Å{wMÉ2ÆÖFŸ¥`e9Ú¶¸P‡.”FÔï rY ‚²ÈTB,{ÛœéJ}«àQ4¹0Rû4D‚B§S‘ dO•v¾„™Sן¯3FeŸ™«+ÓâwH dÕÛÌì·P4ë&¥#rÜÉ Ù¦ê†ý·xòqk¯2,¹§™E\ék‚×Sá”ÚºÙ⺷ö£6…à ʾ qSá³Å|;àû}4Ÿ($â¹VY~óÍ!èÜÒŒËX½Ù1j‚VíÍŸš³+œ]«½g{_{/vµ½\¢¶vÉWKÿ:ñám½ ¥ S²x‘t ŽšÝÙÿÀÇ^ný PK IW™k‚½÷ á _rels/.relsUT dìd dìd dìd’ÏNÃ0‡ï{ŠÈ÷ÕÝ@¡¥» ¤Ý*`%îÑ&QâÁöö‚J£ì°cœŸ¿|¶²ÙÆA½rL½wVE Šñ¶w†çúay * 9Kƒw¬áÈ ¶ÕbóÄIîI]’Ê—4t"á1™ŽGJ…ìòMããH’±Å@æ…ZÆuYÞ`üÍ€jÂT;«!îì T}|Û7MoøÞ›ýÈNN<|v–í2ÄÜ¥ÏèšbË¢Ázó˜Ë )„"£OÏ7ú{ZYÈ’yÞç#1'tuÉM?6o>Z´_å9›ëKÚ˜}?þ³žÏÌ·N>fµx PK IWª½e ¢ U € word/document.xmlUT dìdPK IWþË3” z €J¢ word/settings.xmlUT dìdPK IWC‡{š' ƒ €¤ docProps/custom.xmlUT dìdPK IW츱=Œ €‡¥ [Content_Types].xmlUT dìdPK IWV%ë±" €U§ docProps/app.xmlUT dìdPK IW€RŒ 3 €¶¨ docProps/core.xmlUT dìdPK IWkòDn ô €ª word/_rels/document.xml.relsUT dìdPK IW;$î €Î« word/fontTable.xmlUT dìdPK IW+åäz] ÷. €ý¬ word/numbering.xmlUT dìdPK IW¤2×r- ¿ €›° word/styles.xmlUT dìdPK IWMFÒ ø €´ word/header1.xmlUT dìdPK IWF— T e €· word/media/image1.jpegUT dìdPK IW!Yéáå €°Ë word/media/image2.pngUT dìdPK IW°Àºë ú €ÙÌ word/media/image3.pngUT dìdPK IW$“†ª L €Î word/footer1.xmlUT dìdPK IWzaGôM €ñÑ word/footer2.xmlUT dìdPK IW–µâº P €}Õ word/theme/theme1.xmlUT dìdPK IW™k‚½÷ á €{Û _rels/.relsUT PK ! bîh^ [Content_Types].xml ¢( ¬”ËNÃ0E÷HüCä-Jܲ@5í‚Ç*Q>Àēƪc[žiiÿž‰ûB¡j7±ÏÜ{2ñÍh²nm¶‚ˆÆ»R‹ÈÀU^7/ÅÇì%¿’rZYï @1__f› ˜q·ÃR4DáAJ¬h>€ãÚÇV߯¹ªZ¨9ÈÛÁàNVÞ8Ê©ÓãÑÔji){^óã-I‹"{Üv^¥P!XS)bR¹rú—K¾s(¸3Õ`cÞ0†½ÝÎß»¾7M4²©ŠôªZÆk+¿|\|z¿(Ž‹ôPúº6h_-[ž@!‚ÒØ Pk‹´2nÏ}Ä?£LËð Ýû%áÄßdºždN"m,à¥ÇžDO97*‚~§Èɸ8ÀOíc|n¦Ñ äEøÿöéºóÀBÉÀ!$}‡íàÈé;{ìÐå[ƒîñ–é2þ ÿÿ PK ! µU0#ô L _rels/.rels ¢( ¬’MOÃ0†ïHü‡È÷ÕÝBKwAH»!T~€Iܵ£$Ý¿'TƒG½~üÊÛÝ<êÈ!öâ4¬‹;#¶w†—úqu *&r–Fq¬áÄvÕõÕö™GJy(v½*«¸¨¡KÉß#FÓñD±Ï.W ¥†=™ZÆMYÞbø®ÕBS톰·7 ê“Ï›×–¦é ?ˆ9LìÒ™ÈsbgÙ®|Èl!õùUSh9i°bžr:"y_dlÀóD›¿ý|-NœÈR"4ø2ÏGÇ% õZ´4ñËyÄ7 ëÈðÉ‚‹¨Þ ÿÿ PK ! Q48wÛ — xl/workbook.xml¤UÙnâ0}iþ!cñ‡ *–¢AšVU×$dC¬&vÆv UÕŸë@XÊK§/¹p|Žï¹N÷b“¥Ö •Š ÞC¸î"‹òHÄŒ¯zèá~b·‘¥4á1I§=ôJºèÿüÑ] ù¼âÙ ®z(Ñ:GE ͈ª‹œrˆ,…̈†©\9*—”Ä*¡Tg©ã¹nàd„q´Eåg0ÄrÉ":Q‘Q®· ’¦D}•°\UhYô¸ŒÈç"·#‘å ±`)Ó¯%(²²(œ®¸d‘‚ì nZ w v¡ñª• t¶TÆ")”Xê:@;[Ògú±ë`|²›ó=ø’ïHúÂL÷¬dðEVÁ+8€a÷Ûh¬Uz%„Íû"ZsÏÍCýî’¥ôqk]‹äù5ÉL¦Rd¥Dé˘i÷P ¦bM/|dÉ",…¨çãFNoçiûéë>aêiçsó#ðÄ ÕTr¢éHp ÜIú®ÝJìQ"ÀÜÖ-ý[0I¡¦ÀZ Z…d¡nˆN¬B¦=4 g %PDF-1.4 %âãÏÓ 3 0 obj << /Linearized 1 /L 422775 ÿØÿà JFIF ÿÛ C ÿÛ C ÿÀ X" ÿÄ ÿÄ H !1A"Qaq2‘¡#±ÁBRÑ3Cbrá$S‚¢²ð4ñ%6DTc’ÂsÿÄ ÿÄ = !1AQ"aq‘Á2R¡±BÑð#3br’²4á$‚¢ÂñÿÚ ? áHBßÝ`„! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! ! stream
<?php
namespace Razorpay\Api;
use Requests;
use Exception;
use Requests_Hooks;
use Razorpay\Api\Errors;
use Razorpay\Api\Errors\ErrorCode;
// Available since PHP 5.5.19 and 5.6.3
// https://git.io/fAMVS | https://secure.php.net/manual/en/curl.constants.php
if (defined('CURL_SSLVERSION_TLSv1_1') === false)
{
define('CURL_SSLVERSION_TLSv1_1', 5);
}
/**
* Request class to communicate to the request libarary
*/
class Request
{
public static $OAUTH = 'oauth';
public static $API = 'api';
protected $authType;
public function __construct($authType = null)
{
$this->authType = $authType ?? self::$API;
}
/**
* Headers to be sent with every http request to the API
* @var array
*/
protected static $headers = array(
'Razorpay-API' => 1
);
/**
* Fires a request to the API
* @param string $method HTTP Verb
* @param string $url Relative URL for the request
* @param array $data Data to be passed along the request
* @param array $additionHeader headers to be passed along the request
* @param string $apiVersion version to be passed along the request
* @return array Response data in array format. Not meant
* to be used directly
*/
public function request($method, $url, $data = array(), $apiVersion = "v1")
{
if($this->authType == self::$OAUTH){
$url = OAuth::getFullUrl($url, $apiVersion);
}else{
$url = Api::getFullUrl($url, $apiVersion);
}
$hooks = new Requests_Hooks();
$hooks->register('curl.before_send', array($this, 'setCurlSslOpts'));
$options = array(
'hook' => $hooks,
'timeout' => 60
);
$headers = $this->getRequestHeaders();
if(!Api::getToken()){
$options['auth'] = array(Api::getKey(), Api::getSecret());
}
if(Api::getToken()){
$token = Api::getToken();
$headers['Authorization'] = "Bearer $token";
}
$response = Requests::request($url, $headers, $data, $method, $options);
$this->checkErrors($response);
return json_decode($response->body, true);
}
public function setCurlSslOpts($curl)
{
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_1);
}
/**
* Adds an additional header to all API requests
* @param string $key Header key
* @param string $value Header value
* @return null
*/
public static function addHeader($key, $value)
{
self::$headers[$key] = $value;
}
/**
* Removes an additional header from all API requests
* @param string $key Header key
* @return null
*/
public static function removeHeader($key){
unset(self::$headers[$key]);
}
/**
* Returns all headers attached so far
* @return array headers
*/
public static function getHeaders()
{
return self::$headers;
}
/**
* Process the statusCode of the response and throw exception if necessary
* @param Object $response The response object returned by Requests
*/
protected function checkErrors($response)
{
$body = $response->body;
$httpStatusCode = $response->status_code;
try
{
$body = json_decode($response->body, true);
}
catch (Exception $e)
{
$this->throwServerError($body, $httpStatusCode);
}
if (($httpStatusCode < 200) or
($httpStatusCode >= 300))
{
$this->processError($body, $httpStatusCode, $response);
}
}
protected function processError($body, $httpStatusCode, $response)
{
if(isset($body['error']) && $this->authType == self::$OAUTH){
if($httpStatusCode >= 400 && $httpStatusCode < 500){
$body['error']['code'] = ErrorCode::BAD_REQUEST_ERROR;
}else if($httpStatusCode >= 500){
$body['error']['code'] = ErrorCode::SERVER_ERROR;
}
}
$this->verifyErrorFormat($body, $httpStatusCode);
$code = $body['error']['code'];
// We are basically converting the error code to the Error class name
// Replace underscores with space
// Lowercase the words, capitalize first letter of each word
// Remove spaces
$error = str_replace('_', ' ', $code);
$error = ucwords(strtolower($error));
$error = str_replace(' ', '', $error);
// Add namespace
// This is the fully qualified error class name
$error = __NAMESPACE__.'\Errors\\' . $error;
$description = $body['error']['description'];
$field = null;
if (isset($body['error']['field']))
{
$field = $body['error']['field'];
// Create an instance of the error and then throw it
throw new $error($description, $code, $httpStatusCode, $field);
}
throw new $error($description, $code, $httpStatusCode);
}
protected function throwServerError($body, $httpStatusCode)
{
$description = "The server did not send back a well-formed response. " . PHP_EOL .
"Server Response: $body";
throw new Errors\ServerError(
$description,
ErrorCode::SERVER_ERROR,
$httpStatusCode);
}
protected function getRequestHeaders()
{
$uaHeader = array(
'User-Agent' => $this->constructUa()
);
$headers = array_merge(self::$headers, $uaHeader);
return $headers;
}
protected function constructUa()
{
$ua = 'Razorpay/v1 PHPSDK/' . Api::VERSION . ' PHP/' . phpversion();
$ua .= ' ' . $this->getAppDetailsUa();
return $ua;
}
protected function getAppDetailsUa()
{
$appsDetails = Api::$appsDetails;
$appsDetailsUa = '';
foreach ($appsDetails as $app)
{
if ((isset($app['title'])) and (is_string($app['title'])))
{
$appUa = $app['title'];
if ((isset($app['version'])) and (is_scalar($app['version'])))
{
$appUa .= '/' . $app['version'];
}
$appsDetailsUa .= $appUa . ' ';
}
}
return $appsDetailsUa;
}
/**
* Verifies error is in proper format. If not then
* throws ServerErrorException
*
* @param array $body
* @param int $httpStatusCode
* @return void
*/
protected function verifyErrorFormat($body, $httpStatusCode)
{
if (is_array($body) === false)
{
$this->throwServerError($body, $httpStatusCode);
}
if ((isset($body['error']) === false) or
(isset($body['error']['code']) === false))
{
$this->throwServerError($body, $httpStatusCode);
}
$code = $body['error']['code'];
if (Errors\ErrorCode::exists($code) === false)
{
$this->throwServerError($body, $httpStatusCode);
}
}
}