Razorpay for WooCommerce - Version 2.8.2

Version Description

  • Updated Razorpay SDK.
  • Added subscription webhook events.
  • Tested up to Woocommerce 5.9.0
Download this release

Release Info

Developer razorpay
Plugin Icon 128x128 Razorpay for WooCommerce
Version 2.8.2
Comparing to
See all releases

Code changes from version 2.8.1 to 2.8.2

includes/razorpay-route.php CHANGED
@@ -512,7 +512,7 @@ class RZP_Route extends WP_List_Table
512
  $this->prepareReversalItems();
513
 
514
  echo '<form method="get">
515
- <input type="hidden" name="page" value="razorpay_route_reversals">';
516
 
517
  $this->display();
518
 
@@ -614,7 +614,7 @@ class RZP_Route extends WP_List_Table
614
  $this->preparePaymentItems();
615
 
616
  echo '<form method="get">
617
- <input type="hidden" name="page" value="razorpay_route_payments">';
618
  echo '<p class="pay_search_label">Search here for payments of linked account</p>';
619
  $this->search_box('search', 'search_id');
620
  $this->display();
512
  $this->prepareReversalItems();
513
 
514
  echo '<form method="get">
515
+ <input type="hidden" name="page" value="razorpayRouteReversals">';
516
 
517
  $this->display();
518
 
614
  $this->preparePaymentItems();
615
 
616
  echo '<form method="get">
617
+ <input type="hidden" name="page" value="razorpayRoutePayments">';
618
  echo '<p class="pay_search_label">Search here for payments of linked account</p>';
619
  $this->search_box('search', 'search_id');
620
  $this->display();
includes/razorpay-webhook.php CHANGED
@@ -28,13 +28,17 @@ class RZP_Webhook
28
  const SUBSCRIPTION_CANCELLED = 'subscription.cancelled';
29
  const REFUNDED_CREATED = 'refund.created';
30
  const VIRTUAL_ACCOUNT_CREDITED = 'virtual_account.credited';
 
 
31
 
32
  protected $eventsArray = [
33
- self::PAYMENT_AUTHORIZED,
34
- self::VIRTUAL_ACCOUNT_CREDITED,
35
- self::REFUNDED_CREATED,
36
- self::PAYMENT_FAILED,
37
- self::SUBSCRIPTION_CANCELLED
 
 
38
  ];
39
 
40
  public function __construct()
@@ -81,7 +85,7 @@ class RZP_Webhook
81
  {
82
  return;
83
  }
84
-
85
  if (isset($_SERVER['HTTP_X_RAZORPAY_SIGNATURE']) === true)
86
  {
87
  $razorpayWebhookSecret = $this->razorpay->getSetting('webhook_secret');
@@ -129,6 +133,12 @@ class RZP_Webhook
129
  case self::REFUNDED_CREATED:
130
  return $this->refundedCreated($data);
131
 
 
 
 
 
 
 
132
  default:
133
  return;
134
  }
@@ -154,6 +164,23 @@ class RZP_Webhook
154
  return;
155
  }
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  /**
159
  * Handling the payment authorized webhook
@@ -161,7 +188,7 @@ class RZP_Webhook
161
  * @param array $data Webook Data
162
  */
163
  protected function paymentAuthorized(array $data)
