File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,19 @@ function createRazorpayOrderId(array $params)
182182 return $ razorpayOrderId ;
183183}
184184
185+ function getExistingOrderDetails ($ params , $ razorpayOrderId )
186+ {
187+ try
188+ {
189+ $ api = getRazorpayApiInstance ($ params );
190+ return $ api ->order ->fetch ($ razorpayOrderId );
191+ }
192+ catch (Exception $ e )
193+ {
194+ logTransaction (razorpay_MetaData ()['DisplayName ' ], $ e ->getMessage (), "Unsuccessful - Fetch existing order failed " );
195+ }
196+
197+ }
185198/**
186199 * Payment link.
187200 * Required by third party payment gateway modules only.
@@ -229,7 +242,17 @@ function razorpay_link($params)
229242 }
230243 else
231244 {
232- $ razorpayOrderId = $ existingRazorpayOrderId ;
245+ $ existingOrder = getExistingOrderDetails ($ params , $ existingRazorpayOrderId );
246+
247+ if (isset ($ existingOrder ) === true and
248+ ((int )$ existingOrder ['amount ' ]) !== ((int )$ amount ))
249+ {
250+ $ razorpayOrderId = createRazorpayOrderId ($ params );
251+ }
252+ else
253+ {
254+ $ razorpayOrderId = $ existingRazorpayOrderId ;
255+ }
233256 }
234257
235258 return <<<EOT
@@ -256,4 +279,4 @@ function razorpay_link($params)
256279 ></script>
257280</form>
258281EOT ;
259- }
282+ }
You can’t perform that action at this time.
0 commit comments