diff --git a/razorpay-sdk/src/Account.php b/razorpay-sdk/src/Account.php new file mode 100644 index 00000000..66b6adcb --- /dev/null +++ b/razorpay-sdk/src/Account.php @@ -0,0 +1,62 @@ +getEntityUrl(); + + return $this->request('POST', $entityUrl, $attributes, 'v2'); + } + + public function fetch($id) + { + $entityUrl = $this->getEntityUrl(); + + return $this->request('GET', $entityUrl . $id, null, 'v2'); + } + + public function delete() + { + $entityUrl = $this->getEntityUrl(); + + return $this->request('DELETE', $entityUrl . $this->id, null, 'v2'); + } + + public function edit($attributes = array()) + { + $url = $this->getEntityUrl() . $this->id; + + return $this->request('PATCH', $url, $attributes, 'v2'); + } + + public function stakeholders() + { + $stakeholder = new Stakeholder(); + + $stakeholder['account_id'] = $this->id; + + return $stakeholder; + } + + public function products() + { + $product = new Product(); + + $product['account_id'] = $this->id; + + return $product; + } + + public function webhooks() + { + $webhook = new Webhook(); + + $webhook['account_id'] = $this->id; + + return $webhook; + } +} diff --git a/razorpay-sdk/src/Api.php b/razorpay-sdk/src/Api.php index 16709ed6..c4d91456 100644 --- a/razorpay-sdk/src/Api.php +++ b/razorpay-sdk/src/Api.php @@ -4,7 +4,7 @@ class Api { - protected static $baseUrl = 'https://api.razorpay.com/v1/'; + protected static $baseUrl = 'https://api.razorpay.com'; protected static $key = null; @@ -16,7 +16,7 @@ class Api */ public static $appsDetails = array(); - const VERSION = '2.8.5'; + const VERSION = '2.8.7'; /** * @param string $key @@ -84,8 +84,8 @@ public static function getSecret() return self::$secret; } - public static function getFullUrl($relativeUrl) + public static function getFullUrl($relativeUrl, $apiVersion = "v1") { - return self::getBaseUrl() . $relativeUrl; + return self::getBaseUrl() . "/". $apiVersion . "/". $relativeUrl; } } diff --git a/razorpay-sdk/src/Card.php b/razorpay-sdk/src/Card.php index d9f77eff..186815b9 100644 --- a/razorpay-sdk/src/Card.php +++ b/razorpay-sdk/src/Card.php @@ -11,4 +11,11 @@ public function fetch($id) { return parent::fetch($id); } + + public function requestCardReference($attributes = array()) + { + $entityUrl = $this->getEntityUrl() . '/fingerprints'; + + return $this->request('POST', $entityUrl, $attributes); + } } diff --git a/razorpay-sdk/src/Entity.php b/razorpay-sdk/src/Entity.php index feb98507..caf17c5c 100644 --- a/razorpay-sdk/src/Entity.php +++ b/razorpay-sdk/src/Entity.php @@ -82,14 +82,15 @@ protected function snakeCase($input) * @param string $relativeUrl * @param array $data * @param array $additionHeader + * @param string $apiVersion * * @return Entity */ - protected function request($method, $relativeUrl, $data = null) + protected function request($method, $relativeUrl, $data = null, $apiVersion = "v1") { $request = new Request(); - $response = $request->request($method, $relativeUrl, $data); + $response = $request->request($method, $relativeUrl, $data, $apiVersion); if ((isset($response['entity'])) and ($response['entity'] == $this->getEntity())) { diff --git a/razorpay-sdk/src/Iin.php b/razorpay-sdk/src/Iin.php new file mode 100644 index 00000000..c2f26530 --- /dev/null +++ b/razorpay-sdk/src/Iin.php @@ -0,0 +1,11 @@ +account_id .'/'.$this->getEntityUrl(); + + return $this->request('POST', $url, $attributes, 'v2'); + } + + public function fetch($id) + { + $entityUrl = 'accounts/'.$this->account_id .'/'.$this->getEntityUrl().'/'.$id; + + return $this->request('GET', $entityUrl, null, 'v2'); + } + + public function edit($id, $attributes = array()) + { + $entityUrl = 'accounts/'.$this->account_id .'/'.$this->getEntityUrl().'/'.$id; + + return $this->request('PATCH', $entityUrl, $attributes, 'v2'); + } + + public function fetchTnc($product_name) + { + $entityUrl = $this->getEntityUrl().'/'.$product_name.'/tnc'; + + return $this->request('GET', $entityUrl,null , 'v2'); + } +} diff --git a/razorpay-sdk/src/Request.php b/razorpay-sdk/src/Request.php index 78ea5919..2ccab02e 100644 --- a/razorpay-sdk/src/Request.php +++ b/razorpay-sdk/src/Request.php @@ -35,12 +35,13 @@ class Request * @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()) - { - $url = Api::getFullUrl($url); + public function request($method, $url, $data = array(), $apiVersion = "v1") + { + $url = Api::getFullUrl($url, $apiVersion); $hooks = new Requests_Hooks(); diff --git a/razorpay-sdk/src/Stakeholder.php b/razorpay-sdk/src/Stakeholder.php new file mode 100644 index 00000000..05cf5971 --- /dev/null +++ b/razorpay-sdk/src/Stakeholder.php @@ -0,0 +1,34 @@ +account_id .'/'.$this->getEntityUrl(); + + return $this->request('POST', $url, $attributes, 'v2'); + } + + public function fetch($id) + { + $entityUrl = 'accounts/'.$this->account_id .'/'.$this->getEntityUrl().'/'.$id; + + return $this->request('GET', $entityUrl, null, 'v2'); + } + + public function all($options = array()) + { + $relativeUrl = 'accounts/'.$this->account_id.'/'.$this->getEntityUrl(); + + return $this->request('GET', $relativeUrl, $options, 'v2'); + } + + public function edit($id, $attributes = array()) + { + $entityUrl = 'accounts/'.$this->account_id .'/'.$this->getEntityUrl().'/'.$id; + + return $this->request('PATCH', $entityUrl, $attributes, 'v2'); + } +} diff --git a/razorpay-sdk/src/Token.php b/razorpay-sdk/src/Token.php index 4a2e5634..8f55874c 100644 --- a/razorpay-sdk/src/Token.php +++ b/razorpay-sdk/src/Token.php @@ -3,7 +3,15 @@ namespace Razorpay\Api; class Token extends Entity -{ +{ + + public function create($attributes = array()) + { + $url = $this->getEntityUrl(); + + return $this->request('POST', $url, $attributes); + } + /** * @param $id Token id */ @@ -14,6 +22,13 @@ public function fetch($id) return $this->request('GET', $relativeUrl); } + public function fetchCardPropertiesByToken($attributes = array()) + { + $relativeUrl = $this->getEntityUrl(). '/fetch'; + + return $this->request('POST', $relativeUrl, $attributes); + } + public function all($options = array()) { $relativeUrl = 'customers/'.$this->customer_id.'/'.$this->getEntityUrl(); @@ -27,4 +42,18 @@ public function delete($id) return $this->request('DELETE', $relativeUrl); } + + public function deleteToken($attributes = array()) + { + $relativeUrl = $this->getEntityUrl(). '/delete'; + + return $this->request('POST', $relativeUrl, $attributes); + } + + public function processPaymentOnAlternatePAorPG($attributes = array()) + { + $relativeUrl = $this->getEntityUrl().'service_provider_tokens/token_transactional_data'; + + return $this->request('POST', $relativeUrl, $attributes); + } } diff --git a/razorpay-sdk/src/Webhook.php b/razorpay-sdk/src/Webhook.php index b2728d80..a0e9d9ac 100644 --- a/razorpay-sdk/src/Webhook.php +++ b/razorpay-sdk/src/Webhook.php @@ -10,16 +10,34 @@ class Webhook extends Entity */ public function create($attributes = array()) { + if(isset($this->account_id)) + { + $url = 'accounts/'. $this->account_id . '/' .$this->getEntityUrl(); + + return $this->request('POST', $url, $attributes, 'v2'); + } return parent::create($attributes); } public function fetch($id) { + if(isset($this->account_id)) + { + $url = 'accounts/'. $this->account_id . '/' .$this->getEntityUrl() . $id; + + return $this->request('GET', $url, null, 'v2'); + } return parent::fetch($id); } public function all($options = array()) { + if(isset($this->account_id)) + { + $url = 'accounts/'. $this->account_id . '/' .$this->getEntityUrl(); + + return $this->request('GET', $url, $options, 'v2'); + } return parent::all($options); } @@ -33,7 +51,20 @@ public function all($options = array()) public function edit($attributes, $id) { $url = $this->getEntityUrl() . $id; - + + if(isset($this->account_id)) + { + $url = 'accounts/'.$this->account_id .'/'. $url; + + return $this->request('PATCH', $url, $attributes, 'v2'); + } return $this->request(Requests::PUT, $url, $attributes); } + + public function delete($id) + { + $url = 'accounts/'. $this->account_id . '/' .$this->getEntityUrl(). $id; + + return $this->request('DELETE', $url, null, 'v2'); + } }