164
- {
165
  // We don't process subscription/invoice payments here
166
  if (isset($data['payload']['payment']['entity']['invoice_id']) === true)
167
  {
@@ -349,9 +376,9 @@ class RZP_Webhook
349
  * Returns boolean false incase not proper webhook data
350
  */
351
  protected function shouldConsumeWebhook($data)
352
- {
353
- if ((isset($data['event']) === true) and
354
- (in_array($data['event'], $this->eventsArray) === true) and
355
  isset($data['payload']['payment']['entity']['notes']['woocommerce_order_number']) === true)
356
  {
357
  return true;
28
  const SUBSCRIPTION_CANCELLED = 'subscription.cancelled';
29
  const REFUNDED_CREATED = 'refund.created';
30
  const VIRTUAL_ACCOUNT_CREDITED = 'virtual_account.credited';
31
+ const SUBSCRIPTION_PAUSED = 'subscription.paused';
32
+ const SUBSCRIPTION_RESUMED = 'subscription.resumed';
33
 
34
  protected $eventsArray = [
35
+ self::PAYMENT_AUTHORIZED,
36
+ self::VIRTUAL_ACCOUNT_CREDITED,
37
+ self::REFUNDED_CREATED,
38
+ self::PAYMENT_FAILED,
39
+ self::SUBSCRIPTION_CANCELLED,
40
+ self::SUBSCRIPTION_PAUSED,
41
+ self::SUBSCRIPTION_RESUMED
42
  ];
43
 
44
  public function __construct()
85
  {
86
  return;
87
  }
88
+
89
  if (isset($_SERVER['HTTP_X_RAZORPAY_SIGNATURE']) === true)
90
  {
91
  $razorpayWebhookSecret = $this->razorpay->getSetting('webhook_secret');
133
  case self::REFUNDED_CREATED:
134
  return $this->refundedCreated($data);
135
 
136
+ case self::SUBSCRIPTION_PAUSED:
137
+ return $this->subscriptionPaused($data);
138
+
139
+ case self::SUBSCRIPTION_RESUMED:
140
+ return $this->subscriptionResumed($data);
141
+
142
  default:
143
  return;
144
  }
164
  return;
165
  }
166
 
167
+ /**
168
+ * Does nothing for the main payments flow currently
169
+ * @param array $data Webook Data
170
+ */
171
+ protected function subscriptionPaused(array $data)
172
+ {
173
+ return;
174
+ }
175
+
176
+ /**
177
+ * Does nothing for the main payments flow currently
178
+ * @param array $data Webook Data
179
+ */
180
+ protected function subscriptionResumed(array $data)
181
+ {
182
+ return;
183
+ }
184
 
185
  /**
186
  * Handling the payment authorized webhook
188
  * @param array $data Webook Data
189
  */
190
  protected function paymentAuthorized(array $data)
191
+ {
192
  // We don't process subscription/invoice payments here
193
  if (isset($data['payload']['payment']['entity']['invoice_id']) === true)
194
  {
376
  * Returns boolean false incase not proper webhook data
377
  */
378
  protected function shouldConsumeWebhook($data)
379
+ {
380
+ if ((isset($data['event']) === true) and
381
+ (in_array($data['event'], $this->eventsArray) === true) and
382
  isset($data['payload']['payment']['entity']['notes']['woocommerce_order_number']) === true)
383
  {
384
  return true;
razorpay-sdk/src/Addon.php CHANGED
@@ -18,4 +18,11 @@ class Addon extends Entity
18
 
19
  return $this->request('DELETE', $entityUrl . $this->id);
20
  }
 
 
 
 
 
 
 
21
  }
18
 
19
  return $this->request('DELETE', $entityUrl . $this->id);
20
  }
21
+
22
+ public function fetchAll($attributes = array())
23
+ {
24
+ $entityUrl = $this->getEntityUrl();
25
+
26
+ return $this->request('GET', $entityUrl , $attributes);
27
+ }
28
  }
razorpay-sdk/src/Api.php CHANGED
@@ -16,7 +16,7 @@ class Api
16
  */
17
  public static $appsDetails = array();
18
 
19
- const VERSION = '2.7.0';
20
 
21
  /**
22
  * @param string $key
16
  */
17
  public static $appsDetails = array();
18
 
19
+ const VERSION = '2.8.1';
20
 
21
  /**
22
  * @param string $key
razorpay-sdk/src/Entity.php CHANGED
@@ -7,11 +7,16 @@ use Razorpay\Api\Errors;
7
  class Entity extends Resource implements ArrayableInterface
8
  {
9
  protected $attributes = array();
10
-
11
- protected function create($attributes = null)
 
 
 
 
 
12
  {
13
  $entityUrl = $this->getEntityUrl();
14
-
15
  return $this->request('POST', $entityUrl, $attributes);
16
  }
17
 
@@ -22,7 +27,7 @@ class Entity extends Resource implements ArrayableInterface
22
  $this->validateIdPresence($id);
23
 
24
  $relativeUrl = $entityUrl . $id;
25
-
26
  return $this->request('GET', $relativeUrl);
27
  }
28
 
@@ -46,7 +51,7 @@ class Entity extends Resource implements ArrayableInterface
46
  protected function all($options = array())
47
  {
48
  $entityUrl = $this->getEntityUrl();
49
-
50
  return $this->request('GET', $entityUrl, $options);
51
  }
52
 
@@ -76,6 +81,7 @@ class Entity extends Resource implements ArrayableInterface
76
  * @param string $method
77
  * @param string $relativeUrl
78
  * @param array $data
 
79
  *
80
  * @return Entity
81
  */
@@ -85,8 +91,7 @@ class Entity extends Resource implements ArrayableInterface
85
 
86
  $response = $request->request($method, $relativeUrl, $data);
87
 
88
- if ((isset($response['entity'])) and
89
- ($response['entity'] == $this->getEntity()))
90
  {
91
  $this->fill($response);
92
 
@@ -97,7 +102,7 @@ class Entity extends Resource implements ArrayableInterface
97
  return static::buildEntity($response);
98
  }
99
  }
100
-
101
  /**
102
  * Given the JSON response of an API call, wraps it to corresponding entity
103
  * class or a collection and returns the same.
@@ -161,7 +166,9 @@ class Entity extends Resource implements ArrayableInterface
161
  public function fill($data)
162
  {
163
  $attributes = array();
164
-
 
 
165
  foreach ($data as $key => $value)
166
  {
167
  if (is_array($value))
@@ -169,7 +176,6 @@ class Entity extends Resource implements ArrayableInterface
169
  if (static::isAssocArray($value) === false)
170
  {
171
  $collection = array();
172
-
173
  foreach ($value as $v)
174
  {
175
  if (is_array($v))
@@ -182,7 +188,6 @@ class Entity extends Resource implements ArrayableInterface
182
  array_push($collection, $v);
183
  }
184
  }
185
-
186
  $value = $collection;
187
  }
188
  else
@@ -193,7 +198,7 @@ class Entity extends Resource implements ArrayableInterface
193
 
194
  $attributes[$key] = $value;
195
  }
196
-
197
  $this->attributes = $attributes;
198
  }
199
 
7
  class Entity extends Resource implements ArrayableInterface
8
  {
9
  protected $attributes = array();
10
+ /**
11
+ * Create method
12
+ *
13
+ * @param array $attributes
14
+ *
15
+ */
16
+ protected function create($attributes = null)
17
  {
18
  $entityUrl = $this->getEntityUrl();
19
+
20
  return $this->request('POST', $entityUrl, $attributes);
21
  }
22
 
27
  $this->validateIdPresence($id);
28
 
29
  $relativeUrl = $entityUrl . $id;
30
+
31
  return $this->request('GET', $relativeUrl);
32
  }
33
 
51
  protected function all($options = array())
52
  {
53
  $entityUrl = $this->getEntityUrl();
54
+
55
  return $this->request('GET', $entityUrl, $options);
56
  }
57
 
81
  * @param string $method
82
  * @param string $relativeUrl
83
  * @param array $data
84
+ * @param array $additionHeader
85
  *
86
  * @return Entity
87
  */
91
 
92
  $response = $request->request($method, $relativeUrl, $data);
93
 
94
+ if ((isset($response['entity'])) and ($response['entity'] == $this->getEntity()))
 
95
  {
96
  $this->fill($response);
97
 
102
  return static::buildEntity($response);
103
  }
104
  }
