taiwan_payments 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +24 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.ja.md +293 -0
  5. data/README.md +291 -0
  6. data/README.zh-TW.md +293 -0
  7. data/docs/ecpay-invoices.md +202 -0
  8. data/docs/ecpay-payments.md +191 -0
  9. data/docs/glossary/concepts.ja.md +33 -0
  10. data/docs/glossary/concepts.md +34 -0
  11. data/docs/glossary/ecpay-invoice.ja.md +113 -0
  12. data/docs/glossary/ecpay-invoice.md +114 -0
  13. data/docs/glossary/ecpay-payment.ja.md +64 -0
  14. data/docs/glossary/ecpay-payment.md +65 -0
  15. data/docs/rails.md +184 -0
  16. data/docs/sandbox-setup.md +104 -0
  17. data/docs/taiwan-payments-101.ja.md +138 -0
  18. data/docs/taiwan-payments-101.md +138 -0
  19. data/docs/taiwan-payments-101.zh-TW.md +138 -0
  20. data/docs/testing.md +140 -0
  21. data/docs/webhooks.md +113 -0
  22. data/exe/taiwan_payments +6 -0
  23. data/lib/generators/taiwan_payments/install/install_generator.rb +41 -0
  24. data/lib/generators/taiwan_payments/install/templates/ecpay_controller.rb.tt +26 -0
  25. data/lib/generators/taiwan_payments/install/templates/initializer.rb.tt +38 -0
  26. data/lib/taiwan_payments/cli.rb +271 -0
  27. data/lib/taiwan_payments/configuration.rb +86 -0
  28. data/lib/taiwan_payments/credentials.rb +27 -0
  29. data/lib/taiwan_payments/decimal.rb +36 -0
  30. data/lib/taiwan_payments/ecpay/aes_cipher.rb +36 -0
  31. data/lib/taiwan_payments/ecpay/check_mac_value.rb +63 -0
  32. data/lib/taiwan_payments/ecpay/checkout.rb +154 -0
  33. data/lib/taiwan_payments/ecpay/invoice_client.rb +253 -0
  34. data/lib/taiwan_payments/ecpay/invoice_mapper.rb +222 -0
  35. data/lib/taiwan_payments/ecpay/payment_client.rb +188 -0
  36. data/lib/taiwan_payments/ecpay/payment_methods.rb +40 -0
  37. data/lib/taiwan_payments/ecpay/payment_notification.rb +127 -0
  38. data/lib/taiwan_payments/ecpay/response_body.rb +30 -0
  39. data/lib/taiwan_payments/ecpay/trade_info.rb +68 -0
  40. data/lib/taiwan_payments/ecpay.rb +19 -0
  41. data/lib/taiwan_payments/environment.rb +22 -0
  42. data/lib/taiwan_payments/error_codes/ecpay_invoice.yml +80 -0
  43. data/lib/taiwan_payments/error_codes/ecpay_payment.yml +59 -0
  44. data/lib/taiwan_payments/error_codes.rb +23 -0
  45. data/lib/taiwan_payments/errors.rb +71 -0
  46. data/lib/taiwan_payments/form_helper.rb +21 -0
  47. data/lib/taiwan_payments/glossary/concepts.yml +122 -0
  48. data/lib/taiwan_payments/glossary/ecpay_invoice.yml +523 -0
  49. data/lib/taiwan_payments/glossary/ecpay_payment.yml +278 -0
  50. data/lib/taiwan_payments/glossary.rb +106 -0
  51. data/lib/taiwan_payments/hosted_form.rb +46 -0
  52. data/lib/taiwan_payments/http_client.rb +62 -0
  53. data/lib/taiwan_payments/instrumentation.rb +42 -0
  54. data/lib/taiwan_payments/invoice.rb +235 -0
  55. data/lib/taiwan_payments/money.rb +32 -0
  56. data/lib/taiwan_payments/php_compat.rb +39 -0
  57. data/lib/taiwan_payments/railtie.rb +23 -0
  58. data/lib/taiwan_payments/redactor.rb +29 -0
  59. data/lib/taiwan_payments/taipei_time.rb +42 -0
  60. data/lib/taiwan_payments/tax_id.rb +26 -0
  61. data/lib/taiwan_payments/testing.rb +152 -0
  62. data/lib/taiwan_payments/validation.rb +56 -0
  63. data/lib/taiwan_payments/version.rb +5 -0
  64. data/lib/taiwan_payments/webhooks.rb +54 -0
  65. data/lib/taiwan_payments.rb +67 -0
  66. metadata +118 -0
