LoginSignup
2
2

More than 5 years have passed since last update.

mfkessaiをrubyで使う

Last updated at Posted at 2018-06-13

Mfkessaiサービスをrubyで実装する

Mfkessaiとは請求代行サービス、詳しいURL

公開されている以下のgemを使う

ライブラリは、利用可能なアカウントの秘密鍵と本番環境かテスト環境かのURLの設定をする必要があります。

簡単な例

require "mfkessai"
Mfkessai.api_url = "https://sandbox"
Mfkessai.api_key = "mfkessai_test_..."

# list customers
Mfkessai::Customer.list

# retrieve single customer
Mfkessai::Customer.retrieve("customer_test_123")

決済の取引を行なう

require "mfkessai"
Mfkessai.api_url = "https://sandbox"
Mfkessai.api_key = "mfkessai_test_..."

# 取引を登録
params = {
  "amount": 2160,
  "date": "2018-04-16T00:00:00+09:00",
  "destination": {
    "address1": "千代田区1-2-3",
    "address2": "サンプルビル3F",
    "cc_emails": [
      "another.test1@example.jp",
      "another.test2@example.jp"
    ],
    "customer": {
      "office_name": "サンプル商事株式会社",
      "user_defined_id": "customer123456"
    },
    "customer_id": "ABCD-EFGH",
    "department": "経理部",
    "email": "kesai.tanto@example.jp",
    "name": "請求先氏名",
    "prefecture": "東京都",
    "tel": "03-1234-5678",
    "title": "",
    "zip_code": "111-1111"
  },
  "destination_id": "XXXX-YYYY",
  "due_date": "2018-05-31T00:00:00+09:00",
  "email_flag": true,
  "issue_date": "2018-05-16T00:00:00+09:00",
  "posting_flag": false,
  "transaction_details": [
    {
      "amount": 2000,
      "description": "商品名A",
      "quantity": 2,
      "unit_price": 1000
    },
    {
      "amount": 160,
      "description": "消費税",
      "quantity": 1,
      "unit_price": 160
    }
  ],
  "user_defined_id": "transaction00000001"
}

Mfkessai::Transaction.create(request_body: params)

顧客のリスト取得する

require "mfkessai"
Mfkessai.api_url = "https://sandbox"
Mfkessai.api_key = "mfkessai_test_..."

# 顧客リストを取得
Mfkessai::Customer.list

詳しい使用方法・対応APIはREADME.mdを参考にしてください

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2