Class: ProcessingKz::StartTransaction
- Inherits:
-
Object
- Object
- ProcessingKz::StartTransaction
- Defined in:
- lib/processing_kz/start_transaction.rb
Instance Attribute Summary collapse
-
#billing_address ⇒ Object
readonly
Returns the value of attribute billing_address.
-
#currency_code ⇒ Object
readonly
Returns the value of attribute currency_code.
-
#customer_reference ⇒ Object
readonly
Returns the value of attribute customer_reference.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#error_description ⇒ Object
readonly
Returns the value of attribute error_description.
-
#goods_list ⇒ Object
Returns the value of attribute goods_list.
-
#language_code ⇒ Object
readonly
Returns the value of attribute language_code.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
-
#merchant_local_date_time ⇒ Object
Returns the value of attribute merchant_local_date_time.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
-
#purchaser_email ⇒ Object
readonly
Returns the value of attribute purchaser_email.
-
#purchaser_name ⇒ Object
readonly
Returns the value of attribute purchaser_name.
-
#purchaser_phone ⇒ Object
readonly
Returns the value of attribute purchaser_phone.
-
#redirect_url ⇒ Object
readonly
Returns the value of attribute redirect_url.
-
#return_url ⇒ Object
readonly
Returns the value of attribute return_url.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#terminal_id ⇒ Object
readonly
Returns the value of attribute terminal_id.
Instance Method Summary collapse
- #hashed_goods_list ⇒ Object
-
#initialize(args = {}) ⇒ StartTransaction
constructor
A new instance of StartTransaction.
- #request! ⇒ Object
- #response(args = {}) ⇒ Object
- #total_amount ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ StartTransaction
Returns a new instance of StartTransaction.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/processing_kz/start_transaction.rb', line 23 def initialize(args = {}) @merchant_id = args[:merchant_id] || Config.merchant_id @currency_code = args[:currency_code] || Config.currency_code @language_code = args[:language_code] || Config.language_code @terminal_id = args[:terminal_id] @order_id = args[:order_id] @description = args[:description] @purchaser_name = args[:purchaser_name] @return_url = args[:return_url] @purchaser_email = args[:purchaser_email] @purchaser_phone = args[:purchaser_phone] @customer_reference = args[:customer_reference] self.goods_list = args[:goods_list] self.merchant_local_date_time = args[:merchant_local_date_time] || Time.now request! end |
Instance Attribute Details
#billing_address ⇒ Object (readonly)
Returns the value of attribute billing_address.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def billing_address @billing_address end |
#currency_code ⇒ Object (readonly)
Returns the value of attribute currency_code.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def currency_code @currency_code end |
#customer_reference ⇒ Object (readonly)
Returns the value of attribute customer_reference.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def customer_reference @customer_reference end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def description @description end |
#error_description ⇒ Object (readonly)
Returns the value of attribute error_description.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def error_description @error_description end |
#goods_list ⇒ Object
Returns the value of attribute goods_list.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def goods_list @goods_list end |
#language_code ⇒ Object (readonly)
Returns the value of attribute language_code.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def language_code @language_code end |
#merchant_id ⇒ Object (readonly)
Returns the value of attribute merchant_id.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def merchant_id @merchant_id end |
#merchant_local_date_time ⇒ Object
Returns the value of attribute merchant_local_date_time.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def merchant_local_date_time @merchant_local_date_time end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def order_id @order_id end |
#purchaser_email ⇒ Object (readonly)
Returns the value of attribute purchaser_email.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def purchaser_email @purchaser_email end |
#purchaser_name ⇒ Object (readonly)
Returns the value of attribute purchaser_name.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def purchaser_name @purchaser_name end |
#purchaser_phone ⇒ Object (readonly)
Returns the value of attribute purchaser_phone.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def purchaser_phone @purchaser_phone end |
#redirect_url ⇒ Object (readonly)
Returns the value of attribute redirect_url.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def redirect_url @redirect_url end |
#return_url ⇒ Object (readonly)
Returns the value of attribute return_url.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def return_url @return_url end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def success @success end |
#terminal_id ⇒ Object (readonly)
Returns the value of attribute terminal_id.
5 6 7 |
# File 'lib/processing_kz/start_transaction.rb', line 5 def terminal_id @terminal_id end |
Instance Method Details
#hashed_goods_list ⇒ Object
61 62 63 64 65 66 |
# File 'lib/processing_kz/start_transaction.rb', line 61 def hashed_goods_list raise NoGoodsError unless goods_list hash = [] goods_list.each { |good| hash << good.to_hash } hash end |
#request! ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/processing_kz/start_transaction.rb', line 68 def request! client = Savon.client(wsdl: Config.wsdl, soap_version: 2, endpoint: Config.host) request = client.call(:start_transaction, message: { transaction: { merchant_id: merchant_id, currency_code: currency_code, language_code: language_code, order_id: order_id, goods_list: hashed_goods_list, merchant_local_date_time: merchant_local_date_time, return_u_r_l: return_url, total_amount: total_amount.to_i } } ) response(request.body[:start_transaction_response][:return]) end |
#response(args = {}) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/processing_kz/start_transaction.rb', line 86 def response(args = {}) @success = args[:success] @redirect_url = args[:redirect_url] @error_description = args[:error_description] @customer_reference = args[:customer_reference] end |
#total_amount ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/processing_kz/start_transaction.rb', line 52 def total_amount raise NoGoodsError unless goods_list total = 0 goods_list.each do |good| total += good.amount end total end |