@@ -0,0 +1,191 @@
1
+ # ECPay payments
2
+
3
+ ECPay (綠界科技) calls this product 全方位金流, or AIO. You send the customer to a payment page hosted by ECPay, and ECPay calls your server with the result.
4
+
5
+ Every vendor field mentioned here is explained in the [ECPay payment glossary](glossary/ecpay-payment.md). If the flow is new to you, read [Taiwan payments 101](taiwan-payments-101.md) first.
6
+
7
+ ## The client
8
+
9
+ ```ruby
10
+ # ECPay's public test merchant. Nothing to sign up for.
11
+ payments = TaiwanPayments::ECPay::PaymentClient.sandbox
12
+
13
+ # Your own merchant.
14
+ payments = TaiwanPayments::ECPay::PaymentClient.new(
15
+ merchant_id: "1234567",
16
+ hash_key: ENV.fetch("ECPAY_HASH_KEY"),
17
+ hash_iv: ENV.fetch("ECPAY_HASH_IV"),
18
+ env: :production # or :sandbox. Required, so going live is always deliberate.
19
+ )
20
+ ```
21
+
22
+ A client is immutable and safe to share between threads. Its `inspect` never shows the keys. Platform merchants (特約合作平台商) can pass `platform_id:`.
23
+
24
+ The payment product and the e-invoice product have **different** merchant IDs and keys. Payment keys will not work for invoices.
25
+
26
+ ## Checkout
27
+
28
+ ```ruby
29
+ form = payments.checkout(
30
+ order_no: "ORD1001",
31
+ amount: 1200,
32
+ description: "Order 1001",
33
+ items: ["Oolong tea x2", "Shipping"],
34
+ return_url: "https://shop.example/webhooks/ecpay/payment"
35
+ )
36
+ ```
37
+
38
+ `checkout` returns a `TaiwanPayments::HostedForm`. ECPay only accepts a checkout that is POSTed by the customer's browser, so the gem never sends it for you.
39
+
40
+ ```ruby
41
+ form.action_url # where the form posts to
42
+ form.fields # the signed fields, as a Hash of Strings
43
+ form.to_html # a <form> that submits itself, with a <noscript> button
44
+ form.to_html(auto_submit: false, submit_text: "Pay now") # a visible button instead
45
+ form.to_html(nonce: csp_nonce) # for a strict Content-Security-Policy
46
+ ```
47
+
48
+ In Rails, `<%= taiwan_payments_form(@form) %>` does this and adds the CSP nonce for you.
49
+
50
+ ### Required arguments
51
+
52
+ | Argument | ECPay field | Rule |
53
+ | --- | --- | --- |
54
+ | `order_no:` | `MerchantTradeNo` | 1 to 20 letters and digits, unique per attempt. ECPay refuses a reused number even if the first attempt failed, so add a suffix when a customer retries. |
55
+ | `amount:` | `TotalAmount` | Whole TWD. A fractional amount raises instead of being rounded. |
56
+ | `description:` | `TradeDesc` | Shortened to 200 bytes. |
57
+ | `items:` | `ItemName` | An array of names. Joined with `#` and shortened to 400 bytes. |
58
+ | `return_url:` | `ReturnURL` | Your server-to-server webhook. Must be public. |
59
+
60
+ The two display fields are shortened before signing, on a character boundary, because ECPay otherwise cuts them after the signature has been computed and then rejects the signature.
61
+
62
+ ### Choosing payment methods
63
+
64
+ ```ruby
65
+ # order holds the required arguments shown above
66
+ payments.checkout(**order, payment_method: :credit)
67
+ payments.checkout(**order, payment_method: :all, ignore_methods: [:barcode, :web_atm])
68
+ ```
69
+
70
+ | Symbol | ECPay name | What it is |
71
+ | --- | --- | --- |
72
+ | `:all` | `ALL` | The customer chooses on ECPay's page. Default. |
73
+ | `:credit` | `Credit` | Credit card |
74
+ | `:atm` | `ATM` | Bank transfer to a one-off virtual account |
75
+ | `:cvs` | `CVS` | Convenience store kiosk code |
76
+ | `:barcode` | `BARCODE` | Convenience store barcode |
77
+ | `:web_atm` | `WebATM` | Bank card through a card reader |
78
+ | `:apple_pay` | `ApplePay` | Apple Pay |
79
+ | `:twqr` | `TWQR` | TWQR mobile payments |
80
+ | `:bnpl` | `BNPL` | Buy now, pay later |
81
+ | `:weixin` | `WeiXin` | WeChat Pay |
82
+ | `:digital_payment` | `DigitalPayment` | Other digital wallets |
83
+
84
+ Which methods are available depends on your merchant contract. ECPay's own spelling (`"Credit"`) is accepted too.
85
+
86
+ ### Optional arguments
87
+
88
+ | Argument | ECPay field | Notes |
89
+ | --- | --- | --- |
90
+ | `client_back_url:` | `ClientBackURL` | The "back to shop" link on ECPay's page. Carries no result. |
91
+ | `order_result_url:` | `OrderResultURL` | The customer's browser is POSTed here with the result. Must differ from `return_url`. See [Webhooks](webhooks.md). |
92
+ | `payment_info_url:` | `PaymentInfoURL` | Webhook for the ATM account or store code that was issued. |
93
+ | `client_redirect_url:` | `ClientRedirectURL` | The browser is POSTed here with the ATM account or store code. |
94
+ | `language:` | `Language` | `:en`, `:ja`, `:ko` or `:zh_cn`. Traditional Chinese when omitted. |
95
+ | `custom_fields:` | `CustomField1` to `4` | Up to four strings of 50 characters, echoed back in callbacks. |
96
+ | `installments:` | `CreditInstallment` | Terms to offer, such as `[3, 6, 12]`. |
97
+ | `redeem:` | `Redeem` | `true` lets the customer use card reward points. |
98
+ | `union_pay:` | `UnionPay` | `0` customer chooses, `1` UnionPay only, `2` hide UnionPay. |
99
+ | `atm_expire_days:` | `ExpireDate` | Days allowed to pay an ATM transfer, 1 to 60. |
100
+ | `store_expire:` | `StoreExpireDate` | Minutes for `:cvs`, days for `:barcode`. |
101
+ | `store_descriptions:` | `Desc_1` to `4` | Up to four lines of 20 characters printed at the kiosk. |
102
+ | `sub_method:` | `ChooseSubPayment` | A vendor code that narrows the method, such as one bank. |
103
+ | `extra_paid_info:` | `NeedExtraPaidInfo` | `true` adds card digits, bank codes and similar to the callback. |
104
+ | `store_id:`, `remark:`, `item_url:` | `StoreID`, `Remark`, `ItemURL` | Passed through. |
105
+ | `trade_date:` | `MerchantTradeDate` | Defaults to now. Sent in Taiwan time. |
106
+ | `extra:` | any | A Hash of raw ECPay fields for anything not modelled, such as periodic billing. |
107
+
108
+ Invalid input raises `TaiwanPayments::ValidationError` before anything is signed. The message names both the argument and the ECPay field.
109
+
110
+ ## Callbacks
111
+
112
+ ```ruby
113
+ notification = payments.notification(request.request_parameters)
114
+ ```
115
+
116
+ `notification` verifies `CheckMacValue` and raises `TaiwanPayments::SignatureError` when it does not match. You cannot get a notification object from unverified data.
117
+
118
+ | Reader | ECPay field | |
119
+ | --- | --- | --- |
120
+ | `status` | `RtnCode`, `SimulatePaid` | `:paid`, `:awaiting_payment`, `:simulated` or `:failed` |
121
+ | `paid?` | | Real, completed payment. Never true for a simulated one. |
122
+ | `awaiting_payment?` | `RtnCode` 2 or 10100073 | A payment code was issued. A paid callback follows later. |
123
+ | `simulated?` | `SimulatePaid` | Sent by the back office "simulate payment" button. No money moved. |
124
+ | `failed?` | | Anything else. `status_code` and `message` say why. |
125
+ | `order_no` | `MerchantTradeNo` | Your order number |
126
+ | `trade_no` | `TradeNo` | ECPay's number. Store it. Card refunds need it. |
127
+ | `amount` | `TradeAmt` | Integer TWD. Compare it with your order. |
128
+ | `payment_method` | `PaymentType` | `:credit`, `:atm` and so on. `payment_type` is ECPay's detailed string. |
129
+ | `paid_at`, `ordered_at` | `PaymentDate`, `TradeDate` | `Time` in Taiwan time, or `nil` |
130
+ | `fee` | `PaymentTypeChargeFee` | ECPay's fee in TWD |
131
+ | `custom_fields` | `CustomField1` to `4` | Array of four strings |
132
+ | `payment_instructions` | `BankCode`, `vAccount`, `PaymentNo`, `Barcode1` to `3`, `ExpireDate` | Present when `awaiting_payment?` |
133
+ | `raw`, `[]` | | Every field exactly as ECPay sent it |
134
+ | `ack` | | `"1|OK"`, the body ECPay expects back |
135
+
136
+ For payments that are not instant, show the customer how to pay:
137
+
138
+ ```ruby
139
+ if notification.awaiting_payment?
140
+ instructions = notification.payment_instructions
141
+ instructions.payment_method # :atm, :cvs or :barcode
142
+ instructions.bank_code # ATM
143
+ instructions.virtual_account # ATM
144
+ instructions.payment_no # convenience store code
145
+ instructions.barcodes # three barcode segments
146
+ instructions.expires_at # deadline
147
+ end
148
+ ```
149
+
150
+ [Webhooks](webhooks.md) explains which URL receives what, and how to respond.
151
+
152
+ ## Querying an order
153
+
154
+ ```ruby
155
+ trade = payments.query(order_no: "ORD1001")
156
+ ```
157
+
158
+ Returns `nil` when ECPay has no such order, which is normal if the customer never reached the payment page. Otherwise it returns a `TradeInfo` with `status` (`:paid`, `:unpaid` or `:failed`), `paid?`, `amount`, `trade_no`, `payment_method`, `paid_at`, `fee`, `custom_fields` and `raw`.
159
+
160
+ Use it to reconcile orders whose callback never arrived. Do not poll in a tight loop: ECPay answers HTTP 403 to a merchant that calls too often and keeps refusing for a while. That surfaces as `TaiwanPayments::RateLimitedError`.
161
+
162
+ The response signature is verified. A response that fails raises `SignatureError`.
163
+
164
+ ## Card capture and refund
165
+
166
+ ```ruby
167
+ payments.refund(order_no: "ORD1001", trade_no: notification.trade_no, amount: 500)
168
+
169
+ # The other three take the same arguments.
170
+ payments.capture(order_no: "ORD1001", trade_no: trade_no, amount: 1200) # 關帳: settle an authorised payment
171
+ payments.cancel_capture(order_no: "ORD1001", trade_no: trade_no, amount: 1200) # 取消關帳: undo a capture before settlement
172
+ payments.void_authorization(order_no: "ORD1001", trade_no: trade_no, amount: 1200) # 放棄: release an authorisation
173
+ ```
174
+
175
+ These apply to credit card payments only. Each returns a `CreditActionResult` or raises `ApiError`. Most merchants are set up to capture automatically and only ever need `refund`. Instalment and reward-point payments can only be refunded in full.
176
+
177
+ **Read this before relying on them.** This is the one part of the gem that has not been run end to end. A successful capture or refund needs a completed card payment, which cannot be made from a script. The request format follows ECPay's documentation and the error handling was verified against real stage responses. Try a refund on a small real payment before you depend on it.
178
+
179
+ Refunds for ATM and convenience store payments are not available through this API. You arrange those with the customer directly.
180
+
181
+ ## Things that go wrong
182
+
183
+ | Symptom | Cause |
184
+ | --- | --- |
185
+ | `ApiError 10200073` or ECPay's page says CheckMacValue Error | Wrong keys, or keys from the e-invoice product |
186
+ | ECPay's page says the order number is duplicated | `order_no` was used before, even by a failed attempt |
187
+ | The callback never arrives | `return_url` is not public, or your endpoint did not answer `1|OK` to an earlier attempt |
188
+ | Orders marked paid that were never paid | Code trusted `RtnCode` and ignored `SimulatePaid`. Use `paid?`. |
189
+ | `RateLimitedError` | Too many `query` calls |
190
+
191
+ Debug a signature from the terminal with `taiwan_payments ecpay mac`.
@@ -0,0 +1,33 @@
1
+ <!-- Generated by `rake docs:glossary` from lib/taiwan_payments/glossary/concepts.yml. Edit that file, not this one. -->
2
+
3
+ # 台湾の決済・発票用語集
4
+
5
+ 各行は、フィールドまたは用語、その中国語名、意味、そして `taiwan_payments` での書き方を示します。
6
+
7
+ 参考資料: https://www.einvoice.nat.gov.tw/
8
+
9
+ | 用語 | 中国語 | 意味 | この gem での書き方 |
10
+ | --- | --- | --- | --- |
11
+ | **Uniform invoice** | 統一發票 | すべての事業者が販売のたびに発行しなければならない、政府が定めた領収書です。各発票の番号が 2 か月ごとの公営宝くじ(統一発票の宝くじ)の抽せん対象になるため、消費者は発票を受け取りたがります。 | `TaiwanPayments::Invoice` |
12
+ | **E-invoice** | 電子發票 | ECPay(綠界科技)などの認定プロバイダーを通じて電子的に発行する統一発票です。発票のデータはプロバイダーが財政部へ報告します。 | `ECPay::InvoiceClient` |
13
+ | **Tax ID** | 統一編號(統編) | 会社や団体を識別する 8 桁の番号です。購入者は、経理処理のために事業者向けの発票が必要な場合に自社の番号を伝えます。 | `buyer: {tax_id:}`, `TaxId.valid?` |
14
+ | **Carrier** | 載具 | ペーパーレスの発票を購入者のために保存しておく場所です。これにより、宝くじの当せん金を本人に結び付けられます。 | `carrier:` |
15
+ | **Mobile barcode** | 手機條碼 | 最も一般的なキャリアです。/ABC+123 のようなコードで、個人が財政部に一度登録しておき、買い物のたびに提示します。 | `carrier: "/ABC+123"` |
16
+ | **Citizen digital certificate** | 自然人憑證 | 政府が発行する IC カード型の身分証明書です。その番号(英字 2 文字と数字 14 桁)をキャリアとして利用できます。 | `carrier: "AB12345678901234"` |
17
+ | **Member carrier** | 會員載具 | 発票プロバイダー自身が運営するキャリアで、購入者のメールアドレスまたは電話番号で識別します。購入者がキャリアを指定しない場合の既定値です。 | `carrier: :member` |
18
+ | **Donation code** | 捐贈碼(愛心碼) | 登録済みの慈善団体を表す 3〜7 桁のコードです。購入者は発票を、当せんした場合の賞金も含めてその団体に寄付します。 | `donation_code:` |
19
+ | **Random number** | 隨機碼 | 各発票に記載される 4 桁のコードです。発票番号と組み合わせることで、購入者が発票を照会できます。 | `random_number` |
20
+ | **Invoice number track** | 字軌 | 税務当局が 2 か月の期間ごとに事業者へ割り当てる発票番号の範囲です。範囲を使い切ると、プロバイダーは発票を発行できなくなります。 | `ApiError` codes 1500047 and 5070350 |
21
+ | **Void** | 作廢 | 発票全体を取り消すことです。発票を発行した 2 か月の期間内に限り可能です。 | `void` |
22
+ | **Allowance** | 折讓 | 発票に対して発行する減額伝票(クレジットノート)です。一部返金や、2 か月の期間が締め切られた後の返品に使います。 | `allowance` |
23
+ | **Taxable, zero-rated, exempt** | 應稅、零稅率、免稅 | 3 種類の課税区分です。課税は通常の 5% の営業税、ゼロ税率は主に輸出、免税は特定の商品やサービスが対象です。 | `tax_type:` |
24
+ | **Merchant** | 特店 | 決済プロバイダーのアカウントを持つ事業者です。各ベンダーはこのアカウントを「特店」、その ID を「特店編號」と呼びます。 | `merchant_id:` |
25
+ | **Convenience store code** | 超商代碼 | 購入者が 7-ELEVEN、FamilyMart、Hi-Life、OK Mart の店頭端末に入力するコードです。入力後、レジで現金で支払います。 | `payment_method: :cvs` |
26
+ | **Convenience store barcode** | 超商條碼 | 購入者がレジで提示して現金で支払うための 3 つのバーコードです。 | `payment_method: :barcode` |
27
+ | **Virtual account** | 虛擬帳號 | 注文ごとに生成される 1 回限りの銀行口座番号です。購入者は ATM またはオンラインバンキングからこの口座に振り込みます。 | `payment_method: :atm` |
28
+ | **WebATM** | 網路 ATM | 購入者のパソコンに接続したカードリーダーを使い、銀行のキャッシュカードで支払う方法です。 | `payment_method: :web_atm` |
29
+ | **Capture** | 關帳(請款) | オーソリ(与信)済みのカード決済を確定し、実際に代金を回収する処理です。ほとんどの加盟店では自動で行われます。 | `capture` |
30
+ | **Refund** | 退刷(退款) | 売上確定済みのカード決済の代金を返すことです。 | `refund` |
31
+ | **Instalments** | 分期付款 | カード決済を 3〜30 か月に分けて支払う方法です。台湾では広く使われており、購入者には無利息の場合も多くあります。 | `installments:` |
32
+ | **Reward points** | 紅利折抵 | 購入代金の一部をクレジットカードのポイントで支払うことです。 | `redeem:` |
33
+ | **Simulated payment** | 模擬付款 | ベンダーの管理画面にあるボタンで、テスト環境だけでなく本番環境にもあります。お金を動かさずに、偽の「支払い済み」コールバックを送信します。 | `simulated?` |
@@ -0,0 +1,34 @@
1
+ <!-- Generated by `rake docs:glossary` from lib/taiwan_payments/glossary/concepts.yml. Edit that file, not this one. -->
2
+
3
+ # Taiwan payment and invoice terms / 台灣金流與發票名詞解釋
4
+
5
+ Each row gives a field or term, its Chinese name, what it means, and where to find it in `taiwan_payments`.
6
+ 每一列為欄位或名詞、中文名稱、英文說明,以及在 `taiwan_payments` 中對應的寫法。
7
+
8
+ Reference / 參考資料: https://www.einvoice.nat.gov.tw/
9
+
10
+ | Term | 中文 | Meaning | In this gem |
11
+ | --- | --- | --- | --- |
12
+ | **Uniform invoice** | 統一發票 | The government-regulated receipt every business must issue for a sale. Each one carries a number that enters a bimonthly state lottery, which is why consumers want theirs. | `TaiwanPayments::Invoice` |
13
+ | **E-invoice** | 電子發票 | A uniform invoice issued electronically through a certified provider such as ECPay, which reports it to the Ministry of Finance. | `ECPay::InvoiceClient` |
14
+ | **Tax ID** | 統一編號(統編) | The 8-digit number identifying a company or organisation. A buyer gives theirs when they need a business invoice for their accounts. | `buyer: {tax_id:}`, `TaxId.valid?` |
15
+ | **Carrier** | 載具 | Where a paperless invoice is stored for the buyer, so lottery prizes can be matched to them. | `carrier:` |
16
+ | **Mobile barcode** | 手機條碼 | The most common carrier. A code such as /ABC+123 that a person registers once with the Ministry of Finance and shows at every purchase. | `carrier: "/ABC+123"` |
17
+ | **Citizen digital certificate** | 自然人憑證 | A government-issued ID smart card whose number (2 letters and 14 digits) can serve as a carrier. | `carrier: "AB12345678901234"` |
18
+ | **Member carrier** | 會員載具 | A carrier run by the invoice provider itself, keyed by the buyer's email or phone. The default when the buyer gives no carrier. | `carrier: :member` |
19
+ | **Donation code** | 捐贈碼(愛心碼) | A 3 to 7 digit code for a registered charity. The buyer gives the invoice, and any lottery prize, to the charity. | `donation_code:` |
20
+ | **Random number** | 隨機碼 | A 4-digit code on each invoice that, with the invoice number, lets the buyer look it up. | `random_number` |
21
+ | **Invoice number track** | 字軌 | The range of invoice numbers the tax office assigns a business for each two-month period. A provider cannot issue once the range runs out. | `ApiError` codes 1500047 and 5070350 |
22
+ | **Void** | 作廢 | Cancelling an invoice entirely. Only possible within the two-month period it was issued in. | `void` |
23
+ | **Allowance** | 折讓 | A credit note against an invoice, used for partial refunds and for returns after the period has closed. | `allowance` |
24
+ | **Taxable, zero-rated, exempt** | 應稅、零稅率、免稅 | The three tax treatments. Taxable is the normal 5% business tax, zero-rated is mostly exports, exempt covers certain goods and services. | `tax_type:` |
25
+ | **Merchant** | 特店 | A business with a payment provider account. The vendors call your account a 特店 and its ID the 特店編號. | `merchant_id:` |
26
+ | **Convenience store code** | 超商代碼 | A code the customer types into a kiosk at 7-ELEVEN, FamilyMart, Hi-Life or OK Mart and then pays in cash at the counter. | `payment_method: :cvs` |
27
+ | **Convenience store barcode** | 超商條碼 | Three barcodes the customer shows at the counter to pay in cash. | `payment_method: :barcode` |
28
+ | **Virtual account** | 虛擬帳號 | A one-off bank account number generated for an order. The customer transfers to it from an ATM or online banking. | `payment_method: :atm` |
29
+ | **WebATM** | 網路 ATM | Paying from a bank card through a card reader attached to the customer's computer. | `payment_method: :web_atm` |
30
+ | **Capture** | 關帳(請款) | Settling an authorised card payment so the money is actually collected. Automatic for most merchants. | `capture` |
31
+ | **Refund** | 退刷(退款) | Returning money on a captured card payment. | `refund` |
32
+ | **Instalments** | 分期付款 | Card payment spread over 3 to 30 months, widely used in Taiwan and often interest-free for the customer. | `installments:` |
33
+ | **Reward points** | 紅利折抵 | Paying part of a purchase with credit card reward points. | `redeem:` |
34
+ | **Simulated payment** | 模擬付款 | A button in the vendor's back office, in production as well as in testing, that sends a fake "paid" callback without any money moving. | `simulated?` |
@@ -0,0 +1,113 @@
1
+ <!-- Generated by `rake docs:glossary` from lib/taiwan_payments/glossary/ecpay_invoice.yml. Edit that file, not this one. -->
2
+
3
+ # ECPay 電子発票のフィールド一覧
4
+
5
+ 各行は、フィールドまたは用語、その中国語名、意味、そして `taiwan_payments` での書き方を示します。
6
+
7
+ 参考資料: https://developers.ecpay.com.tw/7896/
8
+
9
+ | 用語 | 中国語 | 意味 | この gem での書き方 |
10
+ | --- | --- | --- | --- |
11
+ | `MerchantID` | 特店編號 | 電子発票サービス用の加盟店 ID です。決済用の加盟店 ID とは別のものです。 | `merchant_id:` on the client |
12
+ | `PlatformID` | 特約合作平台商代號 | プラットフォーム加盟店 ID です。配下の加盟店に代わって発票を発行するプラットフォーム専用です。 | `platform_id:` on the client |
13
+ | `RqHeader` | 傳入資料 | リクエストヘッダーのオブジェクトです。Timestamp を含みます。 | set automatically |
14
+ | `Timestamp` | 傳入時間 | リクエストの Unix 時間です。10 分を過ぎると ECPay に拒否されます。 | set automatically |
15
+ | `Data` | 加密資料 | リクエストまたはレスポンスのフィールドを JSON にして URL エンコードし、AES-128-CBC で暗号化したうえで Base64 エンコードしたものです。 | encrypted and decrypted automatically |
16
+ | `RpHeader` | 回傳資料 | レスポンスヘッダーのオブジェクトです。 | not used |
17
+ | `RqID` | 傳輸編號 | ECPay がリクエストに付ける ID です。API 呼び出しについて ECPay のサポートに問い合わせるときに伝えてください。 | not used |
18
+ | `Revision` | 串接規格文件版號 | API 仕様書のリビジョンです。 | not used |
19
+ | `TransCode` | 回傳代碼 | ECPay がリクエストを読み取れたかどうかを表します。1 は読み取れたことを示します。失敗した場合は、T110 などのコードを持つ ApiError が発生します。 | `ApiError#code` |
20
+ | `TransMsg` | 回傳訊息 | TransCode に対応するメッセージです。 | `ApiError#message` |
21
+ | `RtnCode` | 回應代碼 | 操作の結果です。1 は成功です。それ以外の場合は ApiError が発生します。 | `ApiError#code` |
22
+ | `RtnMsg` | 回應訊息 | 結果に対する ECPay のメッセージです。中国語で返されます。 | `ApiError#message_zh` |
23
+ | `RelateNumber` | 特店自訂編號 | 加盟店側で発票に付ける一意の参照番号で、最大 50 文字です。通常は注文番号を使います。 | `order_no:` |
24
+ | `CustomerID` | 客戶編號 | 加盟店側で管理している顧客 ID です。 | `buyer: {customer_id:}` |
25
+ | `CustomerIdentifier` | 統一編號 | 購入者の会社の統一編号(8 桁)です。事業者向けの発票では値が入り、消費者向けの発票では空です。 | `buyer: {tax_id:}` |
26
+ | `CustomerName` | 客戶名稱 | 購入者の名前です。印刷する発票では必須です。 | `buyer: {name:}` |
27
+ | `CustomerAddr` | 客戶地址 | 購入者の住所です。印刷する発票では必須です。 | `buyer: {address:}` |
28
+ | `CustomerPhone` | 客戶手機號碼 | 購入者の携帯電話番号で、数字のみです。この項目かメールアドレスのどちらかが必須です。 | `buyer: {phone:}` |
29
+ | `CustomerEmail` | 客戶電子信箱 | 購入者のメールアドレスです。ECPay が発票の通知をここに送信します。 | `buyer: {email:}` |
30
+ | `ClearanceMark` | 通關方式 | ゼロ税率の販売で指定します。1 は税関を経由していない、2 は税関を経由したことを表します。 | `customs_clearance:` |
31
+ | `Print` | 列印註記 | 購入者に紙の発票を渡す場合は 1、それ以外は 0 です。 | `print:` |
32
+ | `Donation` | 捐贈註記 | 発票を慈善団体に寄付する場合は 1 です。 | set when `donation_code:` is given |
33
+ | `LoveCode` | 捐贈碼 | 慈善団体の 3〜7 桁の寄付コード(愛心碼)です。 | `donation_code:` |
34
+ | `CarrierType` | 載具類別 | ペーパーレスの発票の保存先です。空はキャリアなし、1 は ECPay の会員キャリア、2 は自然人憑証(自然人憑證)、3 はモバイルバーコード(手機條碼)です。 | `carrier:` |
35
+ | `CarrierNum` | 載具編號 | キャリアの番号です。モバイルバーコードの場合は /ABC+123 のような値です。会員キャリアの場合は空です。 | `carrier:` |
36
+ | `TaxType` | 課稅類別 | 1 は課税、2 はゼロ税率、3 は免税、9 は混合です。 | `tax_type:` |
37
+ | `ZeroTaxRateReason` | 零稅率原因 | ゼロ税率の販売の法定理由で、71 から 79 のコードです。 | `zero_tax_rate_reason:` |
38
+ | `SpecialTaxType` | 特種稅額類別 | 特種税額の対象となる事業者向けの区分です。ほとんどの店舗では使いません。 | `extra: {"SpecialTaxType" => ...}` |
39
+ | `SalesAmount` | 發票總金額(含稅) | 発票の合計金額(税込)です。単位は新台湾ドル(TWD)です。 | `Invoice#total` |
40
+ | `InvoiceRemark` | 發票備註 | 発票に印字される備考です。 | `remark:` |
41
+ | `Items` | 商品 | 発票の品目(明細行)です。 | `items:` |
42
+ | `ItemSeq` | 商品序號 | 品目の行番号です。1 から始まります。 | set automatically |
43
+ | `ItemName` | 商品名稱 | 品目の説明(品名)です。 | `items: [{name:}]` |
44
+ | `ItemCount` | 商品數量 | 数量です。 | `items: [{quantity:}]` |
45
+ | `ItemWord` | 商品單位 | 単位で、最大 6 文字です。既定値は、慣例として何にでも使える「式」です。 | `items: [{unit:}]` |
46
+ | `ItemPrice` | 商品單價 | 単価(税込)です。 | `items: [{unit_price:}]` |
47
+ | `ItemTaxType` | 商品課稅別 | 品目ごとの課税区分です。品目によって異なるのは、混合の発票の場合だけです。 | `items: [{tax_type:}]` |
48
+ | `ItemAmount` | 商品合計 | 品目の合計金額(税込)です。 | `items: [{amount:}]` |
49
+ | `ItemRemark` | 商品備註 | 品目の備考です。 | `items: [{remark:}]` |
50
+ | `InvType` | 字軌類別 | 07 は一般税額、08 は特種税額です。 | `"07"`; override with `extra:` |
51
+ | `vat` | 商品單價是否含稅 | 価格が税込の場合は 1 です。gem は常に税込で送信します。 | `"1"`; override with `extra:` |
52
+ | `InvoiceNo` | 發票號碼 | 発票番号です。英字 2 文字と数字 8 桁です。 | `invoice_no` |
53
+ | `InvoiceDate` | 發票開立時間 | 発票の発行日時です。照会、無効化(作廢)、折譲(折讓、発行後の減額)には日付部分が必要です。 | `issued_at`, `issued_on:` |
54
+ | `RandomNumber` | 隨機碼 | 発票に印字される 4 桁のコードです。購入者は発票番号と組み合わせて発票を照会します。 | `random_number` |
55
+ | `Reason` | 作廢原因 | 発票または折譲を無効化する理由で、最大 20 文字です。 | `reason:` |
56
+ | `AllowanceNotify` | 通知類別 | 折譲を購入者に通知する方法です。S は SMS、E はメール、A は両方、N は通知なしです。 | chosen from `email:` and `phone:` |
57
+ | `NotifyMail` | 通知電子信箱 | 折譲の通知先のメールアドレスです。 | `email:` |
58
+ | `NotifyPhone` | 通知手機號碼 | 折譲の通知先の携帯電話番号です。 | `phone:` |
59
+ | `AllowanceAmount` | 折讓單總金額(含稅) | 折譲の合計金額(税込)です。 | computed from `items:` |
60
+ | `AllowanceNo` | 折讓編號 | 無効化する折譲の番号です。 | `allowance_no:` |
61
+ | `IA_Allow_No` | 折讓單號 | 今回発行された折譲の番号です。 | `allowance_no` |
62
+ | `IA_Invoice_No` | 發票號碼 | 折譲の対象となる発票の番号です。 | `invoice_no` |
63
+ | `IA_Date` | 折讓時間 | 折譲の発行日時です。 | `issued_at` |
64
+ | `IA_Remain_Allowance_Amt` | 折讓剩餘金額 | その発票に対して、まだ折譲できる残りの金額です。 | `remaining_amount` |
65
+ | `DelayFlag` | 延遲註記 | 1 は DelayDay で指定した日数の経過後に自動で発行し、2 はトリガーされるまで待機します。 | `schedule(days:)` |
66
+ | `DelayDay` | 延遲天數 | 発行までの待機日数で、最大 15 日です。 | `schedule(days:)` |
67
+ | `Tsr` | 交易單號 | 予約発票に加盟店側で付ける参照番号で、最大 30 文字です。発行をトリガーするときに使います。 | `reference:` |
68
+ | `PayType` | 交易類別 | 常に 2 です。 | set automatically |
69
+ | `PayAct` | 交易類別名稱 | 常に ECPAY です。 | set automatically |
70
+ | `NotifyURL` | 開立完成時通知特店系統的網址 | 予約発票が発行されると、ECPay がここへ POST します。 | `notify_url:` |
71
+ | `OrderNumber` | 交易單號 | 予約発行のレスポンスで返される、Tsr と同じ値です。 | `ScheduledInvoice#reference` |
72
+ | `BarCode` | 手機條碼 | 財政部に照会して確認するモバイルバーコードです。 | `mobile_barcode_valid?` |
73
+ | `IsExist` | 是否存在 | 寄付コードまたはモバイルバーコードが登録されている場合は Y です。 | `donation_code_valid?`, `mobile_barcode_valid?` |
74
+ | `OrganName` | 受捐贈單位名稱 | 寄付コードに対応する慈善団体の名称です。 | not surfaced; see `Testing.ecpay_invoice_request` to inspect |
75
+ | `PrintStyle` | 列印格式 | 発票の印刷用ページのレイアウトです。1 は標準レイアウトです。 | `extra: {"PrintStyle" => ...}` |
76
+ | `IsShowingDetail` | 是否列印明細 | 印刷用ページに品目を表示するかどうかです。 | `extra: {"IsShowingDetail" => ...}` |
77
+ | `InvoiceHtml` | 發票列印網址 | ECPay が用意する発票の印刷用ページへのリンクです。有効期限があります。 | `print_url` |
78
+ | `IIS_Mer_ID` | 特店編號 | 加盟店 ID です。 | `raw["IIS_Mer_ID"]` |
79
+ | `IIS_Number` | 發票號碼 | 発票番号です。 | `invoice_no` |
80
+ | `IIS_Relate_Number` | 特店自訂編號 | 加盟店側で発票に付けた参照番号です。 | `order_no` |
81
+ | `IIS_Customer_ID` | 客戶編號 | 加盟店側で管理している顧客 ID です。 | `buyer.customer_id` |
82
+ | `IIS_Identifier` | 買方統編 | 購入者の統一編号です。消費者向けの発票では 0 が 10 桁並んだ値になります。 | `buyer.tax_id` |
83
+ | `IIS_Customer_Name` | 客戶名稱 | 購入者の名前です。 | `buyer.name` |
84
+ | `IIS_Customer_Addr` | 客戶地址 | 購入者の住所です。 | `buyer.address` |
85
+ | `IIS_Customer_Phone` | 客戶電話 | 購入者の携帯電話番号です。 | `buyer.phone` |
86
+ | `IIS_Customer_Email` | 客戶信箱 | 購入者のメールアドレスです。 | `buyer.email` |
87
+ | `IIS_Clearance_Mark` | 通關方式 | ゼロ税率の販売における通関区分です。 | `raw["IIS_Clearance_Mark"]` |
88
+ | `IIS_Type` | 發票種類 | 07 は一般税額、08 は特種税額です。 | `raw["IIS_Type"]` |
89
+ | `IIS_Category` | 發票類別 | B2C または B2B です。 | `raw["IIS_Category"]` |
90
+ | `IIS_Tax_Type` | 課稅別 | 1 は課税、2 はゼロ税率、3 は免税、9 は混合です。 | `raw["IIS_Tax_Type"]` |
91
+ | `IIS_Tax_Rate` | 稅率 | 税率です。標準の 5% の場合は 0.05 です。 | `raw["IIS_Tax_Rate"]` |
92
+ | `IIS_Tax_Amount` | 稅金 | 合計金額のうちの税額です。税額を別記しない消費者向けの発票では、ECPay は 0 を返します。 | `tax_amount` |
93
+ | `IIS_Sales_Amount` | 發票金額 | 発票の合計金額です。 | `total` |
94
+ | `IIS_Check_Number` | 檢查碼 | ECPay 内部のチェック文字です。 | `raw["IIS_Check_Number"]` |
95
+ | `IIS_Carrier_Type` | 載具類別 | キャリアの種類です。値は CarrierType と同じです。 | `carrier_type` |
96
+ | `IIS_Carrier_Num` | 載具編號 | キャリアの番号です。会員キャリアの場合は、ECPay が独自に生成した ID が返されます。 | `carrier_number` |
97
+ | `IIS_Love_Code` | 捐贈碼 | 寄付コードです。発票が寄付されていない場合は 0 です。 | `donation_code` |
98
+ | `IIS_IP` | 發票開立 IP | 発行リクエストの送信元 IP アドレスです。 | `raw["IIS_IP"]` |
99
+ | `IIS_Create_Date` | 發票開立時間 | 発票の発行日時です。 | `issued_at` |
100
+ | `IIS_Issue_Status` | 發票開立狀態 | 1 は発行済み、0 は取消済みです。 | `raw["IIS_Issue_Status"]` |
101
+ | `IIS_Invalid_Status` | 發票作廢狀態 | 発票が無効化されている場合は 1 です。 | `voided?` |
102
+ | `IIS_Upload_Status` | 發票上傳狀態 | 発票が財政部へ報告されると 1 になります。 | `uploaded?` |
103
+ | `IIS_Upload_Date` | 發票上傳時間 | 財政部へ報告された日時です。 | `raw["IIS_Upload_Date"]` |
104
+ | `IIS_Turnkey_Status` | 發票上傳後接收狀態 | 財政部側の受信状況です。C は受理、E は失敗、G は処理中です。 | `raw["IIS_Turnkey_Status"]` |
105
+ | `IIS_Remain_Allowance_Amt` | 剩餘可折讓金額 | その発票に対して、まだ折譲できる残りの金額です。 | `remaining_allowance_amount` |
106
+ | `IIS_Print_Flag` | 列印旗標 | 印刷用として発行された発票の場合は 1 です。 | `printed?` |
107
+ | `IIS_Award_Flag` | 中獎旗標 | 統一発票の宝くじの結果です。抽せん前は空、0 は当せんなし、1 は当せん、X は対象外(事業者向けの発票)です。 | `raw["IIS_Award_Flag"]` |
108
+ | `IIS_Award_Type` | 中獎種類 | 当せんした賞の種類です。当せんなしの場合は 0 です。 | `raw["IIS_Award_Type"]` |
109
+ | `IIS_Random_Number` | 隨機碼 | 発票に印字される 4 桁のコードです。 | `random_number` |
110
+ | `QRCode_Left` | 電子發票左側 QRCode 內容 | 印刷した発票の左側の QR コードの内容です。 | `raw["QRCode_Left"]` |
111
+ | `QRCode_Right` | 電子發票右側 QRCode 內容 | 印刷した発票の右側の QR コードの内容です。 | `raw["QRCode_Right"]` |
112
+ | `PosBarCode` | 電子發票條碼內容 | 印刷した発票のバーコードの内容です。 | `raw["PosBarCode"]` |
113
+ | `ChannelPartner` | 通路商編號 | 販売チャネルパートナーのコードです。ほとんどの店舗では使いません。 | `raw["ChannelPartner"]` |
@@ -0,0 +1,114 @@
1
+ <!-- Generated by `rake docs:glossary` from lib/taiwan_payments/glossary/ecpay_invoice.yml. Edit that file, not this one. -->
2
+
3
+ # ECPay e-invoice fields / 綠界 B2C 電子發票欄位對照表
4
+
5
+ Each row gives a field or term, its Chinese name, what it means, and where to find it in `taiwan_payments`.
6
+ 每一列為欄位或名詞、中文名稱、英文說明,以及在 `taiwan_payments` 中對應的寫法。
7
+
8
+ Reference / 參考資料: https://developers.ecpay.com.tw/7896/
9
+
10
+ | Term | 中文 | Meaning | In this gem |
11
+ | --- | --- | --- | --- |
12
+ | `MerchantID` | 特店編號 | Merchant ID for the e-invoice product. Not the same as the payment merchant ID. | `merchant_id:` on the client |
13
+ | `PlatformID` | 特約合作平台商代號 | Platform merchant ID, only for platforms issuing on behalf of sub-merchants. | `platform_id:` on the client |
14
+ | `RqHeader` | 傳入資料 | Request header object. Holds the Timestamp. | set automatically |
15
+ | `Timestamp` | 傳入時間 | Unix time of the request. ECPay rejects it after ten minutes. | set automatically |
16
+ | `Data` | 加密資料 | The request or response fields as JSON, URL-encoded, AES-128-CBC encrypted and Base64 encoded. | encrypted and decrypted automatically |
17
+ | `RpHeader` | 回傳資料 | Response header object. | not used |
18
+ | `RqID` | 傳輸編號 | ECPay's ID for the request. Quote it when asking ECPay support about a call. | not used |
19
+ | `Revision` | 串接規格文件版號 | API specification revision. | not used |
20
+ | `TransCode` | 回傳代碼 | Whether ECPay could read the request at all. 1 is yes. Failures raise ApiError with a code such as T110. | `ApiError#code` |
21
+ | `TransMsg` | 回傳訊息 | Message for TransCode. | `ApiError#message` |
22
+ | `RtnCode` | 回應代碼 | Result of the operation. 1 is success. Anything else raises ApiError. | `ApiError#code` |
23
+ | `RtnMsg` | 回應訊息 | ECPay's message for the result, in Chinese. | `ApiError#message_zh` |
24
+ | `RelateNumber` | 特店自訂編號 | Your unique reference for the invoice, up to 50 characters. Usually the order number. | `order_no:` |
25
+ | `CustomerID` | 客戶編號 | Your own ID for the customer. | `buyer: {customer_id:}` |
26
+ | `CustomerIdentifier` | 統一編號 | Buyer's 8-digit company tax ID. Present on a business invoice, empty on a consumer one. | `buyer: {tax_id:}` |
27
+ | `CustomerName` | 客戶名稱 | Buyer's name. Required on a printed invoice. | `buyer: {name:}` |
28
+ | `CustomerAddr` | 客戶地址 | Buyer's address. Required on a printed invoice. | `buyer: {address:}` |
29
+ | `CustomerPhone` | 客戶手機號碼 | Buyer's mobile number, digits only. Either this or the email is required. | `buyer: {phone:}` |
30
+ | `CustomerEmail` | 客戶電子信箱 | Buyer's email. ECPay sends the invoice notice here. | `buyer: {email:}` |
31
+ | `ClearanceMark` | 通關方式 | For zero-rated sales. 1 did not go through customs, 2 went through customs. | `customs_clearance:` |
32
+ | `Print` | 列印註記 | 1 when the buyer gets a paper invoice, 0 otherwise. | `print:` |
33
+ | `Donation` | 捐贈註記 | 1 when the invoice is donated to a charity. | set when `donation_code:` is given |
34
+ | `LoveCode` | 捐贈碼 | The charity's 3 to 7 digit donation code. | `donation_code:` |
35
+ | `CarrierType` | 載具類別 | Where a paperless invoice is stored. Empty for none, 1 ECPay member carrier, 2 citizen digital certificate, 3 mobile barcode. | `carrier:` |
36
+ | `CarrierNum` | 載具編號 | The carrier's number, such as /ABC+123 for a mobile barcode. Empty for the member carrier. | `carrier:` |
37
+ | `TaxType` | 課稅類別 | 1 taxable, 2 zero-rated, 3 exempt, 9 mixed. | `tax_type:` |
38
+ | `ZeroTaxRateReason` | 零稅率原因 | Statutory reason for a zero-rated sale, a code from 71 to 79. | `zero_tax_rate_reason:` |
39
+ | `SpecialTaxType` | 特種稅額類別 | Category for special-tax businesses. Most shops never use it. | `extra: {"SpecialTaxType" => ...}` |
40
+ | `SalesAmount` | 發票總金額(含稅) | Invoice total in TWD, tax included. | `Invoice#total` |
41
+ | `InvoiceRemark` | 發票備註 | Note printed on the invoice. | `remark:` |
42
+ | `Items` | 商品 | The invoice lines. | `items:` |
43
+ | `ItemSeq` | 商品序號 | Line number, starting at 1. | set automatically |
44
+ | `ItemName` | 商品名稱 | Line description. | `items: [{name:}]` |
45
+ | `ItemCount` | 商品數量 | Quantity. | `items: [{quantity:}]` |
46
+ | `ItemWord` | 商品單位 | Unit, up to 6 characters. Defaults to 式, the customary catch-all. | `items: [{unit:}]` |
47
+ | `ItemPrice` | 商品單價 | Unit price, tax included. | `items: [{unit_price:}]` |
48
+ | `ItemTaxType` | 商品課稅別 | Tax type of one line. Only differs between lines on a mixed invoice. | `items: [{tax_type:}]` |
49
+ | `ItemAmount` | 商品合計 | Line total, tax included. | `items: [{amount:}]` |
50
+ | `ItemRemark` | 商品備註 | Note for the line. | `items: [{remark:}]` |
51
+ | `InvType` | 字軌類別 | 07 general tax, 08 special tax. | `"07"`; override with `extra:` |
52
+ | `vat` | 商品單價是否含稅 | 1 when prices include tax, which is how the gem always sends them. | `"1"`; override with `extra:` |
53
+ | `InvoiceNo` | 發票號碼 | The invoice number, two letters and eight digits. | `invoice_no` |
54
+ | `InvoiceDate` | 發票開立時間 | When the invoice was issued. Lookups, voids and allowances need the date part. | `issued_at`, `issued_on:` |
55
+ | `RandomNumber` | 隨機碼 | Four-digit code printed on the invoice. Buyers use it with the invoice number to look the invoice up. | `random_number` |
56
+ | `Reason` | 作廢原因 | Why the invoice or allowance is being voided, up to 20 characters. | `reason:` |
57
+ | `AllowanceNotify` | 通知類別 | How the buyer hears about an allowance. S for SMS, E for email, A for both, N for none. | chosen from `email:` and `phone:` |
58
+ | `NotifyMail` | 通知電子信箱 | Email address for the allowance notice. | `email:` |
59
+ | `NotifyPhone` | 通知手機號碼 | Mobile number for the allowance notice. | `phone:` |
60
+ | `AllowanceAmount` | 折讓單總金額(含稅) | Total being credited, tax included. | computed from `items:` |
61
+ | `AllowanceNo` | 折讓編號 | Number of the allowance to void. | `allowance_no:` |
62
+ | `IA_Allow_No` | 折讓單號 | Number of the allowance just issued. | `allowance_no` |
63
+ | `IA_Invoice_No` | 發票號碼 | Invoice the allowance belongs to. | `invoice_no` |
64
+ | `IA_Date` | 折讓時間 | When the allowance was issued. | `issued_at` |
65
+ | `IA_Remain_Allowance_Amt` | 折讓剩餘金額 | What can still be credited against the invoice. | `remaining_amount` |
66
+ | `DelayFlag` | 延遲註記 | 1 issues automatically after DelayDay days. 2 waits to be triggered. | `schedule(days:)` |
67
+ | `DelayDay` | 延遲天數 | Days to wait before issuing, up to 15. | `schedule(days:)` |
68
+ | `Tsr` | 交易單號 | Your handle for a scheduled invoice, up to 30 characters. Used to trigger it. | `reference:` |
69
+ | `PayType` | 交易類別 | Always 2. | set automatically |
70
+ | `PayAct` | 交易類別名稱 | Always ECPAY. | set automatically |
71
+ | `NotifyURL` | 開立完成時通知特店系統的網址 | ECPay POSTs here once a scheduled invoice has been issued. | `notify_url:` |
72
+ | `OrderNumber` | 交易單號 | Echo of Tsr in the scheduling response. | `ScheduledInvoice#reference` |
73
+ | `BarCode` | 手機條碼 | Mobile barcode to check with the Ministry of Finance. | `mobile_barcode_valid?` |
74
+ | `IsExist` | 是否存在 | Y when the donation code or mobile barcode is registered. | `donation_code_valid?`, `mobile_barcode_valid?` |
75
+ | `OrganName` | 受捐贈單位名稱 | Name of the charity a donation code belongs to. | not surfaced; see `Testing.ecpay_invoice_request` to inspect |
76
+ | `PrintStyle` | 列印格式 | Layout of the printable invoice page. 1 is the standard layout. | `extra: {"PrintStyle" => ...}` |
77
+ | `IsShowingDetail` | 是否列印明細 | Whether the printable page lists the items. | `extra: {"IsShowingDetail" => ...}` |
78
+ | `InvoiceHtml` | 發票列印網址 | Link to ECPay's printable page for the invoice. It expires. | `print_url` |
79
+ | `IIS_Mer_ID` | 特店編號 | Merchant ID. | `raw["IIS_Mer_ID"]` |
80
+ | `IIS_Number` | 發票號碼 | Invoice number. | `invoice_no` |
81
+ | `IIS_Relate_Number` | 特店自訂編號 | Your reference for the invoice. | `order_no` |
82
+ | `IIS_Customer_ID` | 客戶編號 | Your own ID for the customer. | `buyer.customer_id` |
83
+ | `IIS_Identifier` | 買方統編 | Buyer's tax ID. Ten zeros on a consumer invoice. | `buyer.tax_id` |
84
+ | `IIS_Customer_Name` | 客戶名稱 | Buyer's name. | `buyer.name` |
85
+ | `IIS_Customer_Addr` | 客戶地址 | Buyer's address. | `buyer.address` |
86
+ | `IIS_Customer_Phone` | 客戶電話 | Buyer's mobile number. | `buyer.phone` |
87
+ | `IIS_Customer_Email` | 客戶信箱 | Buyer's email. | `buyer.email` |
88
+ | `IIS_Clearance_Mark` | 通關方式 | Customs mark for zero-rated sales. | `raw["IIS_Clearance_Mark"]` |
89
+ | `IIS_Type` | 發票種類 | 07 general tax, 08 special tax. | `raw["IIS_Type"]` |
90
+ | `IIS_Category` | 發票類別 | B2C or B2B. | `raw["IIS_Category"]` |
91
+ | `IIS_Tax_Type` | 課稅別 | 1 taxable, 2 zero-rated, 3 exempt, 9 mixed. | `raw["IIS_Tax_Type"]` |
92
+ | `IIS_Tax_Rate` | 稅率 | Tax rate, 0.05 for the standard 5%. | `raw["IIS_Tax_Rate"]` |
93
+ | `IIS_Tax_Amount` | 稅金 | Tax portion of the total. ECPay reports 0 on consumer invoices, where tax is not shown separately. | `tax_amount` |
94
+ | `IIS_Sales_Amount` | 發票金額 | Invoice total. | `total` |
95
+ | `IIS_Check_Number` | 檢查碼 | ECPay's internal check character. | `raw["IIS_Check_Number"]` |
96
+ | `IIS_Carrier_Type` | 載具類別 | Carrier type, as in CarrierType. | `carrier_type` |
97
+ | `IIS_Carrier_Num` | 載具編號 | Carrier number. For the member carrier ECPay reports its own generated ID. | `carrier_number` |
98
+ | `IIS_Love_Code` | 捐贈碼 | Donation code, or 0 when the invoice was not donated. | `donation_code` |
99
+ | `IIS_IP` | 發票開立 IP | IP address the issuing request came from. | `raw["IIS_IP"]` |
100
+ | `IIS_Create_Date` | 發票開立時間 | When the invoice was issued. | `issued_at` |
101
+ | `IIS_Issue_Status` | 發票開立狀態 | 1 issued, 0 cancelled. | `raw["IIS_Issue_Status"]` |
102
+ | `IIS_Invalid_Status` | 發票作廢狀態 | 1 when the invoice has been voided. | `voided?` |
103
+ | `IIS_Upload_Status` | 發票上傳狀態 | 1 once the invoice has been reported to the Ministry of Finance. | `uploaded?` |
104
+ | `IIS_Upload_Date` | 發票上傳時間 | When it was reported to the Ministry of Finance. | `raw["IIS_Upload_Date"]` |
105
+ | `IIS_Turnkey_Status` | 發票上傳後接收狀態 | Ministry of Finance receipt status. C accepted, E failed, G in progress. | `raw["IIS_Turnkey_Status"]` |
106
+ | `IIS_Remain_Allowance_Amt` | 剩餘可折讓金額 | What can still be credited against the invoice. | `remaining_allowance_amount` |
107
+ | `IIS_Print_Flag` | 列印旗標 | 1 when the invoice was issued for printing. | `printed?` |
108
+ | `IIS_Award_Flag` | 中獎旗標 | Receipt lottery result. Empty before the draw, 0 no prize, 1 prize, X not eligible (business invoice). | `raw["IIS_Award_Flag"]` |
109
+ | `IIS_Award_Type` | 中獎種類 | Which lottery prize was won. 0 for none. | `raw["IIS_Award_Type"]` |
110
+ | `IIS_Random_Number` | 隨機碼 | Four-digit code printed on the invoice. | `random_number` |
111
+ | `QRCode_Left` | 電子發票左側 QRCode 內容 | Content of the left QR code on a printed invoice. | `raw["QRCode_Left"]` |
112
+ | `QRCode_Right` | 電子發票右側 QRCode 內容 | Content of the right QR code on a printed invoice. | `raw["QRCode_Right"]` |
113
+ | `PosBarCode` | 電子發票條碼內容 | Content of the barcode on a printed invoice. | `raw["PosBarCode"]` |
114
+ | `ChannelPartner` | 通路商編號 | Sales channel partner code. Most shops never use it. | `raw["ChannelPartner"]` |
@@ -0,0 +1,64 @@
1
+ <!-- Generated by `rake docs:glossary` from lib/taiwan_payments/glossary/ecpay_payment.yml. Edit that file, not this one. -->
2
+
3
+ # ECPay 決済のフィールド一覧
4
+
5
+ 各行は、フィールドまたは用語、その中国語名、意味、そして `taiwan_payments` での書き方を示します。
6
+
7
+ 参考資料: https://developers.ecpay.com.tw/?p=2862
8
+
9
+ | 用語 | 中国語 | 意味 | この gem での書き方 |
10
+ | --- | --- | --- | --- |
11
+ | `MerchantID` | 特店編號 | ECPay が発行する加盟店 ID です。決済用と電子発票用でそれぞれ別の ID があります。 | `merchant_id:` on the client |
12
+ | `PlatformID` | 特約合作平台商代號 | プラットフォーム加盟店 ID です。配下の加盟店を代理するマーケットプレイス専用です。 | `platform_id:` on the client |
13
+ | `CheckMacValue` | 檢查碼 | ほかのすべてのフィールドから計算する SHA256 署名(チェックサム)です。gem がリクエストに付加し、コールバックでは検証します。 | `client.check_mac_value` |
14
+ | `EncryptType` | CheckMacValue 加密類型 | 署名アルゴリズムです。常に 1(SHA256)です。 | set automatically |
15
+ | `MerchantTradeNo` | 特店訂單編號 | 加盟店側で一意に決める注文番号で、1〜20 文字の英数字です。使用済みの番号は ECPay に拒否されます。 | `order_no` |
16
+ | `MerchantTradeDate` | 特店交易時間 | 注文の作成日時です。台湾時間で指定します(yyyy/MM/dd HH:mm:ss)。 | `trade_date:` |
17
+ | `PaymentType` | 交易類型 / 付款方式 | 決済リクエストでは常に "aio" です。コールバックでは、Credit_CreditCard や ATM_TAISHIN のように、実際に使われた支払い方法の詳細が入ります。 | `payment_type`, `payment_method` |
18
+ | `TotalAmount` | 交易金額 | 金額です。新台湾ドル(TWD)の整数で指定します。 | `amount:` |
19
+ | `TradeDesc` | 交易描述 | 注文の説明です。ほとんどの決済ページでは購入者に表示されません。 | `description:` |
20
+ | `ItemName` | 商品名稱 | 決済ページに表示される商品名です。"#" で連結します。 | `items:` |
21
+ | `ReturnURL` | 付款完成通知回傳網址 | 決済結果を受け取るサーバー間の Webhook です。"1\|OK" と応答してください。 | `return_url:` |
22
+ | `ChoosePayment` | 選擇預設付款方式 | 決済ページで提示する支払い方法です。ALL にすると購入者が選択できます。 | `payment_method:` |
23
+ | `ChooseSubPayment` | 付款子項目 | 支払い方法をさらに絞り込みます。たとえば ATM 振込で使う銀行を 1 つに限定できます。 | `sub_method:` |
24
+ | `IgnorePayment` | 隱藏付款方式 | ChoosePayment が ALL のときに非表示にする支払い方法です。"#" で連結します。 | `ignore_methods:` |
25
+ | `OrderResultURL` | Client 端回傳付款結果網址 | 支払い後、購入者のブラウザーが決済結果とともにここへ POST されます。ReturnURL とは異なる URL を指定する必要があります。 | `order_result_url:` |
26
+ | `ClientBackURL` | Client 端返回特店的按鈕連結 | ECPay のページにある「ショップに戻る」ボタンのリンク先です。決済結果は渡されません。 | `client_back_url:` |
27
+ | `PaymentInfoURL` | Server 端回傳付款相關資訊 | 購入者が支払いに使う ATM 振込用のバーチャル口座またはコンビニ決済コード(超商代碼)を受け取る Webhook です。 | `payment_info_url:` |
28
+ | `ClientRedirectURL` | Client 端回傳付款相關資訊 | ECPay のページを表示する代わりに、購入者のブラウザーが ATM 振込用のバーチャル口座またはコンビニ決済コードとともにここへ POST されます。 | `client_redirect_url:` |
29
+ | `ItemURL` | 商品銷售網址 | 商品ページへのリンクです。 | `item_url:` |
30
+ | `Remark` | 備註欄位 | 注文とともに保存される自由記述のメモです。 | `remark:` |
31
+ | `StoreID` | 特店旗下店舖代號 | 加盟店独自の支店コードまたは店舗コードです。コールバックでそのまま返されます。 | `store_id:` |
32
+ | `Language` | 語系設定 | 決済ページの言語です。ENG、KOR、JPN、CHI のいずれかで、省略時は繁体字中国語になります。 | `language:` |
33
+ | `NeedExtraPaidInfo` | 是否需要額外的付款資訊 | Y にすると、カード番号の一部や銀行コードなどの詳細がコールバックに追加されます。 | `extra_paid_info:` |
34
+ | `CustomField1` | 自訂名稱欄位 1 | 加盟店が自由に使える最大 50 文字のデータです。コールバックでそのまま返されます。 | `custom_fields:` |
35
+ | `CustomField2` | 自訂名稱欄位 2 | CustomField1 を参照してください。 | `custom_fields:` |
36
+ | `CustomField3` | 自訂名稱欄位 3 | CustomField1 を参照してください。 | `custom_fields:` |
37
+ | `CustomField4` | 自訂名稱欄位 4 | CustomField1 を参照してください。 | `custom_fields:` |
38
+ | `ExpireDate` | 允許繳費有效天數 / 繳費期限 | 決済リクエストでは、ATM 振込の支払い猶予日数(1〜60)です。コールバックでは支払い期限です。 | `atm_expire_days:`, `payment_instructions.expires_at` |
39
+ | `StoreExpireDate` | 超商繳費截止時間 | コンビニでの支払い猶予時間です。コンビニ決済コードの場合は分単位、コンビニバーコード(超商條碼)の場合は日単位です。 | `store_expire:` |
40
+ | `Desc_1` | 交易描述 1 | コンビニの店頭端末で出力される伝票に印字される行です。 | `store_descriptions:` |
41
+ | `Desc_2` | 交易描述 2 | Desc_1 を参照してください。 | `store_descriptions:` |
42
+ | `Desc_3` | 交易描述 3 | Desc_1 を参照してください。 | `store_descriptions:` |
43
+ | `Desc_4` | 交易描述 4 | Desc_1 を参照してください。 | `store_descriptions:` |
44
+ | `CreditInstallment` | 刷卡分期期數 | 提示する分割払いの回数です。たとえば 3,6,12 のように指定します。 | `installments:` |
45
+ | `Redeem` | 信用卡是否使用紅利折抵 | Y にすると、購入者は代金の一部をカードのポイントで支払えます。 | `redeem:` |
46
+ | `UnionPay` | 銀聯卡交易選項 | 0 は購入者が選択、1 は UnionPay(銀聯)に固定、2 は UnionPay を非表示にします。 | `union_pay:` |
47
+ | `RtnCode` | 交易狀態 | 結果コードです。1 は支払い済み、2 は ATM 振込用のバーチャル口座の発行済み、10100073 はコンビニ決済コードまたはバーコードの発行済みを表します。それ以外は失敗です。 | `status_code`, `status`, `paid?` |
48
+ | `RtnMsg` | 交易訊息 | 結果に対する ECPay のメッセージです。通常は中国語です。 | `message` |
49
+ | `TradeNo` | 綠界的交易編號 | ECPay 側の取引番号です。返金に必要なので保存しておいてください。 | `trade_no` |
50
+ | `TradeAmt` | 交易金額 | 新台湾ドル(TWD)建ての取引金額です。商品やサービスを提供する前に、自社の注文の金額と照合してください。 | `amount` |
51
+ | `TradeDate` | 訂單成立時間 | ECPay が取引を作成した日時です。 | `ordered_at` |
52
+ | `PaymentDate` | 付款時間 | 購入者が支払った日時です。支払われるまでは空です。 | `paid_at` |
53
+ | `PaymentTypeChargeFee` | 交易手續費金額 | この取引に対する ECPay の手数料です。 | `fee` |
54
+ | `HandlingCharge` | 手續費合計 | 照会で返される手数料の合計です。 | `raw["HandlingCharge"]` |
55
+ | `SimulatePaid` | 是否為模擬付款 | 管理画面の支払いシミュレーション(模擬付款)ボタンから送信されたコールバックの場合は 1 です。実際の入金はないため、商品を発送しないでください。 | `simulated?` |
56
+ | `TradeStatus` | 交易狀態 | 照会では、0 は未払い、1 は支払い済みです。それ以外は失敗コードです。 | `status_code`, `status` |
57
+ | `TimeStamp` | 驗證時間 | 照会の Unix 時間です。3 分を過ぎると ECPay に拒否されます。 | set automatically |
58
+ | `BankCode` | 繳費銀行代碼 | 購入者の振込先となるバーチャル口座の銀行コードです。 | `payment_instructions.bank_code` |
59
+ | `vAccount` | 繳費虛擬帳號 | ATM 振込用のバーチャル口座番号です。 | `payment_instructions.virtual_account` |
60
+ | `PaymentNo` | 繳費代碼 | 購入者がコンビニの店頭端末に入力するコードです。 | `payment_instructions.payment_no` |
61
+ | `Barcode1` | 條碼第一段號碼 | 購入者がコンビニのレジで提示する 3 つのバーコードのうち 1 つ目です。 | `payment_instructions.barcodes` |
62
+ | `Barcode2` | 條碼第二段號碼 | Barcode1 を参照してください。 | `payment_instructions.barcodes` |
63
+ | `Barcode3` | 條碼第三段號碼 | Barcode1 を参照してください。 | `payment_instructions.barcodes` |
64
+ | `Action` | 執行動作 | カードに対する操作です。C は売上確定(關帳)、R は返金(退刷)、E は売上確定の取消(取消關帳)、N はオーソリの取消(放棄)です。 | `capture`, `refund`, `cancel_capture`, `void_authorization` |