Stripe subscriptions integration

Stripe subscriptions integration

  

Has anyone ever worked with stripe payment integration in the outsystems? 

I am working on integrating it in my project as: I would make a customer enter their credit card info into stripe checkout(https://stripe.com/docs/checkout), the token that this checkout will return, I will use that to create a customer(https://stripe.com/docs/api/curl#create_customer)  and then create a plan (https://stripe.com/docs/api/java#plans), and then create a subscription for a customer to the plan created earlier (https://stripe.com/docs/api/java#subscriptions). 

But I am stuck on the very first step of storing the customer's credit card information, as I want to implement stripe checkout for customer to enter their credit card to prevent PCI Compliance issues and in the code for generating the payment button, first issue is that is it even allowed to create a form using an expression with following code:

<form action="/your-server-side-code" method="POST">
<script
  src="https://checkout.stripe.com/checkout.js" class="stripe-button"
  data-key="pk_test_6pRNASCoBOKtIshFeQd4XMUh"
  data-amount="2000"
  data-name="Stripe.com"
  data-description="2 widgets"
  data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
  data-locale="auto"
  data-zip-code="true">
</script>
</form>

and if yes, what would I give in value for action? I've implemented this before in .Net MVC application and there I gave it value of @url.action("checkout") and here it went to my 'checkout' controller action method, but how would I do something like this in Outsystems(Java stack)?


or should I use this: https://stripe.com/docs/checkout#integration-custom, and if I use this, then how would I pass the token to my server side logic? Store it in a hidden field from javascript and then access that hidden field? Is that even good practice?


Thanks,

Gurvinder

Solution

Hi Gurvinder,


The second option looks better fitted for an OutSystems application.
As for how to get the token back to your server side, a cleaner alternative to use the hidden button is to use a block from RichWidgets called FakeNotifyWidget. See the block description on how to use it.


Regards,
João Rosado

Solution

Hi João,


I've implemented the button with second option, but I am little confused about how would I access the Id of FakeNotifyWidget from the Page level javascrip and call NotifyWidgetGetMessage() action from there. Can you please look at the attached oml and help me with that?


Thanks,

Gurvinder

You can't do it from the page level javascript.

What I recommend you to do is a the page level to define a function to initalize anything you need and then call that function from an expression in your page with escaped content set to No. That way you will have access to both the id of the button and the FakeNotifyWidget to pass on your javascript.

(btw; remember that to access the .Id of a widget you need to give it a name)

Hi João,

I've implemented it the way you said, can you please have a look at the attached oml to check if I am doing it right?

Thanks!

Hi,


It looks good.

Just a minor point that I recommend as good practice (in this particular case it doen't make a difference).

When referencing widgets in a script try to place the script after the correspondent widget. In your case doesn't make a difference because FakeNotifyWidget is only called later on the callback.


Regards,
João Rosado