+1

Learn about GMO payment gateways with Gem GMO P2

As my previous article, I also show you about what is GMO payment getway and how it work. And now in this article, we practice using GMO in ruby on rails. If you use ruby on rails to do the application, it is easy for you to use because we already have Gem for support this. Now let's start to learn how to use GMO Gem:

Installation

Now you add the gem GOM in to your Gemfile as normal:

#Gemfile
gem "gmo"

and run bundle install to install the dependency.

Shop API

In GMO Gem, the shop API given by GMO to API call and the API which requires shop pass are defined as Shop API. APIs related to settlement, such as transaction registration, settlement status change, etc., are the main.

The Shop API can be handled by the GMO :: Payment :: Shop API class. When initializing, it is necessary to pass the shop ID specified by GMO, shop path, API host name as argument.

gmo = GMO::Payment::ShopAPI.new 
  :shop_id => "foo",
  :shop_pass => "bar",
  :host => "mul-pay.com"
  • Transaction registration (EntryTran) We will issue transaction ID and transaction password required for subsequent settlement transactions and start trading.
result = gmo.entry_tran 
  :order_id => 100,
  :job_cd => "AUTH",
  :amount => 100
  • Settlement Execution (ExecTran) Communicate with the card company using the card number and expiration date information, execute settlement, and return the result.
result = gmo.exec_tran 
  :order_id => 100,
  :access_id => "access_id",
  :access_pass => "access_pass",
  :method => 1,
  :pay_times => 1,
  :card_no => "4111111111111111",
  :expire => "1405", #format must be YYMM
  :client_field_1 => "client_field1"
  • Settlement change (AlterTran) Actual sales will be made against settlement of provisional sales. In addition, we will check the amount with the provisional sales time at the time of execution.
result = gmo.alter_tran
  :access_id => "access_id",
  :access_pass => "access_pass",
  :job_cd => "SALES",
  :amount => 100
  • Amount change (ChangeTran) We will change the amount for the transaction which settlement is completed.
result = gmo.change_tran
  :access_id => "access_id",
  :access_pass => "access_pass",
  :JobCd => 100,
  :Amount => 100`

Site API

Site API given from GMO to API call and API requiring site path are defined as Site API. It is an API group mainly responsible for operations related to cards and members.

The Site API can be handled by the GMO :: Payment :: Site API class. When initializing, it is necessary to pass the site ID specified by GMO, site pass, API host name as argument.

gmo = GMO::Payment::SiteAPI.new 
  :site_id => "foo",
  :site_pass => "bar",
  :host => "mul-pay.com"
  • Member registration (SaveMember) Register a member on the specified site.
result = gmo.save_member 
  :member_id => 100,
  :member_name => "John Smith"
  • Member renewal (UpdateMember) We will update the member information on the designated site.
result = gmo.update_member
  :member_id => 100,
  :member_name => "Taro Yamada"
  • Delete Member (DeleteMember) Delete member information from the specified site.
result = gmo.delete_member 
  :member_id => 100
  • Member Reference (SearchMember) We will refer to the member information of the specified site.
result = gmo.search_member
  :member_id => 100
  • Card Registration / Update (SaveCard) Register card information for the specified member. In addition, we will communicate with the card company using the shop ID set on the site and confirm the validity.
result = gmo.save_card 
  :member_id => 100,
  :card_no => "4111111111111111",
  :card_seq => "1000",
  :expire => "1405"
  • Delete Card (Delete Card) Delete the card information of the specified member.
result = gmo.delete_card 
  :member_id => 100,
  :card_seq => "1000"
  • Card reference (SearchCard) We will refer to the card information of the designated member.
result = gmo.search_card 
  :member_id => 100,
  :seq_mode => "0",
  :card_seq => "1000"
  • Settlement Execution (ExecTran) We will acquire the card information of the card registration serial number selected by the customer. If the card information does not correspond to the personal authentication service, it communicates with the card company and executes settlement. The output parameter at that time is the same as the output parameter of " Settlement execution".
result = gmo.exec_tran 
  :access_id => "access_id",
  :access_pass => "access_pass",
  :order_id => "100",
  :method => "1",
  :pay_times => "1",
  :member_id => 100,
  :card_seq => "1000",
  :seq_mode => "0",
  :amount => "0"

All Rights Reserved

Viblo
Let's register a Viblo Account to get more interesting posts.