API ReferenceIntegrationsKnowledge Base

Sample Application

Note:
Download the Razorpay PHP Sample App from here.
Ensure you are using the latest version of the SDK. You can download the latest version of the SDK from GitHub.

Get Started#

Download the Razorpay PHP Sample App from here.

Open the index.html file on your browser to see a demo of the php-test app. Follow the steps below:

  1. Copy the contents of config.php.sample to config.php.
  2. Enter your <key_id> and <key_secret> in the config.php file.
  3. If you would like a currency other than INR, change the displayCurrency parameter to whatever currency you would like.
  4. Watch the demo to test out automatic or manual checkout.

An easy way to test this is to run php -S localhost:8000 in the root directory and open http://localhost:8000 in your browser.

Standard Checkout Integration#

The Standard or Automatic Checkout method provides a default Pay with Razorpay button that invokes the checkout form. The checkout form options are passed as data attributes inside a <script> tag. You can add any additional, hidden or visible, fields to the form. These fields will be submitted along with the form.

To integrate the automatic checkout:

  1. Create a checkout form using our Standard Checkout Integration.
  2. Accept the razorpay_payment_id parameter in the form submission.
  3. Run the capture code to capture the payment.

Note:
If you are re-using this as your final code, please ensure you:

  • Edit the key_id inside automatic-checkout/index.html. Use the live keys when using the application to accept live payments. Click here to learn more about how to generate keys.
  • Edit the <key_id> and <key_secret> in automatic-checkout/charge.php.

Custom Checkout Integration#

In the Custom or Manual Checkout method, the Checkout form is invoked by the custom button on your site and the form options are passed as variables in a key-value pair format within a <script> tag. Once the payment is successfully authorized, a handler function is called automatically. This function returns a response object containing razorpay_payment_id. This handler function must be called back to your server-side to capture the payment.

To integrate the manual checkout:

  1. Create an order using razorpay orders API.
  2. Accept the razorpay_payment_id parameter and razorpay_signature in the form submission.
  3. Store the razorpay_order_id as a sessions variable.
  4. Verify the signature emitted from our server based on the algorithm given here.

Note:
If you are re-using this as your final code, please ensure you:

  • Edit the <key_id> and <key_secret> inside orders-api/order.php.
  • Edit the <key_secret> in orders-api/verify-signature.php.