Class: Parsbank::Zibal
Instance Attribute Summary collapse
-
#allowedCards ⇒ Object
Returns the value of attribute allowedCards.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#callbackUrl ⇒ Object
Returns the value of attribute callbackUrl.
-
#checkMobileWithCard ⇒ Object
Returns the value of attribute checkMobileWithCard.
-
#description ⇒ Object
Returns the value of attribute description.
-
#email ⇒ Object
Returns the value of attribute email.
-
#ledgerId ⇒ Object
Returns the value of attribute ledgerId.
-
#logo ⇒ Object
readonly
Returns the value of attribute logo.
-
#merchant ⇒ Object
Returns the value of attribute merchant.
-
#mobile ⇒ Object
Returns the value of attribute mobile.
-
#nationalCode ⇒ Object
Returns the value of attribute nationalCode.
-
#orderId ⇒ Object
Returns the value of attribute orderId.
-
#ref_id ⇒ Object
readonly
Returns the value of attribute ref_id.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_message ⇒ Object
readonly
Returns the value of attribute status_message.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(args = {}) ⇒ Zibal
constructor
A new instance of Zibal.
- #redirect_form ⇒ Object
- #valid? ⇒ Boolean
- #validate(response = nil) ⇒ Object
Methods inherited from Gates
#default_config, logo, #redirect_loaders
Constructor Details
#initialize(args = {}) ⇒ Zibal
Returns a new instance of Zibal.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/parsbank/zibal/zibal.rb', line 12 def initialize(args = {}) @amount = args.fetch(:amount) @description = args.fetch(:description, nil) @email = args.fetch(:email, nil) @mobile = args.fetch(:mobile, nil) @merchant = args.fetch(:merchant, default_config(:merchant)) @callbackUrl = args.fetch(:callbackUrl, (default_config(:callback_url) || Parsbank.configuration.callback_url)) @orderId = args.fetch(:orderId, nil) @allowedCards = args.fetch(:allowedCards, nil) @ledgerId = args.fetch(:ledgerId, nil) @nationalCode = args.fetch(:nationalCode, nil) @checkMobileWithCard = args.fetch(:checkMobileWithCard, nil) rescue KeyError => e raise ArgumentError, "Missing required argument: #{e.message}" end |
Instance Attribute Details
#allowedCards ⇒ Object
Returns the value of attribute allowedCards.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def allowedCards @allowedCards end |
#amount ⇒ Object
Returns the value of attribute amount.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def amount @amount end |
#callbackUrl ⇒ Object
Returns the value of attribute callbackUrl.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def callbackUrl @callbackUrl end |
#checkMobileWithCard ⇒ Object
Returns the value of attribute checkMobileWithCard.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def checkMobileWithCard @checkMobileWithCard end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def description @description end |
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def email @email end |
#ledgerId ⇒ Object
Returns the value of attribute ledgerId.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def ledgerId @ledgerId end |
#logo ⇒ Object (readonly)
Returns the value of attribute logo.
10 11 12 |
# File 'lib/parsbank/zibal/zibal.rb', line 10 def logo @logo end |
#merchant ⇒ Object
Returns the value of attribute merchant.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def merchant @merchant end |
#mobile ⇒ Object
Returns the value of attribute mobile.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def mobile @mobile end |
#nationalCode ⇒ Object
Returns the value of attribute nationalCode.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def nationalCode @nationalCode end |
#orderId ⇒ Object
Returns the value of attribute orderId.
7 8 9 |
# File 'lib/parsbank/zibal/zibal.rb', line 7 def orderId @orderId end |
#ref_id ⇒ Object (readonly)
Returns the value of attribute ref_id.
10 11 12 |
# File 'lib/parsbank/zibal/zibal.rb', line 10 def ref_id @ref_id end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/parsbank/zibal/zibal.rb', line 10 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/parsbank/zibal/zibal.rb', line 10 def status @status end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
10 11 12 |
# File 'lib/parsbank/zibal/zibal.rb', line 10 def end |
Instance Method Details
#call ⇒ Object
45 46 47 |
# File 'lib/parsbank/zibal/zibal.rb', line 45 def call create_rest_client end |
#redirect_form ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/parsbank/zibal/zibal.rb', line 49 def redirect_form " <script type='text/javascript' charset='utf-8'> function postRefId (refIdValue) { var form = document.createElement('form'); form.setAttribute('method', 'POST'); form.setAttribute('action', 'https://gateway.zibal.ir/start/#{ref_id}'); form.setAttribute('target', '_self'); var hiddenField = document.createElement('input'); hiddenField.setAttribute('name', 'RefId'); hiddenField.setAttribute('value', refIdValue); form.appendChild(hiddenField); document.body.appendChild(form); form.submit(); document.body.removeChild(form); } postRefId('#{ref_id}') %>') </script> " end |
#valid? ⇒ Boolean
37 38 39 |
# File 'lib/parsbank/zibal/zibal.rb', line 37 def valid? @valid end |
#validate(response = nil) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/parsbank/zibal/zibal.rb', line 28 def validate(response = nil) @response = response @ref_id = @response['trackId'] @status = @response['result'].present? ? @response['result'] : 'FAILED' perform_validation self end |