2

I created apex class with @RestResource. And @HttpPost method to use this code as Resource as the webhook URL, but the class is not invoking, please help here

CLASS:

@RestResource(urlMapping='/Razorpay/*')
global class WebhooK_for_RazorPay 
{
    
    @HttpPost
    global static void ResponseFromPaymentLInk()
    {
        
        
        RestRequest request = RestContext.request;
        system.debug('The request '+  request );
        RestResponse response = RestContext.response;
        system.debug('The response '+  response );
        
    }
     
}

Webhook URL:

https://techforceservices18-dev-ed.develop.my.site.com/services/apexrest/Razorpay

used in Razorpay

1
  • 2
    N.B. for a no-code solution for webhook processing in SFDC, checkout Streamscript
    – cropredy
    Commented Jun 19, 2023 at 23:02

2 Answers 2

1

You should add the permission to the apex class and every other resource needed (i.e. Object Permission, Field-Level Security) to the Guest User.
To open the Guest User profile start from Setup, search for "Sites and" and click on "Sites", then on your site's name and on Public Access Settings button.
In the profile page you should click on Enabled Apex Class Access then on Edit button, add the needed classes and click Save.

Instead of modify the profile, you could create a Permission Set and add it to the Guest User (From the profile page there is a View users button). I think this would be a better approach due to the end of life of permissions on profiles, moreover permission sets can be added to managed and unmanaged package.

7
  • i have given the access to the profile ,but it is not access the apex code
    – Mahesh
    Commented Jun 19, 2023 at 9:23
  • 1
    @Mahesh What happens if you try to call that endpoint via Postman? Could you please post the error message?
    – RubenDG
    Commented Jun 19, 2023 at 9:35
  • NO ERROR while Interacting from the Postman.
    – Mahesh
    Commented Jun 20, 2023 at 11:03
  • @Mahesh Do you call https://techforceservices18-dev-ed.develop.my.site.com/services/apexrest/Razorpay without authentication header? Keep in mind that if you authenticate yourself, you are not testing the endpoint as a guest user.
    – RubenDG
    Commented Jun 20, 2023 at 13:50
  • ok. Understood . I Will test again
    – Mahesh
    Commented Jun 21, 2023 at 7:22
0

I gave access to the "Guest User" profile for the class

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .