Where to add 3DS parameters in the payment request - ruby-on-rails

We are using spree e-commerce platform to build our application which in ruby on rails framework. We wanted to just implement the 3D secure payment method into the existing payment option available with us. The adyen payment gateway is already implemented in the application, just wanted to know how to achieve 3d secure payment processing.

I know this is a later response but for those who end up here this may help.
I'm currently developing an integration for Mangopay in Spree so I don't have the full answer, but in order to make 3Ds to work you'll have to make some changes:
change the update method on checkout controller to redirect to 3ds url once the payment is created
change the payment processing logic in spree to start_processing instead of complete the payment once you get a successful response from adyen (first stage of 3DS)
change the adyen gateway to support 3DS (as far as I know the implementation in ActiveMerchant does not add anything for 3Ds, but I just made a quick look)
add some route, controller and action to process the callback from 3DS and update spree payment and order acordingly
Here you can find useful information:
Spree Mollie Gateway Extension they implement Mollie Gateway with 3DS support
Active Merchant Gem
Spree Extension Tutorial
Feel free to contact me if you have further questions

Related

Test/Sandbox Environment for Google My Business API

I just started with using Google My Business API and was able to perform the get operations just to verify that my Oauth setup is right. Now I want to add a location using the post method for GMB Add location API but before I push my code to production I want to test out this request. Do we have any testing/sandbox environment for Google My Business API testing ?
For anyone coming here for reference I guess if you are using third party tools(Integromat/ Zapier) to make the API Call, the best way is to validate your request by passing in query parameter: validateOnly = True
According to their doc, this is not possible. please read more here

Rails and Razorpay Webhook setup

I am trying to setup Razorpay Webhook in rails. Have done other developments in rails but pricing is new to me. i already setup and tested Webhook in razorpay dashboard and used requestbin.com to get the payload results(JSON) as mentioned in this doc https://razorpay.com/docs/webhooks/
Now, should i create a new POST route and capture the payload results(JSON) in controller and update the database accordingly?! Or is there any other way for handling Webhooks in Rails?
If it is so simple like above what is this gem https://github.com/razorpay/razorpay-ruby used for?
https://github.com/razorpay/razorpay-ruby is simply a ruby wrapper razorpay provides for all create/fetch methods.
In razorpay you can set up a web hook by first creating a handler path on your controller and expose it to them. You can add this route on their web hooks/add under settings on your razorpay merchant dashboard.
To make this callback more secure, razorpay allows you to setup a web hook signature from the dashboard and the above mentioned gem has a wrapper method that helps you verify the signature as well.
Handling Webhooks require 3 things,
Create a POST endpoint in your application
Add the URL in the callback settings in the 3rd party dashboard, in your case it's Razorpay dashboard
Since the Webhook endpoint is public, you need to verify whether the callback is actually from the authentic source or now. The details are usually provided in the api documentation of the 3rd party service.
After doing this, you can handle the callback in your own way according to the requirement. Preferebly Webhook callbacks params should be moved to a background service and return 204 request everytime.
Hope that helps!

Consuming webhooks shopify-api