105
+
106
  /**
107
  * Given the JSON response of an API call, wraps it to corresponding entity
108
  * class or a collection and returns the same.
166
  public function fill($data)
167
  {
168
  $attributes = array();
169
+
170
+ if(is_array($data))
171
+ {
172
  foreach ($data as $key => $value)
173
  {
174
  if (is_array($value))
176
  if (static::isAssocArray($value) === false)
177
  {
178
  $collection = array();
 
179
  foreach ($value as $v)
180
  {
181
  if (is_array($v))
188
  array_push($collection, $v);
189
  }
190
  }
 
191
  $value = $collection;
192
  }
193
  else
198
 
199
  $attributes[$key] = $value;
200
  }
201
+ }
202
  $this->attributes = $attributes;
203
  }
204
 
razorpay-sdk/src/FundAccount.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Razorpay\Api;
4
+
5
+ use Requests;
6
+
7
+
8
+ class FundAccount extends Entity
9
+ {
10
+ /**
11
+ * Create a Fund Account .
12
+ *
13
+ * @param array $attributes
14
+ *
15
+ * @return FundAccount
16
+ */
17
+ public function create($attributes = array())
18
+ {
19
+ return parent::create($attributes);
20
+ }
21
+
22
+ /**
23
+ * Fetch all Fund Accounts
24
+ *
25
+ * @param array $options
26
+ *
27
+ * @return Collection
28
+ */
29
+ public function all($options = array())
30
+ {
31
+ return parent::all($options);
32
+ }
33
+
34
+ }
razorpay-sdk/src/Item.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Razorpay\Api;
4
+
5
+ class Item extends Entity
6
+ {
7
+
8
+ public function create($attributes = array())
9
+ {
10
+ return parent::create($attributes);
11
+ }
12
+
13
+ public function fetch($id)
14
+ {
15
+ return parent::fetch($id);
16
+ }
17
+
18
+ public function edit($attributes = array())
19
+ {
20
+ $url = $this->getEntityUrl() . $this->id;
21
+
22
+ return $this->request('PATCH', $url, $attributes);
23
+ }
24
+
25
+ public function all($options = array())
26
+ {
27
+ return parent::all($options);
28
+ }
29
+
30
+ public function delete()
31
+ {
32
+ $url = $this->getEntityUrl() . $this->id;
33
+
34
+ return $this->request('DELETE', $url);
35
+ }
36
+ }
razorpay-sdk/src/Order.php CHANGED
@@ -22,10 +22,24 @@ class Order extends Entity
22
  return parent::all($options);
