GithubHelp home page GithubHelp logo

isabella232 / sample-legacy-rails-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gocardless/sample-legacy-rails-app

0.0 0.0 0.0 144 KB

A sample Rails app demonstrating the use of GoCardless Legacy API and the Ruby client.

JavaScript 3.08% Ruby 95.82% CoffeeScript 1.10%

sample-legacy-rails-app's Introduction

GoCardless sample application

Setup

The first thing to do is to clone the repository:

$ git clone https://github.com/gocardless/sample-rails-app.git

Change the account details in config/initializers/gocardless.rb to match your SANDBOX developer credentials.

Then install the Gems:

$ bundle install

Once the installation has finished, run the app:

$ rails server

and open your browser at http://127.0.0.1/3000.

Walkthrough

Before you interact with the application, go to GoCardless Sandbox and set up the Redirect URI in the Developer settings. To make it work with this application, use the value http://127.0.0.1:3000/gocardless/confirm. This is to make sure you are redirected back to your site where the purchase is verified after you have made a purchase.

One-off purchases

The simplest payment type is one-off. By clicking Make purchase on the sample appliation website, you are taken through the flow in making a single payment.

A real-world example of one-off purchases is buying something in an online store.

Subscriptions

Subscriptions are fixed periodic payments. Upon clicking Subscribe on the sample application website, you are taken through the process of registering a subscription with a merchant.

An example would be subscribing to a magazine or newspaper. The magazine is published once a month and it costs £10, the payment flow sets up an automatic transaction transferring £10 monthly to the merchant's account.

Pre-authorizations

Pre-authorizations are essentially subscriptions, with an added twist that it's up to the merchant to request funds from the customer's account, and the customer may be billed up to a certain, authorized amount every billing period. Upon clicking Preauthorize on the sample app website, you are taken through the flow of pre-authorizing a variable direct-debit payment.

An example from the real world would be a type of pay-as-you go service where the customer authorizes the merchant to claim up to a certain amount per interval depending on usage.

In the sample app, you pre-authorize a payment of up to £100 every 3 months.

For further information, refer to the docs.

Webhooks

Set up localtunnel to test out Webhooks. The localtunnel gem should be installed as a dependency to the project. Note, however, that the port number is the same as the port that rails server is running on.

$ localtunnel -k ~/.ssh/id_rsa.pub 3000
=> Port 3000 is now publicly accessible from http://3u5q.localtunnel.com ...

Please refer to the the Webhooks manual for more details.

Test your Webhooks

Once you have the app running with rails server and tunneling set up with localtunnel (make sure you verify that by navigating to the URL that localtunnel gives back to you) navigate to the "Web hooks" tab under the Developer section in GoCardless Sandbox. Make sure that the Webhook URL is the same you got back from localtunnel with an added /gocardless/webhook at the end, i.e http://3u5q.localtunnel.com/gocardless/webhook, otherwise it does not work. There should be a button for sending a test webhook. Click that, select Bill as the object type and click Fire webhook.

The data from Webhook is accessible in the webhook endpoint in app/controllers/gocardless_controller.rb in the webhook_data variable.

Tests

To run the tests, run rake test:functionals in the project root.

sample-legacy-rails-app's People

Contributors

karls avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.