Skip to main content

List all Razorpay Orders in Oracle APEX

   

Razorpay Integration with Oracle APEX

The objective of this blog post is to show you how to list all Razorpay Orders (Specific to particular account) in Oracle APEX using APEX_WEB_SERVICE API.

Before we get into the topic, let's take a look at the following link, which will help you to understand how Razorpay payment gateway can be done in Oracle APEX.


List all Razorpay Orders

Below are steps involved to get this process done.

1) Get Razorpay API Keys

2) Get Razorpay Fetch Orders API End Point

3) Invoke 
Razorpay Fetch Orders API with Postman

4) Create a Sample Application

5) List all 
Razorpay Orders in the form of Report using APEX_WEB_SERVICE API

I) Get Razorpay API Keys

API key is a combination of the key_id and key_secret and is required to make any API request to Razorpay. You also have to implement the API key in your code as part of your integration process.

Step 1: Log into your Dashboard with appropriate credentials.

Step 2: Select the mode (Test or Live) which you want to generate the API Key.

Step 3: Navigate to Settings --> API Keys --> Generate Key to generate key for the selected mode.

The key_id and key_secret appear on a pop-up page.

II) Get Razorpay Fetch Orders API End Point

Step 1: You can get the end point from this link (Orders API)

Step 2: Search text "Fetch Orders", then you can find the fetch orders end point.

curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET]\

-X GET https://api.razorpay.com/v1/orders

III) Invoke Razorpay Fetch Orders API with Postman

Step 1: Setup Authorization (Basic Authentication) and click "Send" button to call the API.

Username: API Key Id 
Password: API Key Secrete



Note: When status code is between 200 and 299, then API is working fine.

IV) Create a Sample Application

V) List all Razorpay Orders in the form of Report using APEX_WEB_SERVICE API

Step 1: Create a new blank page.

Step 2: Create a new region on the page (Position: Content Body). In the Property Editor, apply the following changes:

Under Identification:
     For Title - enter List Razorpay Orders
     For Type- select Classical Report/Interactive Report
Under Source:
     For Location - Local Database
     For Type - select SQL Query
     For SQL Query - Copy and paste below query.

SQL Query:

SELECT
          id,
          entity,
          amount,
          amount_paid,
          amount_due,
          currency,
          receipt,
          offer_id,
          status,
          attempts
        FROM dual, 
             json_table (apex_web_service.make_rest_request(p_url => 'https://api.razorpay.com/v1/orders', 
                                                           p_http_method => 'GET',
                                                           p_username => <<Your Razorpay API Key Id>>,
                                                           p_password => <<Your Razorpay API Key Secret>>),
                        '$.items[*]' COLUMNS(id VARCHAR2(4000) path '$.id',
                                             entity VARCHAR2(4000) path '$.entity',
                                             amount NUMBER path '$.amount',
                                             amount_paid NUMBER path '$.amount_paid',
                                             amount_due NUMBER path '$.amount_due',
                                             currency VARCHAR2(4000) path '$.currency',
                                             receipt VARCHAR2(4000) path '$.receipt',
                                             offer_id VARCHAR2(4000) path '$.offer_id',
                                             status VARCHAR2(4000) path '$.status',
                                             attempts VARCHAR2(4000) path '$.attempts'))
WHERE 1=1
ORDER BY id ASC NULLS LAST;


Step 3: Report created and it will list all Razorpay Orders.

API Success Response:

{ "entity":"collection", "count":2, "items":[ { "id":"order_EKzX2WiEWbMxmx", "entity":"order", "amount":1234, "amount_paid":0, "amount_due":1234, "currency":"INR", "receipt":"Receipt No. 1", "offer_id":null, "status":"created", "attempts":0, "notes":[ ], "created_at":1582637108 }, { "id":"order_EAI5nRfThga2TU", "entity":"order", "amount":100, "amount_paid":0, "amount_due":100, "currency":"INR", "receipt":"Receipt No. 1", "offer_id":null, "status":"created", "attempts":0, "notes":[ ], "created_at":1580300731 } ] }

Output:


The demo is here.

That's it. Happy APEXing!

Related Posts:

References/Credits:

Comments

Popular posts from this blog

Printing Page Numbers in RTF Template [Oracle BI Publisher]

Here I am giving an example to print the page numbers dynamically in the RTF (Rich Text Format) template. Step 1:  Go to page footer and copy and paste the below script. Page |  <?fo:page-number?>  of  <?fo:page-number-citation:xdofo:lastpage-joinseq?> <fo:page-number> :   This is the object, which is used to represent the current page-number. <?fo:page-number-citation:xdofo:lastpage-joinseq?> :  This is the syntax, which is used to represent the total number of pages. Step 2:  Load the XML and preview the result. Output: That's it. References: fo:page-number Printing Page Number Code in Oracle XMLP RTF Template

Oracle Application Express Views (APEX)

Application Express Views Search SELECT * FROM apex_dictionary WHERE column_id = 0; View Comment Parent View APEX_APPLICATIONS Applications defined in the current workspace or database user. APEX_WORKSPACES APEX_APPLICATION_ALL_AUTH All authorization schemes for all components by Application APEX_APPLICATIONS

Save Selected Interactive Grid Records into a Collection - Oracle APEX

Here I am giving an example to save selected interactive grid records into a oracle apex collection. Step 1: Create a new blank page. Note: Mine was page 20. You will need to update reference to " P20 " with your page number if it's different. Step 2: Create a new interactive grid report region to the page using below query. Set Static Id "EmpDetails" to the region. SELECT  *     FROM   ( SELECT  emp . empno ,                emp . ename ,                emp . JOB ,                dept . dname department ,                dept . loc  LOCATION ,                mgr . ename  manager ,                emp . hiredate ,                 nvl ( emp . sal , 0 )  salary ,                 nvl ( emp . comm , 0 )  commission            FROM  eba_demo_chart_emp emp ,                eba_demo_chart_dept dept ,                eba_demo_chart_emp mgr           WHERE  emp . deptno = dept . deptno             AND  emp . mgr      = mgr . empno  ( + )           ORDER   BY  emp . ename