23
  }
24
 
 
 
 
 
 
 
 
25
  public function payments()
26
  {
27
  $relativeUrl = $this->getEntityUrl().$this->id.'/payments';
28
 
29
  return $this->request('GET', $relativeUrl);
30
  }
 
 
 
 
 
 
 
31
  }
22
  return parent::all($options);
23
  }
24
 
25
+ public function edit($attributes = array())
26
+ {
27
+ $url = $this->getEntityUrl() . $this->id;
28
+
29
+ return $this->request('PATCH', $url, $attributes);
30
+ }
31
+
32
  public function payments()
33
  {
34
  $relativeUrl = $this->getEntityUrl().$this->id.'/payments';
35
 
36
  return $this->request('GET', $relativeUrl);
37
  }
38
+
39
+ public function transfers($options = array())
40
+ {
41
+ $relativeUrl = $this->getEntityUrl().$this->id;
42
+
43
+ return $this->request('GET', $relativeUrl, $options);
44
+ }
45
  }
razorpay-sdk/src/Payment.php CHANGED
@@ -16,6 +16,13 @@ class Payment extends Entity
16
 
17
  public function all($options = array())
18
  {
 
 
 
 
 
 
 
19
  return parent::all($options);
20
  }
21
 
@@ -86,4 +93,100 @@ class Payment extends Entity
86
 
87
  return $this->request('GET', $relativeUrl);
88
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
16
 
17
  public function all($options = array())
18
  {
19
+ if(isset($options['X-Razorpay-Account'])){
20
+
21
+ Request::addHeader('X-Razorpay-Account', $options['X-Razorpay-Account']);
22
+
23
+ unset($options['X-Razorpay-Account']);
24
+ }
25
+
26
  return parent::all($options);
27
  }
28
 
93
 
94
  return $this->request('GET', $relativeUrl);
95
  }
96
+
97
+ public function fetchMultipleRefund($options = array())
98
+ {
99
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/refunds';
100
+
101
+ return $this->request('GET', $relativeUrl, $options);
102
+ }
103
+
104
+ public function fetchRefund($refundId)
105
+ {
106
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/refunds/'.$refundId;
107
+
108
+ return $this->request('GET', $relativeUrl);
109
+ }
110
+
111
+ public function createRecurring($attributes = array())
112
+ {
113
+ $relativeUrl = $this->getEntityUrl() . 'create/recurring';
114
+
115
+ return $this->request('POST', $relativeUrl, $attributes);
116
+ }
117
+ /**
118
+ * fetch Card Details
119
+ *
120
+ * @param id $id
121
+ *
122
+ * @return card
123
+ */
124
+ public function fetchCardDetails()
125
+ {
126
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/card';
127
+
128
+ return $this->request('GET', $relativeUrl);
129
+ }
130
+ /**
131
+ * fetchPaymentDowntime
132
+ *
133
+ */
134
+ public function fetchPaymentDowntime()
135
+ {
136
+ $relativeUrl = $this->getEntityUrl() . 'downtimes';
137
+
138
+ return $this->request('GET', $relativeUrl);
139
+ }
140
+ /**
141
+ * fetch Payment Downtime Id
142
+ *
143
+ * @param id $id
144
+ *
145
+ * @return card
146
+ */
147
+ public function fetchPaymentDowntimeById($id)
148
+ {
149
+ $relativeUrl = $this->getEntityUrl() . 'downtimes' . $id;
150
+
151
+ return $this->request('GET', $relativeUrl);
152
+ }
153
+ /**
154
+ * create Payment Json
155
+ *
156
+ * @param array $attributes
157
+ */
158
+ public function createPaymentJson($attributes = array())
159
+ {
160
+ $relativeUrl = $this->getEntityUrl() . 'create/json';
161
+
162
+ return $this->request('POST', $relativeUrl, $attributes);
163
+ }
164
+ /**
165
+ * submit otp
166
+ *
167
+ * @param id $id
168
+ *
169
+ * @param array $attributes
170
+ */
171
+ public function otpSubmit($attributes = array())
172
+ {
173
+ $relativeUrl = $this->getEntityUrl(). $this->id . '/otp/submit';
174
+
175
+ return $this->request('POST', $relativeUrl, $attributes);
176
+ }
177
+
178
+ /**
179
+ * Generate otp
180
+ *
181
+ * @param id $id
182
+ *
183
+ * @param array $attributes
184
+ */
185
+ public function otpGenerate()
186
+ {
187
+ $relativeUrl = $this->getEntityUrl(). $this->id . '/otp_generate';
188
+
189
+ return $this->request('POST', $relativeUrl);
190
+ }
191
+
192
  }
