Class: Parsbank::Mellat
Instance Attribute Summary collapse
-
#additional_data ⇒ Object
Returns the value of attribute additional_data.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#callback_url ⇒ Object
Returns the value of attribute callback_url.
-
#local_date ⇒ Object
Returns the value of attribute local_date.
-
#local_time ⇒ Object
Returns the value of attribute local_time.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#payer_id ⇒ Object
Returns the value of attribute payer_id.
-
#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 = {}) ⇒ Mellat
constructor
A new instance of Mellat.
- #redirect_form ⇒ Object
- #valid? ⇒ Boolean
- #validate(response = nil) ⇒ Object
Methods inherited from Gates
#default_config, logo, #redirect_loaders
Constructor Details
#initialize(args = {}) ⇒ Mellat
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/parsbank/mellat/mellat.rb', line 6 def initialize(args = {}) @order_id = args.fetch(:orderId) @amount = args.fetch(:amount) @local_date = args.fetch(:localDate, Time.now.strftime('%Y%m%d')) @local_time = args.fetch(:localTime, Time.now.strftime('%H%M%S')) @additional_data = args.fetch(:additionalData, ' ') @payer_id = args.fetch(:payerId, 0) @callback_url = args.fetch(:callBackUrl, default_config(:callback_url)) @terminal_id = args.fetch(:terminalId, default_config(:terminal_id)) @username = args.fetch(:userName, default_config(:username)) @user_password = args.fetch(:userPassword, default_config(:password)) @wsdl = create_wsdl_client rescue KeyError => e raise ArgumentError, "Missing required argument: #{e.}" end |
Instance Attribute Details
#additional_data ⇒ Object
Returns the value of attribute additional_data.
3 4 5 |
# File 'lib/parsbank/mellat/mellat.rb', line 3 def additional_data @additional_data end |
#amount ⇒ Object
Returns the value of attribute amount.
3 4 5 |
# File 'lib/parsbank/mellat/mellat.rb', line 3 def amount @amount end |
#callback_url ⇒ Object
Returns the value of attribute callback_url.
3 4 5 |
# File 'lib/parsbank/mellat/mellat.rb', line 3 def callback_url @callback_url end |
#local_date ⇒ Object
Returns the value of attribute local_date.
3 4 5 |
# File 'lib/parsbank/mellat/mellat.rb', line 3 def local_date @local_date end |
#local_time ⇒ Object
Returns the value of attribute local_time.
3 4 5 |
# File 'lib/parsbank/mellat/mellat.rb', line 3 def local_time @local_time end |
#order_id ⇒ Object
Returns the value of attribute order_id.
3 4 5 |
# File 'lib/parsbank/mellat/mellat.rb', line 3 def order_id @order_id end |
#payer_id ⇒ Object
Returns the value of attribute payer_id.
3 4 5 |
# File 'lib/parsbank/mellat/mellat.rb', line 3 def payer_id @payer_id end |
#ref_id ⇒ Object (readonly)
Returns the value of attribute ref_id.
4 5 6 |
# File 'lib/parsbank/mellat/mellat.rb', line 4 def ref_id @ref_id end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/parsbank/mellat/mellat.rb', line 4 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/parsbank/mellat/mellat.rb', line 4 def status @status end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
4 5 6 |
# File 'lib/parsbank/mellat/mellat.rb', line 4 def @status_message end |
Instance Method Details
#call ⇒ Object
36 37 38 39 40 41 |
# File 'lib/parsbank/mellat/mellat.rb', line 36 def call response = @wsdl.call(:bp_pay_request, message: ) validate(response.body) rescue Savon::Error => e raise "SOAP request failed: #{e.}" end |
#redirect_form ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/parsbank/mellat/mellat.rb', line 43 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://bpm.shaparak.ir/pgwchannel/startpay.mellat'); 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
28 29 30 |
# File 'lib/parsbank/mellat/mellat.rb', line 28 def valid? @valid end |
#validate(response = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/parsbank/mellat/mellat.rb', line 22 def validate(response = nil) @response = response perform_validation self end |