I'm in the process of building my first RoR webapp and I'm currently trying to set up an integration with Shopify. I want to create an order in my web application whenever one is created in Shopify. For this I want to use a Shopify webhook. Step two will be to set it up so that after processing the order I'll use the Shopify API to update some records. For now my main concern is receiving the webhooks. I've been looking at the documentation for the Shopify gem but with my limited RoR skills I can't seem to figure it out. I've been searching the web for a few hours but can't find any clear examples / explanation.
I'm confused about this gem; shopify-api (https://docs.shopify.com/api/authentication/using-api-gem-with-private-app-credentials). I've created a private app in shopify, but after that I'm lost. Where am I supposed to place this code and how is this invoked after receiving a webhook?
It seems to me that this gem is mainly used to access the Shopify API instead of consuming webhooks. Am I going at this all wrong?
For receiving the changes (especially Order Creation event) from Shopify, you don't need to use any gem or third party to integrate!
Here are the steps that I did before in my app:
1. Provide an api in your app to receive a webhook event
Here is an example:
Your route:
post '/shopify/create_order', to: 'shopify#create_order'
Your controller:
class ShopifyController < ApplicationController
def create_order
# process shopify order here: all info in `params`
end
end
2. Config to call webhook from your Shopify Settings. The configured url will be:
http://your_production_url/shopify/create_order
If you want to test from localhost, go to step 3
3. (Optional) Test from your localhost
Download this free tool: ngrok and extract it to your machine.
Run ngrok in your terminal to generate a forwarding url to your localhost by this command:
ngrok http 3000
So you will get the output from console like this:
Copy the generated url (http://fbc5cf88.ngrok.io for example) above and add to your Shopify settings in step 2
4. (Optional but critical) Set privacy in your app, to make sure only Shopify can call your api. Follow this documentation
Shopify also provides api to integrate with Shopify resources: create/update product, collection, collect, metafield,... You can directly use it. All was described at Shopify API documentation. But the easiest way to work with Shopify is shopify_api gem which provides an interface to work with Shopify (via ActiceResource)
Probably reading up on the documentation on Webhooks would help you figure out a lot of what you need to do
In essence, here are the overview of what you need to start consuming web hooks:
1. Create your web hooks
You can do it using the Shopify API (POST /admin/webhooks.json)
Or you can do it through store admin
The params that you need to take note of:
topic: the type of hook you want (for e.g orders/create)
address: the URL of the endpoint that you would be consuming the hook at (for e.g: https://myapp.domain.com/hooks/order_create)
2. Create your endpoint that will respond to hooks
You then need to setup your ROR app to expose an endpoint that will respond to a POST request.
This endpoint is the same URL that you previously specified when creating the hook
More info at https://docs.shopify.com/api/webhooks/using-webhooks#respond-to-webhook
Notes: You also need to implement a way to verify that requests that you receive through the endpoints came from Shopify, detailed here.

PayPal API With ActiveMerchant (Legacy Code)

I've inherited some legacy Rails code (2.1.3) and there appears to be a public_cert as well as a signature. I thought PayPal used one or the other, but my configuration seems to have both:
config.app_config.pay_pal.merge!(
:password=>"WHATEVER",
:public_key=>"-----BEGIN CERTIFICATE-----\nMIICmTCCAgKgAwIBAgIDEcmhMA0GCSqGSIb3DQEBBQUAMIGZMQswCQYDVQQGEwJV\nUzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2UxFTATBgNV\nBAoTCHANGEDSTUFFqe0RzCDhQmVhgtNWZxeqzjVbVrCx80jF1\nWi/+ksJQLPViFj9+F4WS5i4MjMeCIwIDAQABow0wCzAJBgNVHRMEAjAAMA0GCSqG\nSIb3DQEBBQUAA4GBAMwavx4Eh2JCOCOc/WvL7zdRL07So48mQ9aJr4Bxdgib+/z2\nkqX0ZPJv9T6NQ1h9lcwohIuaJMXtLAysJMjvKcvPdzcHqB6Xv+OGpi2REJjUdB39\n9amutkxQVhKBfK3hCP4+8UlM1yzxejyK8SVWSJCbc5zvJFoLV4SZcbNevtw9\n-----END CERTIFICATE-----\n",
:business=>"me#site.com",
:business_id=>"4WSDFSFSDF",
:login=>"me_api1.site.com",
:cert_id=>"AAAA",
:private_key=>"-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQDm5fXKcp6ht6+Be4Y7VOaNvEPZwVqRt0CHANGEDMORESTUFFKTF7Mozcg12qiq1VDqFYwQF\n8gteGGLFy3GKPWlpqtJzAI4xfpI07d2ivgfXkk4Q74np+P8udulM0bEA+WAoGO6e\nHZ7g0/EbutA0+H5TTSp3gUYa5xcUhSrMiYN/r6HK+aeKnNECQQD8D/oBjEsZwsAB\n2KxDLZfEcrmFiLxjqQSBKPtMJP0Lrhl7OyB2v1o3QDA5+QdbDFbRxA1RNQfw+ZXo\nPuP49DRpAkEA6oFYlNnGvNWlHxDmVob5q88HEgP/ZEWFJXzZcSsAkJNrbdyPCdSj\nxN2M0duJlegJlfsr6l9OyBeFcSXnrVSAqwJBAO7BP2FJ/zUGeJMHJpx3SkOFG9+1\nliScSy0AoZANlTcEERTd+7EfLZgaD9RJ40LF3FLTbn3WSpBiCTG0qIH+5skCQF4K\n5SU8eJC99OwScOz+UB3wdltpMwBZSN4RxXm2zxErrYdvTgWZOtv2JUT7j5+IYF+/\nTIs/EW74z9DibJh8LOUCQEsMclIUTorjVVtAgI5LiSwenDSCgf9Ra0r3CoL3dAGz\n1RskSziPqfQyA2QDFfSPkmycgxPlZvP0G8fwuBs6sjI=\n-----END RSA PRIVATE KEY-----\n",
:signature=>"AwhNvKUCHANGEDSTUFF9xveB4"
)
I'm using PayPal Payments Standard I believe with Rails ActiveMerchant.
Any help would be greatly appreciated
PayPal only allows you to use one or the other. It may have been that the previous person generated the cert or signature and added it to the code, only to switch over to the other method at a later date and never removed it from the code. If it's currently working and processing payments on the PayPal account, you could log into the PayPal account and see which one is currently active on the account. You are only going to see one or the other. Which ever one you are seeing, means the other one would not be being used. If it's not showing, it would not be valid anymore.
Another option, would be you could walk thru the code and see where the API call is being made, and check which one it is sending across to PayPal.

Using Stripe webhooks with Rails

I have successfully built out a rails app as per Ryan Bates' railscast (http://railscasts.com/episodes/288-billing-with-stripe) - However, in the railscast he doesn't cover webhooks. I was wondering if there are any good examples in the public domain of implementing and using webhooks to manage a subscription billing that has been created.
Any thoughts / direction would be super helpful?
Thanks!
There's a nice gem for this: https://github.com/integrallis/stripe_event.
It looks to be well written and maintained.
In your gemfile you can simply add the line -
gem 'stripe_event'
There's clear doc in the readme on github.
Most all payment gateways, including stripe, have some way of telling the client (your webapp) whether the charge went through or not.
For stripe, their docs show how to receive a webhook notification from them.
The flow is:
Create a controller and method in your app to receive the webhook calls from stripe. Note that the calls will come in as POSTs, not GETs
Register the url with stripe using their dashboard. This is a manual step that you do once.
When your method is called from stripe, use the event info to update your models which track the status of your users' subscriptions.
Any questions?
I'd like to use this gem for testing stripe webhooks https://github.com/stripe-ruby-mock/stripe-ruby-mock
Features
No stripe server access required
Easily test against stripe errors
Mock and customize stripe webhooks
Flip a switch to run your tests against Stripe's live test servers

Resources