class Peperusha::CustomerPayViaTill
Public Instance Methods
call()
click to toggle source
# File lib/peperusha/customer_pay_via_till.rb, line 18 def call path = 'mpesa/c2b/v1/simulate' response = Peperusha::Client.invoke_post_request(token, path, attributes) if response.status == 200 data = JSON.parse(response.body) context.body = data else client_errors = Peperusha::Client.build_errors_collection(response) context.fail!(errors: client_errors) end end
Private Instance Methods
attributes()
click to toggle source
# File lib/peperusha/customer_pay_via_till.rb, line 41 def attributes { 'Amount': amount, 'CommandID': 'CustomerBuyGoodsOnline:', 'Msisdn': customer_number, 'ShortCode': business_till_number } end
check_if_params_missing()
click to toggle source
# File lib/peperusha/customer_pay_via_till.rb, line 33 def check_if_params_missing errors = [] errors << 'amount.missing' if amount.nil? errors << 'business_till_number.missing' if business_till_number.nil? errors << 'customer_number.missing' if customer_number.nil? errors end