Class: PaystackSdk::Resources::Charges
- Defined in:
- lib/paystack_sdk/resources/charges.rb
Overview
The ‘Charges` resource exposes helpers for initiating and managing charges through alternative payment channels such as Mobile Money.
At the moment the SDK focuses on supporting the Mobile Money channel which requires posting to the ‘/charge` endpoint with the customer’s email, amount, currency, and the provider specific ‘mobile_money` payload.
Constant Summary collapse
- MOBILE_MONEY_PROVIDERS =
%w[mtn atl vod mpesa orange wave].freeze
Constants included from Utils::ConnectionUtils
Utils::ConnectionUtils::BASE_URL
Instance Method Summary collapse
-
#mobile_money(payload) ⇒ PaystackSdk::Response
Initiates a Mobile Money payment.
-
#submit_otp(payload) ⇒ PaystackSdk::Response
Submits an OTP for authorising a pending Mobile Money charge (e.g. Vodafone).
Methods inherited from Base
Methods included from Utils::ConnectionUtils
#create_connection, #initialize_connection
Methods included from Validations
#validate_allowed_values!, #validate_currency!, #validate_date_format!, #validate_email!, #validate_fields!, #validate_hash!, #validate_positive_integer!, #validate_presence!, #validate_reference_format!, #validate_required_params!
Constructor Details
This class inherits a constructor from PaystackSdk::Resources::Base
Instance Method Details
#mobile_money(payload) ⇒ PaystackSdk::Response
Initiates a Mobile Money payment.
31 32 33 34 35 36 37 |
# File 'lib/paystack_sdk/resources/charges.rb', line 31 def mobile_money(payload) validate_mobile_money_payload!(payload) normalized_payload = normalize_mobile_money_provider(payload) response = @connection.post("/charge", normalized_payload) handle_response(response) end |
#submit_otp(payload) ⇒ PaystackSdk::Response
Submits an OTP for authorising a pending Mobile Money charge (e.g. Vodafone).
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/paystack_sdk/resources/charges.rb', line 47 def submit_otp(payload) validate_fields!( payload: payload, validations: { otp: {type: :string, required: true}, reference: {type: :reference, required: true} } ) response = @connection.post("/charge/submit_otp", payload) handle_response(response) end |