-
Notifications
You must be signed in to change notification settings - Fork 104
Shop API
kawaguchi edited this page Jul 4, 2020
·
8 revisions
GMO Gemでは、API呼び出しにGMOから与えられたショップID、ショップパスが必要になるAPIをShop APIと定義しています。 取引登録、決済ステータス変更等、決済に関するAPIが主です。
Shop APIは、GMO::Payment::ShopAPIクラスで扱うことができます。 初期化の際には、GMOから指定されたショップID、ショップパス、APIのホスト名を引数で渡す必要があります。
gmo = GMO::Payment::ShopAPI.new \
:shop_id => "foo",
:shop_pass => "bar",
:host => "mul-pay.com"
以降の決済取引で必要となる取引 ID と取引パスワードの発行を行い、取引を開始します。
result = gmo.entry_tran \
:order_id => 100,
:job_cd => "AUTH",
:amount => 100
gmo.entry_tran_brandtoken \
:order_id => "order_id",
:job_cd => "AUTH",
:item_code => "1000001",
:amount => 1000
=> {"AccessID"=>"139f8ec33a07c55f406937c52ce4473d", "AccessPass"=>"2689b204d2c17192fa35f9269fa7e744"}
コンビニ決済センターとの通信を行い取引の支払停止処理を行います。
result = gmo.cvs_cancel \
:order_id => order_id,
:access_id => access_id,
:access_pass => access_pass
カード番号と有効期限の情報を使用して、カード会社と通信を行い決済を実施し、結果を返します。
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"
gmo.exec_tran_brandtoken \
:order_id => "order_id",
:access_id => "access_id",
:access_pass => "access_pass",
:token_type => :apple_pay,
:token => "base64_encoded_payment_data"
=> {"Status"=>"CAPTURE", "OrderID"=>"order_id", "Forward"=>"2a99663", "Approve"=>"5487394", "TranID"=>"1707281634111111111111771216", "TranDate"=>"20170728163453", "ClientField1"=>"", "ClientField2"=>"", "ClientField3"=>""}
仮売上の決済に対して実売上を行います。尚、実行時に仮売上時との金額チェックを行います。
result = gmo.alter_tran \
:access_id => "access_id",
:access_pass => "access_pass",
:job_cd => "SALES",
:amount => 100
決済が完了した取引に対して金額の変更を行います。
result = gmo.change_tran \
:access_id => "access_id",
:access_pass => "access_pass",
:JobCd => 100,
:Amount => 100`
gmo.change_tran_brandtoken \
:access_id => "access_id",
:access_pass => "access_pass",
:order_id => "order_id",
:job_cd => "CAPTURE",
:amount => 1500
=> {"AccessID"=>"access_id", "AccessPass"=>"access_pass", "Status"=>"CAPTURE", "Forward"=>"2a99663", "Approve"=>"5538477", "TranID"=>"1707311633111111111111771224", "TranDate"=>"20170731163343"}
gmo.void_tran_brandtoken \
:access_id => "access_id",
:access_pass => "access_pass",
:order_id => "order_id"
=> {"AccessID"=>"access_id", "AccessPass"=>"access_pass", "Status"=>"VOID", "Forward"=>"2a99663", "Approve"=>"5537590", "TranID"=>"1707311610111111111111771219", "TranDate"=>"20170731161007"}
gmo.sales_tran_brandtoken \
:access_id => "access_id",
:access_pass => "access_pass",
:order_id => "order_id",
:amount => 1000
=> {"AccessID"=>"access_id", "AccessPass"=>"access_pass", "Status"=>"SALES", "Forward"=>"2a99663", "Approve"=>"5537883", "TranID"=>"1707311620111111111111771220", "TranDate"=>"20170731162256"}
gmo.refund_tran_brandtoken \
:access_id => "access_id",
:access_pass => "access_pass",
:order_id => "order_id",
:amount => 1000,
=> {"AccessID"=>"access_id", "AccessPass"=>"access_pass", "Status"=>"RETURN", "Forward"=>"2a99663", "Approve"=>"5537883", "TranID"=>"1707311620111111111111771220", "TranDate"=>"20170731162256"}
指定したオーダーID の取引情報を取得します。
result = gmo.search_trade \
:order_id => "order_id"
指定したオーダーIDの取引情報を取得します。
result = gmo.search_trade_multi \
:order_id => "order_id",
:pay_type => "0"