razorpay-sdk/src/PaymentLink.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Razorpay\Api;
4
+
5
+ use Requests;
6
+
7
+
8
+ class PaymentLink extends Entity
9
+ {
10
+ /**
11
+ * Creates Payment link .
12
+ *
13
+ * @param array $attributes
14
+ *
15
+ * @return PaymentLink
16
+ */
17
+ public function create($attributes = array())
18
+ {
19
+ $attributes = json_encode($attributes);
20
+
21
+ Request::addHeader('Content-Type', 'application/json');
22
+
23
+ return parent::create($attributes);
24
+ }
25
+
26
+ /**
27
+ * Fetches Payment link entity with given id
28
+ *
29
+ * @param string $id
30
+ *
31
+ * @return PaymentLink
32
+ */
33
+ public function fetch($id)
34
+ {
35
+ return parent::fetch($id);
36
+ }
37
+
38
+ /**
39
+ * Fetches multiple Payment link with given query options
40
+ *
41
+ * @param array $options
42
+ *
43
+ * @return Collection
44
+ */
45
+ public function all($options = array())
46
+ {
47
+ return parent::all($options);
48
+ }
49
+
50
+ /**
51
+ * Cancels Payment link
52
+ *
53
+ * @return PaymentLink
54
+ */
55
+ public function cancel()
56
+ {
57
+ $url = $this->getEntityUrl() . $this->id . '/cancel';
58
+
59
+ return $this->request(Requests::POST, $url);
60
+ }
61
+
62
+ public function edit($attributes = array())
63
+ {
64
+ $relativeUrl = $this->getEntityUrl() . $this->id;
65
+
66
+ $attributes = json_encode($attributes);
67
+
68
+ Request::addHeader('Content-Type', 'application/json');
69
+
70
+ return $this->request('PATCH', $relativeUrl, $attributes);
71
+ }
72
+
73
+ /**
74
+ * Send/re-send notification with short url by given medium
75
+ *
76
+ * @param $medium - sms|email
77
+ *
78
+ * @return array
79
+ */
80
+ public function notifyBy($medium)
81
+ {
82
+ $url = $this->getEntityUrl() . $this->id . '/notify_by/' . $medium;
83
+ $r = new Request();
84
+
85
+ return $r->request(Requests::POST, $url);
86
+ }
87
+
88
+ }
razorpay-sdk/src/QrCode.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Razorpay\Api;
4
+
5
+ class QrCode extends Entity
6
+ {
7
+ /**
8
+ * Create QR code
9
+ * @param array $attributes
10
+ * @return Entity|QrCode
11
+ */
12
+ public function create($attributes = array())
13
+ {
14
+ $relativeUrl = "payments/". $this->getEntityUrl() ;
15
+
16
+ return $this->request('POST', $relativeUrl, $attributes);
17
+ }
18
+
19
+ /**
20
+ * Fetch QR code details based QR id
21
+ * @param $id
22
+ * @return Entity|QrCode
23
+ */
24
+ public function fetch($id)
25
+ {
26
+ $relativeUrl = "payments/". $this->getEntityUrl(). $id ;
27
+
28
+ return $this->request('GET', $relativeUrl);
29
+ }
30
+
31
+ /**
32
+ * Close the QR code based on id
33
+ * @return Entity|QrCode
34
+ */
35
+ public function close()
36
+ {
37
+ $relativeUrl = "payments/{$this->getEntityUrl()}{$this->id}/close" ;
38
+
39
+ return $this->request('POST', $relativeUrl);
40
+ }
41
+
42
+ /**
43
+ * Fetch all QR code details
44
+ * @param array $options
45
+ * @return Entity|QrCode
46
+ */
47
+ public function all($options = array())
48
+ {
49
+ $relativeUrl = "payments/". $this->getEntityUrl();
50
+
51
+ return $this->request('GET', $relativeUrl, $options);
52
+ }
53
+
54
+ /**
55
+ * Fetch payments made to a QR Code based on QR id
56
+ * @param array $options
57
+ * @return Entity|QrCode
58
+ */
59
+ public function fetchAllPayments($options = array())
60
+ {
61
+ $relativeUrl = "payments/{$this->getEntityUrl()}{$this->id}/payments" ;
62
+
63
+ return $this->request('GET', $relativeUrl, $options);
64
+ }
65
+
66
+ }
razorpay-sdk/src/Refund.php CHANGED
@@ -21,4 +21,18 @@ class Refund extends Entity
21
  {
22
  return parent::all($options);
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
21
  {
22
  return parent::all($options);
23
  }
24
+
25
+ public function edit($attributes = array())
26
+ {
27
+ $url = $this->getEntityUrl() . $this->id;
28
+
29
+ return $this->request('PATCH', $url, $attributes);
30
+ }
31
+
32
+ public function refund($options = array())
33
+ {
34
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/refund';
35
+
36
+ return $this->request('POST', $relativeUrl, $options);
37
+ }
38
  }
