Payfort in Ruby On Rails Application

2019-09-20 00:21发布

问题:

I wish to implement the payfort gateway with my rails application.But I am very much novice to api. I am having a look at the this docs. But i am not clear with where to start? Is there any gem for it?

Any help will be appreciated. Thanks in advance :)

回答1:

There's no Gems for sorry , but api is rest so you can implement what you want easily. But the best thing is to start with creating your own Gateway with Active Merchant.



回答2:

1-Sort all PayFort requests parameters in an ascending alphabetical order based on the parameters names as follow: 

params={access_code=stbbRGM7K1rHXliCQeNwtk,
amount=250,
command=PURCHASE,
currency=QAR,
customer_email=test@gmail.com,
customer_ip=103.43.154.34,
language=en,
merchant_identifier=YRssfesdsd,
merchant_reference=REFRRSERRFFE4444,
token_name=6RTD55DVVVBDSCCVVCFCCV}
params = params.sort.to_h
string = params.to_query(nil)
string = Digest::SHA256.hexdigest string
  params.store 'signature',string 
  uri = URI.parse("https://sbpaymentservices.payfort.com/FortAPI/paymentApi")
  header = {'Content-Type': 'application/json'}
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, header)