ActiveMerchant GMO-PG
An ActiveMerchant gateway that wraps the GMO Payment Gateway (GMO-PG) payment API.
Features
- Register / delete stored credit cards (member management)
- Authorize, immediate capture, capture, void, refund
- 3DS2.0 authentication
- Token-based payments
- Multiple cards per member
Installation
Add this line to your Gemfile:
gem 'active_merchant_gmo_pg'
Then run:
bundle install
Usage
Initializing the gateway
gateway = ActiveMerchant::Billing::GmoPgGateway.new(
shop_id: 'your_shop_id',
shop_pass: 'your_shop_pass',
site_id: 'your_site_id',
site_pass: 'your_site_pass',
test: true # set to false in production
)
Registering a card
credit_card = ActiveMerchant::Billing::CreditCard.new(
number: '4111111111111111',
month: 12,
year: 2025,
verification_value: '123',
first_name: 'Taro',
last_name: 'Yamada'
)
response = gateway.store(credit_card, member_id: 'user123')
if response.success?
# response.authorization contains an identifier in "member_id|card_seq" form
puts "Card registered: #{response.}"
else
puts "Error: #{response.}"
end
Authorize
response = gateway.(1000, credit_card, order_id: 'order123')
if response.success?
puts "Authorized: #{response.}"
else
puts "Error: #{response.}"
end
Immediate capture (purchase)
response = gateway.purchase(1000, credit_card, order_id: 'order124')
if response.success?
puts "Charged: #{response.}"
else
puts "Error: #{response.}"
end
Capture
response = gateway.capture(1000, )
if response.success?
puts "Captured"
else
puts "Error: #{response.}"
end
Void
response = gateway.void()
if response.success?
puts "Voided"
else
puts "Error: #{response.}"
end
Refund
response = gateway.credit(1000, )
if response.success?
puts "Refunded"
else
puts "Error: #{response.}"
end
Deleting a stored card
response = gateway.unstore()
if response.success?
puts "Card deleted"
else
puts "Error: #{response.}"
end
3DS2.0 authentication
To use 3DS2.0, pass the ret_url option to authorize or purchase:
response = gateway.(1000, credit_card,
order_id: 'order125',
ret_url: 'https://example.com/callback'
)
if response.success?
redirect_url = response.params['RedirectUrl']
# Redirect the user to redirect_url to complete 3DS authentication
end
Configuration
Switching environments
For production, pass test: false:
gateway = ActiveMerchant::Billing::GmoPgGateway.new(
shop_id: 'your_shop_id',
shop_pass: 'your_shop_pass',
site_id: 'your_site_id',
site_pass: 'your_site_pass',
test: false
)
Licence
MIT License.