Help us understand the problem. What is going on with this article?

Ruby ActiveMerchant sample code for WorldPay

More than 3 years have passed since last update.
require 'active_merchant'
require 'pp'

currency = 'USD'

gateway = ActiveMerchant::Billing::WorldpayGateway.new(
  :login => 'YOUR_MERCHANT_ID',
  :password => 'YOUR_XML_PASSWORD',
  :test => true,
)

money = 100


credit_card = ActiveMerchant::Billing::CreditCard.new(
  :number             => "4444333322221111",
  :month              => "12",
  :year               => Time.now.year + 1,
  :brand              => :visa,
  :first_name         => 'first',
  :last_name          => 'last',
)

order_id = 'label-' + Time.now.to_i.to_s



# 1. authorization
response1 = gateway.authorize(money, credit_card, {
  :order_id => order_id,
  :currency => currency,
})

pp response1


# 2. capture
#response2 = gateway.capture(money, response1.authorization, {
#  :authorization_validated => true, # avoid order status query
#})
#pp response2

# 3. void
#response3 = gateway.void(response1.authorization)
#pp response3


# 4. Reccuring payment (payAsOrder)
# Specify initial order_id instead of credit card comparing to the 1st payment.
subsequent_order_id = 'label-subsequent-' + Time.now.to_i.to_s
response4 = gateway.authorize(money, order_id, {
  :order_id => subsequent_order_id,
  :currency => currency,
})

pp response4


quoted from
http://matsu.teraren.com/blog/2014/02/25/worldpay-activemerchant/

matsubo
よろしくお願いします。
https://matsu.teraren.com/
minedia
テクノロジーの力で消費者の中に埋もれた価値を再発掘するためのサービスを開発するスタートアップ
https://corporate.minedia.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away