razorpay-sdk/src/Request.php CHANGED
@@ -26,7 +26,7 @@ class Request
26
  * @var array
27
  */
28
  protected static $headers = array(
29
- 'Razorpay-API' => 1
30
  );
31
 
32
  /**
@@ -34,6 +34,7 @@ class Request
34
  * @param string $method HTTP Verb
35
  * @param string $url Relative URL for the request
36
  * @param array $data Data to be passed along the request
 
37
  * @return array Response data in array format. Not meant
38
  * to be used directly
39
  */
@@ -48,13 +49,12 @@ class Request
48
  $options = array(
49
  'auth' => array(Api::getKey(), Api::getSecret()),
50
  'hook' => $hooks,
51
- 'timeout' => 60,
52
  );
53
-
54
  $headers = $this->getRequestHeaders();
55
 
56
- $response = Requests::request($url, $headers, $data, $method, $options);
57
-
58
  $this->checkErrors($response);
59
 
60
  return json_decode($response->body, true);
@@ -157,8 +157,9 @@ class Request
157
  {
158
  $uaHeader = array(
159
  'User-Agent' => $this->constructUa()
 
160
  );
161
-
162
  $headers = array_merge(self::$headers, $uaHeader);
163
 
164
  return $headers;
26
  * @var array
27
  */
28
  protected static $headers = array(
29
+ 'Razorpay-API' => 1
30
  );
31
 
32
  /**
34
  * @param string $method HTTP Verb
35
  * @param string $url Relative URL for the request
36
  * @param array $data Data to be passed along the request
37
+ * @param array $additionHeader headers to be passed along the request
38
  * @return array Response data in array format. Not meant
39
  * to be used directly
40
  */
49
  $options = array(
50
  'auth' => array(Api::getKey(), Api::getSecret()),
51
  'hook' => $hooks,
52
+ 'timeout' => 60
53
  );
54
+
55
  $headers = $this->getRequestHeaders();
56
 
57
+ $response = Requests::request($url, $headers, $data, $method, $options);
 
58
  $this->checkErrors($response);
59
 
60
  return json_decode($response->body, true);
157
  {
158
  $uaHeader = array(
159
  'User-Agent' => $this->constructUa()
160
+
161
  );
162
+
163
  $headers = array_merge(self::$headers, $uaHeader);
164
 
165
  return $headers;
razorpay-sdk/src/Settlement.php CHANGED
@@ -7,9 +7,21 @@ namespace Razorpay\Api;
7
  */
8
  class Settlement extends Entity
9
  {
 
 
 
 
 
 
 
 
 
 
 
 
10
  /**
11
  * Fetch single settlement entity
12
- * @param string $id
13
  * @return Settlement
14
  */
15
  public function fetch($id)
@@ -19,7 +31,7 @@ class Settlement extends Entity
19
 
20
  /**
21
  * Get all settlements according to options
22
- * @param array $options
23
  * @return Collection
24
  */
25
  public function all($options = array())
@@ -38,5 +50,38 @@ class Settlement extends Entity
38
 
39
  return $this->request('GET', $relativeUrl, $options);
40
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
 
7
  */
8
  class Settlement extends Entity
9
  {
10
+ /**
11
+ * create Ondemand Settlemententity
12
+ * @param array $attributes
13
+ * @return Settlement
14
+ */
15
+ public function createOndemandSettlement($attributes = array())
16
+ {
17
+ $relativeUrl = $this->getEntityUrl() ."ondemand" ;
18
+
19
+ return $this->request('POST', $relativeUrl, $attributes);
20
+ }
21
+
22
  /**
23
  * Fetch single settlement entity
24
+ * @param string $id
25
  * @return Settlement
26
  */
27
  public function fetch($id)
31
 
32
  /**
33
  * Get all settlements according to options
34
+ * @param array $options
35
  * @return Collection
36
  */
37
  public function all($options = array())
50
 
51
  return $this->request('GET', $relativeUrl, $options);
52
  }
53
+
54
+ /**
55
+ * Get Settlement Recon
56
+ * @param array $options
57
+ * @return array
58
+ */
59
+ public function settlementRecon($options = array())
60
+ {
61
+ $relativeUrl = $this->getEntityUrl() . 'recon/combined';
62
+
63
+ return $this->request('GET', $relativeUrl, $options);
64
+ }
65
+ /**
66
+ * fetch Ondemand Settlement by Id
67
+ * @param string $id
68
+ * @return array
69
+ */
70
+ public function fetchOndemandSettlementById()
71
+ {
72
+ $relativeUrl = $this->getEntityUrl(). "ondemand/" . $this->id ;
73
+
74
+ return $this->request('GET', $relativeUrl);
75
+ }
76
+ /**
77
+ * fetch all Ondemand Settlement
78
+ * @return array
79
+ */
80
+ public function fetchAllOndemandSettlement()
81
+ {
82
+ $relativeUrl = $this->getEntityUrl(). "ondemand/";
83
+
84
+ return $this->request('GET', $relativeUrl);
85
+ }
86
  }
87
 
razorpay-sdk/src/Subscription.php CHANGED
@@ -32,4 +32,59 @@ class Subscription extends Entity
32
 
33
  return $this->request('POST', $relativeUrl, $attributes);
34
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
32
 
33
  return $this->request('POST', $relativeUrl, $attributes);
34
  }
35
+
36
+ /**
37
+ * Create a Registration Link
38
+ * @param array $attributes
39
+ * @return array
40
+ */
41
+ public function createSubscriptionRegistration($attributes = array())
42
+ {
43
+ $relativeUrl = 'subscription_registration/auth_links';
44
+
45
+ return $this->request('POST', $relativeUrl, $attributes);
46
+ }
47
+
48
+ public function update($attributes = array())
49
+ {
50
+ $relativeUrl = $this->getEntityUrl() . $this->id;
51
+
52
+ return $this->request('PATCH', $relativeUrl, $attributes);
53
+ }
54
+
55
+ public function pendingUpdate()
56
+ {
57
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/retrieve_scheduled_changes';
58
+
59
+ return $this->request('GET', $relativeUrl, null);
60
+ }
61
+
62
+ public function cancelScheduledChanges()
63
+ {
64
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/cancel_scheduled_changes';
65
+
66
+ return $this->request('POST', $relativeUrl, null);
67
+ }
68
+
69
+ public function pause($attributes = array())
70
+ {
71
+ $relativeUrl = $this->getEntityUrl() . $this->id.'/pause';
72
+
73
+ return $this->request('POST', $relativeUrl, $attributes);
74
+ }
75
+
76
+ public function resume($attributes = array())
77
+ {
78
+ $relativeUrl = $this->getEntityUrl() . $this->id.'/resume';
79
+
80
+ return $this->request('POST', $relativeUrl, $attributes);
81
+ }
82
+
83
+ public function deleteOffer($offerId)
84
+ {
85
+ $relativeUrl = $this->getEntityUrl() . $this->id.'/'.$offerId;
86
+
87
+ return $this->request('DELETE', $relativeUrl);
88
+ }
89
+
90
  }
