Stripe Payment Gateway in Oracle APEX
Step-by-Step Guide: Stripe Payment Gateway in Oracle APEX
Step 1: Create a Stripe Developer Account
First, create a Stripe developer account using the official Stripe documentation link:
👉 https://docs.stripe.com/development
After signing up, log in to the Stripe Dashboard.
Step 2: Get Stripe API Keys
From the Stripe Dashboard:
Navigate to Developers → API Keys
Copy:
Publishable Key
Secret Key
⚠️ Important: Keep the Secret Key confidential. Never expose it on the client side.
Step 3: Create a Blank Page in Oracle APEX
Create a Blank Page in your Oracle APEX application
Add the following page items:
Text Field – to enter the payment amount (e.g.,
P20_AMOUNT)Button – to submit the payment (e.g.,
Submit)
Step 4: Create a Process After Submit
Create a Page Process with:
Type: PL/SQL Code
Execution Point: After Submit
Paste the following code:
DECLARE
l_response CLOB;
l_url VARCHAR2(4000);
l_amount NUMBER;
BEGIN
-- Convert rupees to paise
l_amount := :P20_AMOUNT * 100;
l_response := apex_web_service.make_rest_request(
p_url => 'https://api.stripe.com/v1/checkout/sessions',
p_http_method => 'POST',
p_username => 'sk_test_XXXXXXXXXXXXXXXXXXXXXXXX', -- Stripe secret key
p_body =>
'payment_method_types[]=card' ||
'&mode=payment' ||
'&line_items[0][price_data][currency]=inr' ||
'&line_items[0][price_data][product_data][name]=APEX Test Payment' ||
'&line_items[0][price_data][unit_amount]=' || l_amount ||
'&line_items[0][quantity]=1' ||
'&success_url=https://your-success-url' ||
'&cancel_url=https://your-cancel-url'
);
-- Extract checkout URL from response
l_url := json_value(l_response, '$.url');
-- Redirect to Stripe checkout page
apex_util.redirect_url(l_url);
END;
Step 5: Configure Keys and Redirect URLs
Replace the Stripe Secret Key in
p_usernameUpdate:
success_url→ Redirects after successful paymentcancel_url→ Redirects if payment is canceled
Step 6: Save and Run the Page
Save your page
Run the application
Enter the amount and click Submit
You will be redirected to the Stripe Checkout page to complete the payment


Comments
Post a Comment