class StarkitBanking::YBL::Payment::ByFT2

Private Instance Methods

credentials(payment) click to toggle source
# File lib/starkit_banking/api/ybl/payment/ft2.rb, line 21
def credentials(payment)
  payment.payment_account.credentials
end
invoke(env, req, callbacks) click to toggle source
# File lib/starkit_banking/api/ybl/payment/ft2.rb, line 13
def invoke(env, req, callbacks)
  ApiBanking::FundsTransferByCustomerService2.transfer(env, req, callbacks)
end
request(subscription, payment) click to toggle source
# File lib/starkit_banking/api/ybl/payment/ft2.rb, line 25
def request(subscription, payment)

  address = ApiBanking::FundsTransferByCustomerService2::Transfer::Address.new()
  beneficiary = ApiBanking::FundsTransferByCustomerService2::Transfer::Beneficiary.new()
  request = ApiBanking::FundsTransferByCustomerService2::Transfer::Request.new()

  # every payment is identified by its ID, repeated API attempts can be identified when the ID is used as the URN
  @req_reference = request.uniqueRequestNo = payment.id

  request.appID = subscription.app_id
  request.customerID = payment.payment_account.customer_id
  request.debitAccountNo = payment.payment_account.account_number
  request.transferType = payment.transfer_type || payment.transfer_type
  request.transferAmount = payment.transfer_amount
  request.remitterToBeneficiaryInfo = translate(:transfer_description, payment.transfer_description)

  beneficiary.accountNo = payment.beneficiary_account_number
  beneficiary.accountIFSC = payment.beneficiary_ifsc
  beneficiary.fullName = translate(:bene_name, payment.beneficiary_name)
  beneficiary.address = translate(:address_line1, payment.beneficiary_address_line1)

  request.beneficiary = beneficiary

  request
end
response(res) click to toggle source
# File lib/starkit_banking/api/ybl/payment/ft2.rb, line 17
def response(res)
  Transfer::Status.new(res.transactionStatus.statusCode, res.transactionStatus.bankReferenceNo, res.transferType)
end
service_name() click to toggle source
# File lib/starkit_banking/api/ybl/payment/ft2.rb, line 9
def service_name
  'FUNDS TRANSFER'
end
subscription(payment) click to toggle source
# File lib/starkit_banking/api/ybl/payment/ft2.rb, line 51
def subscription(payment)
  payment.payment_account.service_subscriptions.find_by(service_name: service_name)
end
translate(element, value) click to toggle source
# File lib/starkit_banking/api/ybl/payment/ft2.rb, line 55
def translate(element, value)
  case element
  when :bene_name
    value.slice(0,34)
  when :address_line1
    value.gsub!(/[^A-Za-z0-9|\"|\(|\)|\:|\?|\{|\}|\!|\@|\#|\\|\%|\!|\.|\-]+/,'-')
    value.slice(0,34)
  when :transfer_description
    value.gsub!(/[^A-Za-z0-9|\s|\.|\,|\-]+/,'-')
    value.slice(0,119)
  end
end