PluginProbe ʕ •ᴥ•ʔ
Razorpay for WooCommerce / trunk
Razorpay for WooCommerce vtrunk
4.8.7 4.8.6 4.8.5 4.8.4 trunk 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.0-beta 1.6.1 1.6.2 1.6.3 1.6.5 2.0.0 2.0.1 2.1.0 2.2.0 2.3.0 2.3.1 2.3.2 2.4.0 2.4.1 2.4.2 2.4.3 2.5.0 2.6.0 2.7.0 2.7.1 2.7.2 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 3.0.0 3.0.1 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.3.0 3.4.0 3.4.1 3.5.0 3.5.1 3.6.0 3.7.0 3.7.1 3.7.2 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.0.1 4.1.0 4.2.0 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.4.0 4.4.1 4.4.2 4.4.3 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3
woo-razorpay / includes / api / auth.php
woo-razorpay / includes / api Last commit date
api.php 2 months ago auth.php 6 months ago cart.php 6 months ago coupon-apply.php 6 months ago coupon-get.php 6 months ago giftcard-apply.php 1 year ago order.php 8 months ago prepay-cod.php 2 months ago save-abandonment-data.php 1 year ago shipping-info.php 1 year ago
auth.php
61 lines
1 <?php
2
3 /**
4 * custom auth to secure 1cc APIs
5 */
6
7 require_once __DIR__ . '/../../razorpay-sdk/Razorpay.php';
8 use Razorpay\Api\Errors;
9
10 function checkAuthCredentials()
11 {
12 return true;
13 }
14
15 /**
16 * Validate HMAC signature using Razorpay Webhook Secret.
17 * Expects header 'X-Razorpay-Signature' computed over raw request body with HMAC-SHA256.
18 *
19 * @param WP_REST_Request $request
20 * @return bool|WP_Error
21 */
22 function checkHmacSignature($request)
23 {
24 $signature = '';
25 if (isset($_SERVER['HTTP_X_RAZORPAY_SIGNATURE']))
26 {
27 $signature = sanitize_text_field($_SERVER['HTTP_X_RAZORPAY_SIGNATURE']);
28 }
29
30 if (empty($signature))
31 {
32 return new WP_Error('rest_forbidden', __('Signature missing'), array('status' => 403));
33 }
34
35 $payload = file_get_contents('php://input');
36
37 // Retrieve 1CC signing HMAC secret saved at plugin load time
38 $secret = get_option('rzp1cc_hmac_secret');
39
40 if (empty($secret))
41 {
42 return new WP_Error('rest_forbidden', __('Secret not configured'), array('status' => 403));
43 }
44
45 // Verify using Razorpay SDK (same as webhook)
46 try
47 {
48 $rzp = new WC_Razorpay(false);
49 $api = $rzp->getRazorpayApiInstance();
50 $api->utility->verifySignature($payload, $signature, $secret);
51 }
52 catch (Errors\SignatureVerificationError $e)
53 {
54 return new WP_Error('rest_forbidden', __('Invalid signature'), array('status' => 403));
55 }
56
57 return true;
58 }
59
60 ?>
61