Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.

Have an account? Sign In

Captcha Click on image to update the captcha.

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Tech Answered Logo Tech Answered Logo
Sign InSign Up

Tech Answered

Tech Answered Navigation

  • Home
  • Tutorials
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us
Home / Questions /Q 3842
Next
In Process
dynamicapps5
dynamicapps5

dynamicapps5

  • India
  • 127 Questions
  • 66 Answers
  • 2 Best Answers
  • 198 Points
View Profile
  • 0
dynamicapps5
Asked: January 8, 20222022-01-08T06:14:27+05:30 2022-01-08T06:14:27+05:30In: Programming Related

razorpay payment gateway integration in php, example code

  • 0

I am doing a eCommerce website and it’s almost done. I want to integrate razorpay gateway to website. How can I implement the razor pay integration code in PHP? Can  anyone showing an example code for integration of razor pay using php code?

how to integrate razor pay gatewayhow to integrate razor pay gateway with php coderazor payrazor pay gateway php code with examplerazor pay integration coderazor pay integration php code
  • 1
  • 2,385
  • 0
  • 0
Answer
Share
  • Facebook

    Related Questions

    • How to Add, Install SSL Certificate to Your Website
    • What are some key considerations when designing a logo for a company that will be used online and in print?
    • Image Gallery With Animations Using HTML And CSS Code
    • How to backup android phone to pc before factory reset
    • What part does content play in SEO, and what impact does it have on search engine rankings?
    • code for matrix multiplication in c
    • How to add scrolling text in Blogger

    1 Answer

    1. Swathi

      Swathi

      • India
      • 35 Questions
      • 35 Answers
      • 5 Best Answers
      • 153 Points
      View Profile
      Swathi
      2022-01-10T19:34:19+05:30Added an answer on January 10, 2022 at 7:34 pm

      Razorpay allows you to grow your business and power your finance. Razorpay is a user-friendly payment gateway that provides payment solutions in an easy way. To integrate Razorpay gateway in your e-commerce project using PHP, follow the below steps:

      Step 1: Create Razorpay Account

      Create a Razorpay account and generate KeyID and secret key. This is done by selecting the setting option->API key. Then it asks KeyID and secret key. 

      To test payment functionality let us keep creating the Razorpay account in Test mode. If you want to test in live mode then KYC is asked, so that KYC form filling should be completed and activation of your account will be done.

      This is done after account creation and in the Razorpay dashboard. To know the process of creating a Razorpay account, go through the below link.

      How to create an account on Razorpay?

      Step2: Update Razorpay config details:

      If we use “Test app” to integrate the Razorpay gateway, we need to update config.php with key ID and secret key from Razorpay.

      Step 3: Create a form with Item details.

      In index.php file, we will create HTML code with item details and customer details to send to perform payment. We have pay.php on action to handle the payment.<div class=”container”>
      <div class=”row”>
      <div class=”col-sm-12″>
      <h2>Example: Razorpay Payment Gateway Integration in PHP</h2>
      <br><br>
      <div class=”col-sm-4 col-lg-4 col-md-4″>
      <div class=”thumbnail”>
      <img src=”prod.gif” alt=””>
      <div class=”caption”>
      <h4 class=”pull-right”>₹49.99</h4>
      <h4><a href=”#”>My Test Product”</a></h4>
      <p>See more examples like this at <a target=”_blank” href=”https://www.phpzag.com/”>phpzag</a>.</p>
      </div>
      <form id=”checkout-selection” action=”pay.php” method=”POST”>
      <input type=”hidden” name=”item_name” value=”My Test Product”>
      <input type=”hidden” name=”item_description” value=”My Test Product Description”>
      <input type=”hidden” name=”item_number” value=”3456″>
      <input type=”hidden” name=”amount” value=”49.99″>
      <input type=”hidden” name=”address” value=”ABCD Address”>
      <input type=”hidden” name=”currency” value=”INR”>
      <input type=”hidden” name=”cust_name” value=”phpzag”>
      <input type=”hidden” name=”email” value=”test@phpzag.com”>
      <input type=”hidden” name=”contact” value=”9999999999″>
      <input type=”submit” class=”btn btn-primary” value=”Buy Now”>
      </form>
      </div>
      </div>
      </div>
      </div>
      </div>

      Step 4: Handle item details for payment.

      Step 5:Perform payment with Razorpay:

      We will include Razorpay API checkout.js and handle payment functionality. The sample Php code appears like this:

      <button id=”rzp-button1″ class=”btn btn-primary”>Pay with Razorpay</button>
      <script src=”https://checkout.razorpay.com/v1/checkout.js”></script>
      <form name=’razorpayform’ action=”verify.php” method=”POST”>
      <input type=”hidden” name=”razorpay_payment_id” id=”razorpay_payment_id”>
      <input type=”hidden” name=”razorpay_signature” id=”razorpay_signature” >
      </form>
      <script>
      var options = <?php echo $json?>;
      options.handler = function (response){
      document.getElementById(‘razorpay_payment_id’).value = response.razorpay_payment_id;
      document.getElementById(‘razorpay_signature’).value = response.razorpay_signature;
      document.razorpayform.submit();
      };
      options.theme.image_padding = false;
      options.modal = {
      ondismiss: function() {
      console.log(“This code runs when the popup is closed”);
      },
      escape: true,
      backdropclose: false
      };
      var rzp = new Razorpay(options);
      document.getElementById(‘rzp-button1’).onclick = function(e){
      rzp.open();
      e.preventDefault();
      }
      </script>

      I hope the above sample code might help you. You may also read:

      Do you need math for software engineering?

      • 2
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    More Questions

    • arunraj503

      How to Add, Install SSL Certificate to Your Website

    • EmmaScott

      What are some key considerations when designing a logo for

    • dynamicapps5

      Image Gallery With Animations Using HTML And CSS Code

    • arunraj503

      How to backup android phone to pc before factory reset

    • SEO_BRISK

      What part does content play in SEO, and what impact

    • glenn

      code for matrix multiplication in c

    • sita

      How to add scrolling text in Blogger

    • dynamicapps5

      how to solve error illegal start of expression in java

    Stats

    • Questions 1,992
    • Answers 2,102
    • Posts 12
    • Best Answers 73

    Related Questions

    • arunraj503

      How to Add, Install SSL Certificate to Your Website

    • EmmaScott

      What are some key considerations when designing a logo for a company

    • dynamicapps5

      Image Gallery With Animations Using HTML And CSS Code

    • arunraj503

      How to backup android phone to pc before factory reset

    • SEO_BRISK

      What part does content play in SEO, and what impact does it

    • glenn

      code for matrix multiplication in c

    • sita

      How to add scrolling text in Blogger

    • dynamicapps5

      how to solve error illegal start of expression in java

    Explore

    • Home
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help

    Footer

    Recent Comments

    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • AaronBlackburn on why can’t i find my message requests on instagram
    • shree on How to use philips citrus press juicer 25 watts Demo
    Ask A Question

    Archives

    Tags

    laptop buying guide (1) limit google news notifications (1) printer buying guide (1) stop google news notifications (1) turn off google news notifications (1)

    Social media

    © 2023 @ Techanswered.com.
    Terms, Privacy policy & Sitemap.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.