Skip to content

Commit

Permalink
Merge pull request #503 from razorpay/rzp-sdk-2.8.7
Browse files Browse the repository at this point in the history
new sdk 2.8.7 changes
  • Loading branch information
poojarazor authored Sep 11, 2023
2 parents 5d2fbf4 + 354e8e1 commit ffcc9fb
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 11 deletions.
62 changes: 62 additions & 0 deletions razorpay-sdk/src/Account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Razorpay\Api;

class Account extends Entity
{

public function create($attributes = array())
{
$entityUrl = $this->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;
}
}
8 changes: 4 additions & 4 deletions razorpay-sdk/src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -16,7 +16,7 @@ class Api
*/
public static $appsDetails = array();

const VERSION = '2.8.5';
const VERSION = '2.8.7';

/**
* @param string $key
Expand Down Expand Up @@ -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;
}
}
7 changes: 7 additions & 0 deletions razorpay-sdk/src/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
5 changes: 3 additions & 2 deletions razorpay-sdk/src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
{
Expand Down
11 changes: 11 additions & 0 deletions razorpay-sdk/src/Iin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Razorpay\Api;

class Iin extends Entity
{
public function fetch($id)
{
return parent::fetch($id);
}
}
6 changes: 6 additions & 0 deletions razorpay-sdk/src/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

namespace Razorpay\Api;

use Requests;

class Order extends Entity
{
/**
* @param $id Order id description
*/
public function create($attributes = array())
{
$attributes = json_encode($attributes);

Request::addHeader('Content-Type', 'application/json');

return parent::create($attributes);
}

Expand Down
34 changes: 34 additions & 0 deletions razorpay-sdk/src/Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Razorpay\Api;

class Product extends Entity
{
public function requestProductConfiguration($attributes = array())
{
$url = 'accounts/'.$this->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');
}
}
7 changes: 4 additions & 3 deletions razorpay-sdk/src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
34 changes: 34 additions & 0 deletions razorpay-sdk/src/Stakeholder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Razorpay\Api;

class Stakeholder extends Entity
{
public function create($attributes = array())
{
$url = 'accounts/'.$this->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');
}
}
31 changes: 30 additions & 1 deletion razorpay-sdk/src/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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();
Expand All @@ -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);
}
}
33 changes: 32 additions & 1 deletion razorpay-sdk/src/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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');
}
}

0 comments on commit ffcc9fb

Please sign in to comment.