Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Integrating Stripe Checkout with Apex 20

BRB91Aug 17 2020 — edited Aug 19 2020

Hi,

I am trying to intergrate the Stripe payment gateway with Apex 20 following Trent's 2016 blog: https://apextips.blogspot.com/2016/02/accepting-payments-with-stripe-in-apex.html

I can do what Trent has done but since the post was written, Stripe has upgraded to Strong Customer Authentication which means that this method of integrating Stripe is now out of date.

I haven't been able to find anyone else that has managed to intergrate the newest version of Stripe Checkout in apex so have tried to figure it out by myself and have gotten stuck with the apex_web_service.make_rest_request call at this point. - https://stripe.com/docs/payments/checkout/accept-a-payment#create-checkout-session

The problem I have is that I don't know how to pass values in as an array as needed for "payment_method_types" and isnide "line_items". Does anyone know how to achieve this?

Sample Code below

The ouput (I believe) needs to be in this format

{

  payment_method_types: ['card'],

  line_items: [{

    price_data: {

      currency: 'gbp',

      unit_amount: 'p_amount',

    },

    quantity: 1,

  }],

  mode: 'payment'',

  success_url: ''redacted'',

  cancel_url: ''redacted'',

}

My procedure generating the API Call is below

    function create_checkout_session (

      p_amount in NUMBER

     ,p_currency in varchar2 default 'gbp'

    ) return varchar2

    as

   

      l_session_resp CLOB;

     

    begin

 

      l_session_resp := 

        apex_web_service.make_rest_request(

            p_url         => 'https://api.stripe.com/v1/checkout/sessions'

           ,p_http_method => 'POST'

           ,p_username    => g_secret_token

           ,p_body        => 'payment_method_types=card;line_items[price_data[currency=gbp;line_items[price_data[unit_amount=112;line_items[quantity=1;mode=payment;success_url=redacted;cancel_url=redacted'

        );

      apex_json.parse(l_session_resp);

       

      return apex_json.get_varchar2(l_session_resp);

   

    end create_checkout_session;

Thanks, BRB

Comments
Post Details
Added on Aug 17 2020
10 comments
1,703 views