Skip to content

v1.0.0

Compare
Choose a tag to compare
@NagariaHussain NagariaHussain released this 13 May 07:54
· 23 commits to main since this release

Plug-n-play Razorpay Integration for your Frappe apps and sites.

Configuration

Open up Razorpay Settings and add your API keys:

CleanShot 2024-05-13 at 12 16 29@2x

You can also toggle guest checkout from here. If you disable guest checkout, the API endpoints for working with Razorpay orders (more soon) will need authentication.

Accepting Payments / Checkout from Frontend

CleanShot.2024-05-13.at.13.15.59.mp4

The backend is already ready ⚡. For the frontend, I have included 2 ready to go examples:

  1. Portal Page with VanillaJS (source)
  2. FrappeUI Page with Vue Headless component (source)

The nice thing about the second example is that you can just copy the RazorpayHeadlessCheckout (source) component to your FrappeUI based frontend and it will just work!

All of the payment tracking happens in the Razorpay Order DocType:

CleanShot 2024-05-13 at 12 31 26@2x

You can hook into document lifecycle events (before_insert, on_update, etc.) of this DocType to extend/add your own logic. Here is an example using doc_events hook in our custom app:

# hooks.py
#--------

doc_events = {
    "Razorpay Order": {
        "on_update": "path.to.method.process_payment_update"
    }
}

# method
def process_payment_update(doc, event):
    if doc.has_value_changed("status") and doc.status == "Paid":
        meta_data = frappe.parse_json(doc.meta_data)
        # create tickets, sales invoice, etc.
        # ...

You can do the same thing using Server Script (Document Event) as well.