class NuaPay::DirectDebitInfo

Direct Debit payments allows to pull payments from the borrower's accounts, once the borrower has signed an authorisation via signed mandates.

Public Instance Methods

create( mandate_id, data={} ) click to toggle source

data = {“requestedCollectionDate”: “2019-06-08”, “paymentAmount”: 5000.01, “settlementDateShift”: true }

# File lib/nua_pay/direct_debit_info.rb, line 7
def create( mandate_id, data={} )
  validate_direct_debit_post_params( data )

  url = mandate_url( mandate_id )  + NUAPAY_API['DIRECT_DEBITS']
  get_response( url , {request_type: :post}, data )
end
create_mandate_with_direct_debit(data={}) click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 14
def create_mandate_with_direct_debit(data={})
  validate_direct_debit_with_mandate_post_params( data )
  url = build_url( base_url + NUAPAY_API['DIRECT_DEBITS'] )
  get_response( url , {request_type: :post}, data )
end
fetch_by_mandate( mandate_id ) click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 30
def fetch_by_mandate( mandate_id )
  url = mandate_url( mandate_id )  + NUAPAY_API['DIRECT_DEBITS']
  get_response( url )
end
fetch_by_scheme() click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 35
def fetch_by_scheme
  url = build_url( base_url + NUAPAY_API['DIRECT_DEBITS'] )
  get_response( url )
end
get(mandate_id, id ) click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 20
def get(mandate_id, id )
  url = mandate_url( mandate_id )  + NUAPAY_API['DIRECT_DEBITS'] + id
  get_response( url )
end
list() click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 25
def list
  url = build_url( NUAPAY_API['DIRECT_DEBITS_LIST'] )
  get_response( url )
end
represent( mandate_id, id ) click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 50
def represent( mandate_id, id )
  url = mandate_url( mandate_id )  + NUAPAY_API['DIRECT_DEBITS'] + id + NUAPAY_API['REPRESENT']
  get_response( url , {request_type: :post} )
end
revoke( mandate_id, id, reason="" ) click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 40
def revoke( mandate_id, id, reason="" )
  url = mandate_url( mandate_id )  + NUAPAY_API['DIRECT_DEBITS'] + id + NUAPAY_API['REVOKE']
  get_response( url , {request_type: :post}, cancellation( reason ) )
end
revoke_all( mandate_id, reason="" ) click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 45
def revoke_all( mandate_id, reason="" )
  url = mandate_url( mandate_id )  + NUAPAY_API['REVOKE_ALL_DIRECT_DEBITS']
  get_response( url , {request_type: :post}, cancellation( reason ) )
end

Private Instance Methods

validate_direct_debit_post_params( data ) click to toggle source

requestedCollectionDate should be two days prior to the current date

# File lib/nua_pay/direct_debit_info.rb, line 57
def validate_direct_debit_post_params( data )
  _data  = data.with_indifferent_access.compact
  _data.fetch(:requestedCollectionDate) && _data.fetch(:paymentAmount)
end
validate_direct_debit_with_mandate_post_params( data ) click to toggle source
# File lib/nua_pay/direct_debit_info.rb, line 62
def validate_direct_debit_with_mandate_post_params( data )
  mandate = data.fetch(:mandate)
  validate_direct_debit_post_params( data ) && validate_mandate_params( mandate )
end