WebPay Ruby APIサンプル

* 参照: [Ruby APIドキュメント | WebPay: 開発者向けクレジットカード決済サービス](https://webpay.jp/docs/api/ruby)

----

# セットアップ

## Gemインストール

```rb
gem 'webpay', '~> 3.1'  # WebPay
```

```
bundle install
```

# 課金 (Charges)

## 新しい課金の作成

https://webpay.jp/docs/api/ruby#charge_create

```rb
    # 新しい課金の作成 : https://webpay.jp/docs/api/ruby#charge_create
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.charge.create(
      amount:   400,
      currency: "jpy",
      card: {
        number:    "4242-4242-4242-4242",
        exp_month: 11,
        exp_year:  2014,
        cvc:       "123",
        name:      "KEI KUBO"
      },
      description: "",
    ).to_hash.deep_symbolize_keys
    puts "[ ---------- 新しい課金の作成 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 新しい課金の作成 response ---------- ]
{
                 :id => "ch_6C86ki6pX4Xx3oT",
             :object => "charge",
           :livemode => false,
           :currency => "jpy",
        :description => "",
             :amount => 400,
    :amount_refunded => 0,
            :created => 1415774816,
               :paid => true,
           :refunded => false,
               :card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    },
           :captured => true,
               :fees => [
        [0] {
                      :object => "fee",
            :transaction_type => "payment",
             :transaction_fee => 0,
                        :rate => 3.25,
                      :amount => 13,
                     :created => 1415774816
        }
    ]
}
```

## 課金情報の取得

https://webpay.jp/docs/api/ruby#charge_retrieve

```rb
    # 課金情報の取得 : https://webpay.jp/docs/api/ruby#charge_retrieve
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.charge.retrieve(response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 課金情報の取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 課金情報の取得 response ---------- ]
{
                 :id => "ch_6C86ki6pX4Xx3oT",
             :object => "charge",
           :livemode => false,
           :currency => "jpy",
        :description => "",
             :amount => 400,
    :amount_refunded => 0,
            :created => 1415774816,
               :paid => true,
           :refunded => false,
               :card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    },
           :captured => true,
               :fees => [
        [0] {
                      :object => "fee",
            :transaction_type => "payment",
             :transaction_fee => 0,
                        :rate => 3.25,
                      :amount => 13,
                     :created => 1415774816
        }
    ]
}
```

## 課金の払い戻し

https://webpay.jp/docs/api/ruby#charge_refund

```rb
    # 課金の払い戻し : https://webpay.jp/docs/api/ruby#charge_refund
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.charge.refund('ch_3u32gEgiy2xjfEf').to_hash.deep_symbolize_keys
    puts "[ ---------- response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 課金の払い戻し response ---------- ]
{
                 :id => "ch_6C81Nx8LYcy5d3A",
             :object => "charge",
           :livemode => false,
           :currency => "jpy",
        :description => "",
             :amount => 400,
    :amount_refunded => 400,
            :created => 1415775004,
               :paid => true,
           :refunded => true,
               :card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    },
           :captured => true,
               :fees => [
        [0] {
                      :object => "fee",
            :transaction_type => "payment",
             :transaction_fee => 0,
                        :rate => 3.25,
                      :amount => 13,
                     :created => 1415775004
        },
        [1] {
                      :object => "fee",
            :transaction_type => "refund",
             :transaction_fee => 0,
                        :rate => 3.25,
                      :amount => -13,
                     :created => 1415775004
        }
    ]
}
```

## 仮売上の実売上化

https://webpay.jp/docs/api/ruby#charge_capture

```rb
    # 仮売上の実売上化 : https://webpay.jp/docs/api/ruby#charge_capture
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.charge.capture(id: response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 仮売上の実売上化 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 仮売上の実売上化 response ---------- ]
{
                 :id => "ch_6C853R6xy3T72GK",
             :object => "charge",
           :livemode => false,
           :currency => "jpy",
        :description => "",
             :amount => 400,
    :amount_refunded => 0,
            :created => 1415775053,
               :paid => true,
           :refunded => false,
               :card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    },
           :captured => true,
        :expire_time => 1416379853,
               :fees => [
        [0] {
                      :object => "fee",
            :transaction_type => "payment",
             :transaction_fee => 0,
                        :rate => 3.25,
                      :amount => 13,
                     :created => 1415775053
        }
    ]
}
```

## 課金リストの取得

https://webpay.jp/docs/api/ruby#charge_all

```rb
    # 課金リストの取得 : https://webpay.jp/docs/api/ruby#charge_all
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.charge.all(count: 3).to_hash.deep_symbolize_keys
    puts "[ ---------- 課金リストの取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 課金リストの取得 response ---------- ]
{
    :object => "list",
       :url => "/v1/charges",
     :count => 47294,
      :data => [
        [0] {
                         :id => "ch_6C84Jb36N1n9fCC",
                     :object => "charge",
                   :livemode => false,
                   :currency => "jpy",
                :description => "bob@customer.com",
                     :amount => 51,
            :amount_refunded => 0,
                    :created => 1415774536,
                       :paid => false,
                   :refunded => false,
                       :card => {
                     :object => "card",
                   :exp_year => 2015,
                  :exp_month => 9,
                :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                       :name => "Tobias Luetke",
                    :country => "JP",
                       :type => "Visa",
                  :cvc_check => "pass",
                      :last4 => "4242"
            },
                   :captured => false,
                :expire_time => 1416379336,
                       :fees => []
        },
        [1] {
                         :id => "ch_6C8cEw6pb2qp9IH",
                     :object => "charge",
                   :livemode => false,
                   :currency => "jpy",
                :description => "bob@customer.com",
                     :amount => 51,
            :amount_refunded => 0,
                    :created => 1415774398,
                       :paid => false,
                   :refunded => false,
                       :card => {
                     :object => "card",
                   :exp_year => 2015,
                  :exp_month => 9,
                :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                       :name => "Tobias Luetke",
                    :country => "JP",
                       :type => "Visa",
                  :cvc_check => "pass",
                      :last4 => "4242"
            },
                   :captured => false,
                :expire_time => 1416379198,
                       :fees => []
        },
        [2] {
                         :id => "ch_5WQ8f239U5EE00X",
                     :object => "charge",
                   :livemode => false,
                   :currency => "jpy",
                :description => "bob@customer.com",
                     :amount => 51,
            :amount_refunded => 51,
                    :created => 1415169147,
                       :paid => false,
                   :refunded => true,
                       :card => {
                     :object => "card",
                   :exp_year => 2015,
                  :exp_month => 9,
                :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                       :name => "Tobias Luetke",
                    :country => "JP",
                       :type => "Visa",
                  :cvc_check => "pass",
                      :last4 => "4242"
            },
                   :captured => false,
                :expire_time => 1415773947,
                       :fees => []
        }
    ]
}
```

# 顧客 (Customers)

## 新しい顧客の作成

```rb
    # 新しい顧客の作成 :https://webpay.jp/docs/api/ruby#customer_create
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.customer.create(
      card: {
        number:    "4242-4242-4242-4242",
        exp_month: 11,
        exp_year:  2014,
        cvc:       "123",
        name:      "KEI KUBO"
      },
      description: "Active Merchant Test Customer"
    ).to_hash.deep_symbolize_keys
    puts "[ ---------- 新しい顧客の作成 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 新しい顧客の作成 response ---------- ]
{
             :id => "cus_6C80071Eqa419Rn",
         :object => "customer",
       :livemode => false,
        :created => 1415776000,
    :description => "Active Merchant Test Customer",
    :active_card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    },
     :recursions => [],
        :deleted => false
}
```

## 顧客情報の取得

https://webpay.jp/docs/api/ruby#customer_retrieve

```rb
    # 顧客情報の取得 : https://webpay.jp/docs/api/ruby#customer_retrieve
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.customer.retrieve(response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 顧客情報の取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 顧客情報の取得 response ---------- ]
{
             :id => "cus_6C80VWaBDfA65Cd",
         :object => "customer",
       :livemode => false,
        :created => 1415776270,
    :description => "Active Merchant Test Customer",
    :active_card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    },
     :recursions => [],
        :deleted => false
}
```

## 顧客情報の更新

```rb
    # 顧客情報の更新 : https://webpay.jp/docs/api/ruby#customer_update
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.customer.update(description: "最新の顧客情報です", id: response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 顧客情報の更新 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 顧客情報の取得 response ---------- ]
{
             :id => "cus_6C86Jbd1d85N1nb",
         :object => "customer",
       :livemode => false,
        :created => 1415776613,
    :description => "最新の顧客情報です",
    :active_card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    },
     :recursions => [],
        :deleted => false
}
```

## 顧客の削除

https://webpay.jp/docs/api/ruby#customer_delete

```rb
    # 顧客の削除 : https://webpay.jp/docs/api/ruby#customer_delete
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.customer.delete(id: response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 顧客の削除 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 顧客の削除 response ---------- ]
{
         :id => "cus_6C83VM1u3cBEblm",
    :deleted => true
}
```

## 顧客リストの取得

https://webpay.jp/docs/api/ruby#customer_all

```rb
    # 顧客リストの取得 : https://webpay.jp/docs/api/ruby#customer_all
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.customer.all(count: 3).to_hash.deep_symbolize_keys
    puts "[ ---------- 顧客リストの取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 顧客リストの取得 response ---------- ]
{
    :object => "list",
       :url => "/v1/customers",
     :count => 616,
      :data => [
        [0] {
                     :id => "cus_6C85F9aLid36fTL",
                 :object => "customer",
               :livemode => false,
                :created => 1415777109,
            :description => "Active Merchant Test Customer",
            :active_card => {
                     :object => "card",
                   :exp_year => 2014,
                  :exp_month => 11,
                :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                       :name => "KEI KUBO",
                    :country => "JP",
                       :type => "Visa",
                  :cvc_check => "pass",
                      :last4 => "4242"
            },
             :recursions => [],
                :deleted => false
        },
        [1] {
                     :id => "cus_6C86Jbd1d85N1nb",
                 :object => "customer",
               :livemode => false,
                :created => 1415776613,
            :description => "最新の顧客情報です",
            :active_card => {
                     :object => "card",
                   :exp_year => 2014,
                  :exp_month => 11,
                :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                       :name => "KEI KUBO",
                    :country => "JP",
                       :type => "Visa",
                  :cvc_check => "pass",
                      :last4 => "4242"
            },
             :recursions => [],
                :deleted => false
        },
        [2] {
                     :id => "cus_6C85wRc4m5Jh2hy",
                 :object => "customer",
               :livemode => false,
                :created => 1415776595,
            :description => "最新の顧客情報です",
            :active_card => {
                     :object => "card",
                   :exp_year => 2014,
                  :exp_month => 11,
                :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                       :name => "KEI KUBO",
                    :country => "JP",
                       :type => "Visa",
                  :cvc_check => "pass",
                      :last4 => "4242"
            },
             :recursions => [],
                :deleted => false
        }
    ]
}
```

## 顧客のカード情報を削除

https://webpay.jp/docs/api/ruby#customer_delete_active_card

```rb
    # 顧客のカード情報を削除 : https://webpay.jp/docs/api/ruby#customer_delete_active_card
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.customer.delete_active_card(id: response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 顧客のカード情報を削除 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 顧客のカード情報を削除 response ---------- ]
{
             :id => "cus_6C8f3mcPp4EG8h3",
         :object => "customer",
       :livemode => false,
        :created => 1415777506,
    :description => "Active Merchant Test Customer",
     :recursions => [],
        :deleted => false
}
```

# トークン (Tokens)

https://webpay.jp/docs/api/ruby#tokens

## 新しいトークンの作成

https://webpay.jp/docs/api/ruby#token_create

```rb
    # 新しいトークンの作成 : https://webpay.jp/docs/api/ruby#token_create
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.token.create(
      card: {
        number:    "4242-4242-4242-4242",
        exp_month: 11,
        exp_year:  2014,
        cvc:       "123",
        name:      "KEI KUBO"
      }
    ).to_hash.deep_symbolize_keys
    puts "[ ---------- 新しいトークンの作成 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 新しいトークンの作成 response ---------- ]
{
          :id => "tok_6C818tdWv5nM7og",
      :object => "token",
    :livemode => false,
     :created => 1415778577,
        :used => false,
        :card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    }
}
```

## 作成済みトークンの取得

https://webpay.jp/docs/api/ruby#token_retrieve

```rb
    # 作成済みトークンの取得 : https://webpay.jp/docs/api/ruby#token_retrieve
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.token.retrieve(response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 作成済みトークンの取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 作成済みトークンの取得 response ---------- ]
{
          :id => "tok_6C8fZf6Cq3r8gh4",
      :object => "token",
    :livemode => false,
     :created => 1415778800,
        :used => false,
        :card => {
             :object => "card",
           :exp_year => 2014,
          :exp_month => 11,
        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
               :name => "KEI KUBO",
            :country => "JP",
               :type => "Visa",
          :cvc_check => "pass",
              :last4 => "4242"
    }
}
```

# 定期課金 (Recursions)

https://webpay.jp/docs/api/ruby#recursions

## 新しい定期課金の作成

https://webpay.jp/docs/api/ruby#recursion_create

```rb
    # 新しい定期課金の作成 : https://webpay.jp/docs/api/ruby#token_retrieve
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.recursion.create(
      amount:      400,
      currency:    "jpy",
      customer:    "cus_45d3MV5phaXJ4uv",
      period:      "month",
      description: "WebPayマガジン購読料"
    ).to_hash.deep_symbolize_keys
    puts "[ ---------- 新しい定期課金の作成 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 作成済みトークンの取得 response ---------- ]
{
                :id => "rec_6C8e7F4Fy1XXaVB",
            :object => "recursion",
          :livemode => false,
           :created => 1415779284,
            :amount => 400,
          :currency => "jpy",
            :period => "month",
       :description => "WebPayマガジン購読料",
          :customer => "cus_45d3MV5phaXJ4uv",
     :last_executed => 1415779284,
    :next_scheduled => 1418371284,
            :status => "active",
           :deleted => false
}
```

## 定期課金情報の取得

https://webpay.jp/docs/api/ruby#recursion_retrieve

```rb
    # 定期課金情報の取得 : https://webpay.jp/docs/api/ruby#recursion_retrieve
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.recursion.retrieve(response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 定期課金情報の取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 定期課金情報の取得 response ---------- ]
{
                :id => "rec_6C80tg8FW2tK2QK",
            :object => "recursion",
          :livemode => false,
           :created => 1415779847,
            :amount => 400,
          :currency => "jpy",
            :period => "month",
       :description => "WebPayマガジン購読料",
          :customer => "cus_45d3MV5phaXJ4uv",
     :last_executed => 1415779847,
    :next_scheduled => 1418371847,
            :status => "active",
           :deleted => false
}
```

## 一時停止中の定期課金の再開

https://webpay.jp/docs/api/ruby#recursion_resume

```rb
    # 一時停止中の定期課金の再開 : https://webpay.jp/docs/api/ruby#recursion_resume
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.recursion.resume(id: response[:id]).to_hash.deep_symbolize_keys
    puts "[ ---------- 一時停止中の定期課金の再開 response ---------- ]" ; response.tapp;
```

↓

※一時停止中の定期課金のテストデータが無いため、動作確認不可

## 定期課金の削除

https://webpay.jp/docs/api/ruby#recursion_delete

```rb
    # 定期課金の削除 : https://webpay.jp/docs/api/ruby#recursion_delete
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.recursion.delete(id: "rec_94T1gQgEI3LV27x").to_hash.deep_symbolize_keys
    puts "[ ---------- 定期課金の削除 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 定期課金の削除 response ---------- ]
{
         :id => "rec_94T1gQgEI3LV27x",
    :deleted => true
}
```

## 定期課金リストの取得

https://webpay.jp/docs/api/ruby#recursion_all

```rb
    # 定期課金リストの取得 : https://webpay.jp/docs/api/ruby#recursion_all
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.recursion.all(count: 3).to_hash.deep_symbolize_keys
    puts "[ ---------- 定期課金リストの取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- 定期課金リストの取得 response ---------- ]
{
    :object => "list",
       :url => "/v1/recursions",
     :count => 39,
      :data => [
        [0] {
                        :id => "rec_6C83p09dv9Cc1wC",
                    :object => "recursion",
                  :livemode => false,
                   :created => 1415780915,
                    :amount => 400,
                  :currency => "jpy",
                    :period => "month",
               :description => "WebPayマガジン購読料",
                  :customer => "cus_45d3MV5phaXJ4uv",
             :last_executed => 1415780915,
            :next_scheduled => 1418372915,
                    :status => "active",
                   :deleted => false
        },
        [1] {
                        :id => "rec_6C80cN0uif9N32I",
                    :object => "recursion",
                  :livemode => false,
                   :created => 1415780611,
                    :amount => 400,
                  :currency => "jpy",
                    :period => "month",
               :description => "WebPayマガジン購読料",
                  :customer => "cus_45d3MV5phaXJ4uv",
             :last_executed => 1415780611,
            :next_scheduled => 1418372611,
                    :status => "active",
                   :deleted => false
        },
        [2] {
                        :id => "rec_6C8eof9pu8H1e8i",
                    :object => "recursion",
                  :livemode => false,
                   :created => 1415780312,
                    :amount => 400,
                  :currency => "jpy",
                    :period => "month",
               :description => "WebPayマガジン購読料",
                  :customer => "cus_45d3MV5phaXJ4uv",
             :last_executed => 1415780312,
            :next_scheduled => 1418372312,
                    :status => "active",
                   :deleted => false
        }
    ]
}
```

# イベント (Events)

https://webpay.jp/docs/api/ruby#events

## イベント詳細の取得

https://webpay.jp/docs/api/ruby#event_retrieve

```rb
    # イベント詳細の取得 : https://webpay.jp/docs/api/ruby#event_retrieve
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.event.retrieve("evt_g4raMG6wR9qV39M").to_hash.deep_symbolize_keys
    puts "[ ---------- イベント詳細の取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- イベント詳細の取得 response ---------- ]
{
                  :id => "evt_g4raMG6wR9qV39M",
              :object => "event",
            :livemode => false,
                :type => "charge.succeeded",
             :created => 1408365217,
                :data => {
        :object => {
                         :id => "ch_g4raMG83qaNtdAs",
                     :object => "charge",
                   :livemode => false,
                   :currency => "jpy",
                     :amount => 1554,
            :amount_refunded => 0,
                    :created => 1408365217,
                       :paid => true,
                   :refunded => false,
                       :card => {
                     :object => "card",
                   :exp_year => 2015,
                  :exp_month => 8,
                :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                       :name => "KENGO HAMASAKI",
                    :country => "JP",
                       :type => "Visa",
                  :cvc_check => "pass",
                      :last4 => "4242"
            },
                   :captured => true,
                       :fees => [
                [0] {
                              :object => "fee",
                    :transaction_type => "payment",
                     :transaction_fee => 0,
                                :rate => 3.25,
                              :amount => 51,
                             :created => 1408365217
                }
            ]
        }
    },
    :pending_webhooks => 0
}
```

## イベントリストの取得

https://webpay.jp/docs/api/ruby#event_all

```rb
    # イベントリストの取得 : https://webpay.jp/docs/api/ruby#event_all
    webpay   = WebPay.new('test_secret_eHn4TTgsGguBcW764a2KA8Yd')
    response = webpay.event.all(count: 3).to_hash.deep_symbolize_keys
    puts "[ ---------- イベントリストの取得 response ---------- ]" ; response.tapp;
```

↓

```rb
[ ---------- イベントリストの取得 response ---------- ]
{
    :object => "list",
       :url => "/v1/events",
     :count => 42754,
      :data => [
        [0] {
                          :id => "evt_6C89Jj9Ld48402I",
                      :object => "event",
                    :livemode => false,
                        :type => "charge.succeeded",
                     :created => 1415781778,
                        :data => {
                :object => {
                                 :id => "ch_6C89FbgiM6hmadx",
                             :object => "charge",
                           :livemode => false,
                           :currency => "jpy",
                        :description => "bob@customer.com",
                             :amount => 51,
                    :amount_refunded => 0,
                            :created => 1415781778,
                               :paid => false,
                           :refunded => false,
                               :card => {
                             :object => "card",
                           :exp_year => 2015,
                          :exp_month => 9,
                        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                               :name => "Tobias Luetke",
                            :country => "JP",
                               :type => "Visa",
                          :cvc_check => "pass",
                              :last4 => "4242"
                    },
                           :captured => false,
                        :expire_time => 1416386578,
                               :fees => []
                }
            },
            :pending_webhooks => 0
        },
        [1] {
                          :id => "evt_6C814x8x87dAf6u",
                      :object => "event",
                    :livemode => false,
                        :type => "charge.succeeded",
                     :created => 1415781648,
                        :data => {
                :object => {
                                 :id => "ch_6C814x7Pf1yX6Em",
                             :object => "charge",
                           :livemode => false,
                           :currency => "jpy",
                        :description => "bob@customer.com",
                             :amount => 51,
                    :amount_refunded => 0,
                            :created => 1415781648,
                               :paid => false,
                           :refunded => false,
                               :card => {
                             :object => "card",
                           :exp_year => 2015,
                          :exp_month => 9,
                        :fingerprint => "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
                               :name => "Tobias Luetke",
                            :country => "JP",
                               :type => "Visa",
                          :cvc_check => "pass",
                              :last4 => "4242"
                    },
                           :captured => false,
                        :expire_time => 1416386448,
                               :fees => []
                }
            },
            :pending_webhooks => 0
        },
        [2] {
                          :id => "evt_6C8aNm3Jr5UmbIW",
                      :object => "event",
                    :livemode => false,
                        :type => "recursion.succeeded",
                     :created => 1415781538,
                        :data => {
                :object => {
                                :id => "rec_6C8aNm4U9fT198I",
                            :object => "recursion",
                          :livemode => false,
                           :created => 1415781538,
                            :amount => 400,
                          :currency => "jpy",
                            :period => "month",
                       :description => "WebPayマガジン購読料",
                          :customer => "cus_45d3MV5phaXJ4uv",
                     :last_executed => 1415781538,
                    :next_scheduled => 1418373538,
                            :status => "active",
                           :deleted => false
                }
            },
            :pending_webhooks => 0
        }
    ]
}
```