Skip to content

Commit

Permalink
Paypal決済対応
Browse files Browse the repository at this point in the history
  • Loading branch information
ken1flan committed Oct 3, 2023
1 parent 05984a1 commit b71f367
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions lib/gmo/shop_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ def entry_tran_pay_easy(options = {})
post_request name, options
end

# 【PayPal決済】
# 取引登録
# これ以降の決済取引で必要となる取引IDと取引パスワードの発行を行い、取引を開始します。
def entry_tran_paypal(options = {})
name = "EntryTranPaypal.idPass"
required = [:order_id, :job_cd, :amount]
assert_required_options(required, options)
post_request name, options
end

# 【LINE Pay決済】
# 20.1.2.1. 取引登録
# これ以降の決済取引で必要となる取引IDと取引パスワードの発行を行い、取引を開始します。
Expand Down Expand Up @@ -322,6 +332,16 @@ def exec_tran_pay_easy(options = {})
post_request name, options
end

# 【PayPal決済】
# 決済実行
# PayPalと通信を行い決済要求結果を返します。
def exec_tran_paypal(options = {})
name = "ExecTranPaypal.idPass"
required = [:access_id, :access_pass, :order_id, :item_name, :redirect_url]
assert_required_options(required, options)
post_request name, options
end

# 【LINE Pay決済】
# 20.1.2.2. 決済実行
def exec_tran_linepay(options = {})
Expand Down
46 changes: 46 additions & 0 deletions spec/gmo/shop_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@
end
end

describe "#entry_tran_paypal" do
it "gets data about a transaction", :vcr do
order_id = @order_id
result = @service.entry_tran_paypal({
:order_id => order_id,
:job_cd => 'CAPTURE',
:amount => 100
})
result["AccessID"].nil?.should_not be_truthy
result["AccessPass"].nil?.should_not be_truthy
end

it "got error if missing options", :vcr do
lambda {
result = @service.entry_tran_paypal()
}.should raise_error("Required order_id, job_cd, amount were not provided.")
end
end

describe "#entry_tran_linepay" do
it "gets data about a transaction", :vcr do
order_id = @order_id
Expand Down Expand Up @@ -429,6 +448,33 @@
end
end

describe "#exec_tran_paypal" do
it "gets data about a transaction", :vcr do
order_id = generate_id
result = @service.entry_tran_paypal({
:order_id => order_id,
:job_cd => 'CAPTURE',
:amount => 100
})
access_id = result["AccessID"]
access_pass = result["AccessPass"]
result = @service.exec_tran_paypal({
:order_id => order_id,
:access_id => access_id,
:access_pass => access_pass,
:redirect_url => 'https://example.com/path/to/redirect',
:item_name => '購入する商品名'
})
result["OrderID"].nil?.should_not be_truthy
end

it "got error if missing options", :vcr do
lambda {
result = @service.exec_tran_paypal()
}.should raise_error("Required access_id, access_pass, order_id, item_name, redirect_url were not provided.")
end
end

describe "#exec_tran_linepay" do
it "gets data about a transaction", :vcr do
order_id = generate_id
Expand Down

0 comments on commit b71f367

Please sign in to comment.