Class: GoCardlessPro::Resources::RedirectFlow

Inherits:
Object
  • Object
show all
Defined in:
lib/gocardless_pro/resources/redirect_flow.rb

Overview

Redirect flows enable you to use GoCardless’ [hosted payment pages](pay-sandbox.gocardless.com/AL000000AKFPFF) to set up mandates with your customers. These pages are fully compliant and have been translated into Danish, Dutch, French, German, Italian, Norwegian, Portuguese, Slovak, Spanish and Swedish.

The overall flow is:

  1. You [create](#redirect-flows-create-a-redirect-flow) a redirect flow

for your customer, and redirect them to the returned redirect url, e.g. ‘pay.gocardless.com/flow/RE123`.

  1. Your customer supplies their name, email, address, and bank account

details, and submits the form. This securely stores their details, and redirects them back to your ‘success_redirect_url` with `redirect_flow_id=RE123` in the querystring.

  1. You [complete](#redirect-flows-complete-a-redirect-flow) the redirect

flow, which creates a [customer](#core-endpoints-customers), [customer bank account](#core-endpoints-customer-bank-accounts), and [mandate](#core-endpoints-mandates), and returns the ID of the mandate. You may wish to create a [subscription](#core-endpoints-subscriptions) or [payment](#core-endpoints-payments) at this point.

Once you have [completed](#redirect-flows-complete-a-redirect-flow) the redirect flow via the API, you should display a confirmation page to your customer, confirming that their Direct Debit has been set up. You can build your own page, or redirect to the one we provide in the ‘confirmation_url` attribute of the redirect flow.

Redirect flows expire 30 minutes after they are first created. You cannot complete an expired redirect flow.

Defined Under Namespace

Classes: Links

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, response = nil) ⇒ RedirectFlow

Initialize a redirect_flow resource instance

Parameters:

  • object (Hash)

    an object returned from the API



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 59

def initialize(object, response = nil)
  @object = object

  @confirmation_url = object['confirmation_url']
  @created_at = object['created_at']
  @description = object['description']
  @id = object['id']
  @links = object['links']
  @redirect_url = object['redirect_url']
  @scheme = object['scheme']
  @session_token = object['session_token']
  @success_redirect_url = object['success_redirect_url']
  @response = response
end

Instance Attribute Details

#confirmation_urlObject (readonly)

Returns the value of attribute confirmation_url.



48
49
50
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 48

def confirmation_url
  @confirmation_url
end

#created_atObject (readonly)

Returns the value of attribute created_at.



49
50
51
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 49

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



50
51
52
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 50

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



51
52
53
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 51

def id
  @id
end

#redirect_urlObject (readonly)

Returns the value of attribute redirect_url.



52
53
54
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 52

def redirect_url
  @redirect_url
end

#schemeObject (readonly)

Returns the value of attribute scheme.



53
54
55
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 53

def scheme
  @scheme
end

#session_tokenObject (readonly)

Returns the value of attribute session_token.



54
55
56
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 54

def session_token
  @session_token
end

#success_redirect_urlObject (readonly)

Returns the value of attribute success_redirect_url.



55
56
57
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 55

def success_redirect_url
  @success_redirect_url
end

Instance Method Details

#api_responseObject



74
75
76
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 74

def api_response
  ApiResponse.new(@response)
end

Return the links that the resource has



79
80
81
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 79

def links
  @redirect_flow_links ||= Links.new(@links)
end

#to_hObject

Provides the redirect_flow resource as a hash of all its readable attributes



84
85
86
# File 'lib/gocardless_pro/resources/redirect_flow.rb', line 84

def to_h
  @object
end