I am required to redirect a user to an external payment gateway, from a visualforce page. Apart from just the redirection, sensitive information is to be passed to the external gateways, and using JWT.

As a proof of concept, I would need to understand how to store information in a JWT format in Saelsforce, and pass that JWT to an external website while redirecting.

  • 5
    Are you certain you have your terminology correct here? As far as I know, JWTs themselves don't do any redirection. Their primary use is in OAuth (to authenticate with some system). The response you get could include a url to redirect to, but using JWT (or any OAuth flow, really) generally means that you're going to perform a request on your user's behalf (so redirecting your user wouldn't make much sense).
    – Derek F
    Jul 5, 2021 at 12:20
  • 4
    In short: You need to re-evaluate the requirements you were given, or provide more information.
    – Derek F
    Jul 5, 2021 at 12:21
  • @DerekF, Yes actually. So, to sum up, ,the requirement is to redirect to a payment gateway. But, the information that we need to pass to the payment gateway, should be in a JWT format. I am completely new to JWT, and not aware about how can I embed information in JWT and pass information to the external site where I am redirecting to. Its all from Salesforce to outside link. Jul 7, 2021 at 7:14
  • 1
    Is this payment gateway a well known gateway with documentation that you can point us to? Jul 7, 2021 at 11:37

1 Answer 1


The information about how to store the information in a JWT in Salesforce is provided in the documentation of the JWT class here.

You may find the JWTBearerTokenExchange and JWS classes useful as well for your purpose

This video may be helpful for you too: https://www.youtube.com/watch?v=cViU2-xVscA

You must log in to answer this question.

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