razorpay-sdk/src/Utility.php CHANGED
@@ -24,10 +24,20 @@ class Utility
24
 
25
  $payload = $paymentId . '|' . $subscriptionId;
26
  }
 
 
 
 
 
 
 
 
 
 
27
  else
28
  {
29
  throw new Errors\SignatureVerificationError(
30
- 'Either razorpay_order_id or razorpay_subscription_id must be present.');
31
  }
32
 
33
  $secret = Api::getSecret();
24
 
25
  $payload = $paymentId . '|' . $subscriptionId;
26
  }
27
+ else if (isset($attributes['razorpay_payment_link_id']) === true)
28
+ {
29
+ $paymentLinkId = $attributes['razorpay_payment_link_id'];
30
+
31
+ $paymentLinkRefId = $attributes['razorpay_payment_link_reference_id'];
32
+
33
+ $paymentLinkStatus = $attributes['razorpay_payment_link_status'];
34
+
35
+ $payload = $paymentLinkId . '|'. $paymentLinkRefId . '|' . $paymentLinkStatus . '|' . $paymentId;
36
+ }
37
  else
38
  {
39
  throw new Errors\SignatureVerificationError(
40
+ 'Either razorpay_order_id or razorpay_subscription_id or razorpay_payment_link_id must be present.');
41
  }
42
 
43
  $secret = Api::getSecret();
razorpay-sdk/src/VirtualAccount.php CHANGED
@@ -21,19 +21,37 @@ class VirtualAccount extends Entity
21
 
22
  public function close()
23
  {
24
- $relativeUrl = $this->getEntityUrl() . $this->id;
25
 
26
- $data = array(
27
- 'status' => 'closed'
28
- );
29
 
30
- return $this->request('PATCH', $relativeUrl, $data);
31
  }
32
 
33
- public function payments()
34
  {
35
  $relativeUrl = $this->getEntityUrl() . $this->id . '/payments';
36
 
37
- return $this->request('GET', $relativeUrl);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
  }
21
 
22
  public function close()
23
  {
24
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/close';
25
 
 
 
 
26
 
27
+ return $this->request('POST', $relativeUrl);
28
  }
29
 
30
+ public function payments($options = array())
31
  {
32
  $relativeUrl = $this->getEntityUrl() . $this->id . '/payments';
33
 
34
+ return $this->request('GET', $relativeUrl, $options);
35
+ }
36
+
37
+ public function addReceiver($attributes = array())
38
+ {
39
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/receivers';
40
+
41
+ return $this->request('POST', $relativeUrl, $attributes);
42
+ }
43
+
44
+ public function addAllowedPayer($attributes = array())
45
+ {
46
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/allowed_payers';
47
+
48
+ return $this->request('POST', $relativeUrl, $attributes);
49
+ }
50
+
51
+ public function deleteAllowedPayer($allowedPlayerId)
52
+ {
53
+ $relativeUrl = $this->getEntityUrl() . $this->id . '/allowed_payers/'.$allowedPlayerId;
54
+
55
+ return $this->request('DELETE', $relativeUrl);
56
  }
57
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: razorpay
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 5.7.2
6
- Stable tag: 2.8.1
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -41,6 +41,11 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
44
  = 2.8.1 =
45
  * Bug fix in custom woocommerce order number issue.
46
  * Tested up to Woocommerce 5.9.0
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 5.7.2
6
+ Stable tag: 2.8.2
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
41
 
42
  == Changelog ==
43
 
44
+ = 2.8.2 =
45
+ * Updated Razorpay SDK.
46
+ * Added subscription webhook events.
47
+ * Tested up to Woocommerce 5.9.0
48
+
49
  = 2.8.1 =
50
  * Bug fix in custom woocommerce order number issue.
51
  * Tested up to Woocommerce 5.9.0
woo-razorpay.php CHANGED
@@ -3,8 +3,8 @@
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
- * Version: 2.8.1
7
- * Stable tag: 2.8.1
8
  * Author: Team Razorpay
9
  * WC tested up to: 5.9.0
10
  * Author URI: https://razorpay.com
@@ -261,6 +261,8 @@ function woocommerce_razorpay_init()
261
  /* adds route enable form fields to the defaultFormFields */
262
  $defaultFormFields = apply_filters( 'route_module_setting_fields', $defaultFormFields );
263
 
 
 
264
  foreach ($defaultFormFields as $key => $value)
265
  {
266
  if (in_array($key, $this->visibleSettings, true))
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
+ * Version: 2.8.2
7
+ * Stable tag: 2.8.2
8
  * Author: Team Razorpay
9
  * WC tested up to: 5.9.0
10
  * Author URI: https://razorpay.com
261
  /* adds route enable form fields to the defaultFormFields */
262
  $defaultFormFields = apply_filters( 'route_module_setting_fields', $defaultFormFields );
263
 
264
+ do_action_ref_array( 'setup_extra_setting_fields', array( &$defaultFormFields ) );
265
+
266
  foreach ($defaultFormFields as $key => $value)
267
  {
268
  if (in_array($key, $this->visibleSettings, true))