From d94eb4195e6fab3efd875549c2734376383a3b97 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 10 Apr 2014 20:27:27 +0000 Subject: [PATCH 01/10] debit a card in a foreign currency --- features/forex.feature | 38 +++++++++++++++++++++++++++++++++++++ fixtures/_models/debit.json | 5 +++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 features/forex.feature diff --git a/features/forex.feature b/features/forex.feature new file mode 100644 index 0000000..883a68c --- /dev/null +++ b/features/forex.feature @@ -0,0 +1,38 @@ +Feature: Forex + Foreign currency exchange, hereafter 'forex', is a feature that allows + marketplaces to charge thier buyers in non-USD currencies. + + This provides a better experience for customers who have accounts denominated + in other currencies, and reduces chargeback rates for those customers as well. + + Scenario: Debit a card in € + Given I have tokenized a card + When I make a POST request to the link "cards.debits" with the body: + """ + { + "debits": [{ + "amount": 2000, + "currency": "EUR" + }] + } + """ + Then I should get a 201 Created status code + And the response is valid according to the "debits" schema + + Scenario: Debiting a card directly in € + When I POST to /debits with the body: + """ + { + "debits": [{ + "amount": 1234, + "source": { + "number": "4111111111111111", + "expiration_year": "2018", + "expiration_month": 12 + }, + "currency": "EUR" + }] + } + """ + Then I should get a 201 Created status code + And the response is valid according to the "debits" schema diff --git a/fixtures/_models/debit.json b/fixtures/_models/debit.json index 689d81c..7084bd0 100644 --- a/fixtures/_models/debit.json +++ b/fixtures/_models/debit.json @@ -27,7 +27,8 @@ "currency": { "type": "string", "enum": [ - "USD" + "USD", + "EUR" ] }, "appears_on_statement_as": { @@ -122,4 +123,4 @@ "meta", "links" ] -} \ No newline at end of file +} From 8b08372eb89ec52b8865f4ea20c83b992c467a58 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 10 Apr 2014 13:36:06 -0700 Subject: [PATCH 02/10] =?UTF-8?q?fix=20encoding=20error=20on=20=E2=82=AC?= =?UTF-8?q?=20:sweat=5Fsmile:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/forex.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/forex.feature b/features/forex.feature index 883a68c..e967003 100644 --- a/features/forex.feature +++ b/features/forex.feature @@ -5,7 +5,7 @@ Feature: Forex This provides a better experience for customers who have accounts denominated in other currencies, and reduces chargeback rates for those customers as well. - Scenario: Debit a card in € + Scenario: Debit a card in € Given I have tokenized a card When I make a POST request to the link "cards.debits" with the body: """ @@ -19,7 +19,7 @@ Feature: Forex Then I should get a 201 Created status code And the response is valid according to the "debits" schema - Scenario: Debiting a card directly in € + Scenario: Debiting a card directly in € When I POST to /debits with the body: """ { From f8eb3b3ab5a182aee5b7a3866c5c4c139a9a7d67 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 10 Apr 2014 23:05:33 +0000 Subject: [PATCH 03/10] Adding details for exposing the amounts --- features/forex.feature | 4 ++++ fixtures/_models/debit.json | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/features/forex.feature b/features/forex.feature index e967003..448bb55 100644 --- a/features/forex.feature +++ b/features/forex.feature @@ -5,6 +5,9 @@ Feature: Forex This provides a better experience for customers who have accounts denominated in other currencies, and reduces chargeback rates for those customers as well. + The fee is reflected in the response back from the debit. See the schema for + debits for more details. + Scenario: Debit a card in € Given I have tokenized a card When I make a POST request to the link "cards.debits" with the body: @@ -36,3 +39,4 @@ Feature: Forex """ Then I should get a 201 Created status code And the response is valid according to the "debits" schema + diff --git a/fixtures/_models/debit.json b/fixtures/_models/debit.json index 7084bd0..3101c17 100644 --- a/fixtures/_models/debit.json +++ b/fixtures/_models/debit.json @@ -62,6 +62,39 @@ "type": "string", "pattern": "W[0-9]{3}-[0-9]{3}-[0-9]{4}" }, + "fee": { + "description": "The fee Balanced charged for this transaction. It is denominated in USD integer cents.", + "type": "integer", + "minimum": 1 + }, + "fee_details": { + "description": "The breakdown of the fee paid for this transaction.", + "type": "array", + "items": { + "description": "Details of the fees paid. There may be zero to two: our usual fee, and a forex fee if the transaction was not in USD.", + "type": "object", + "properties": { + "amount": { + "type": "integer", + "minimum": "1", + } + "currency": { + "type": "string", + "enum": [ + "USD" + ] + } + "type": { + "type": "string" + "enum": [ + "processing", + "forex" + ] + } + } + }, + "minItems": 0 + }, "meta": { "$ref": "meta.json" }, @@ -121,6 +154,6 @@ "failure_reason_code", "transaction_number", "meta", - "links" + "links", ] } From 4307c8fe637666633ee16224373baab1c7036502 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 10 Apr 2014 23:24:58 +0000 Subject: [PATCH 04/10] Revert "Adding details for exposing the amounts" This reverts commit f8eb3b3ab5a182aee5b7a3866c5c4c139a9a7d67. @mjallday schooled me about how we used to do this like this, but don't any more. Seems good. :+1: --- features/forex.feature | 4 ---- fixtures/_models/debit.json | 35 +---------------------------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/features/forex.feature b/features/forex.feature index 448bb55..e967003 100644 --- a/features/forex.feature +++ b/features/forex.feature @@ -5,9 +5,6 @@ Feature: Forex This provides a better experience for customers who have accounts denominated in other currencies, and reduces chargeback rates for those customers as well. - The fee is reflected in the response back from the debit. See the schema for - debits for more details. - Scenario: Debit a card in € Given I have tokenized a card When I make a POST request to the link "cards.debits" with the body: @@ -39,4 +36,3 @@ Feature: Forex """ Then I should get a 201 Created status code And the response is valid according to the "debits" schema - diff --git a/fixtures/_models/debit.json b/fixtures/_models/debit.json index 3101c17..7084bd0 100644 --- a/fixtures/_models/debit.json +++ b/fixtures/_models/debit.json @@ -62,39 +62,6 @@ "type": "string", "pattern": "W[0-9]{3}-[0-9]{3}-[0-9]{4}" }, - "fee": { - "description": "The fee Balanced charged for this transaction. It is denominated in USD integer cents.", - "type": "integer", - "minimum": 1 - }, - "fee_details": { - "description": "The breakdown of the fee paid for this transaction.", - "type": "array", - "items": { - "description": "Details of the fees paid. There may be zero to two: our usual fee, and a forex fee if the transaction was not in USD.", - "type": "object", - "properties": { - "amount": { - "type": "integer", - "minimum": "1", - } - "currency": { - "type": "string", - "enum": [ - "USD" - ] - } - "type": { - "type": "string" - "enum": [ - "processing", - "forex" - ] - } - } - }, - "minItems": 0 - }, "meta": { "$ref": "meta.json" }, @@ -154,6 +121,6 @@ "failure_reason_code", "transaction_number", "meta", - "links", + "links" ] } From f17f0313323ca3981565b59f6d569f70a61f18d5 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 10 Apr 2014 23:49:20 +0000 Subject: [PATCH 05/10] Add full currency list to the debit schema --- fixtures/_models/debit.json | 158 +++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-) diff --git a/fixtures/_models/debit.json b/fixtures/_models/debit.json index 7084bd0..cce3e4f 100644 --- a/fixtures/_models/debit.json +++ b/fixtures/_models/debit.json @@ -28,7 +28,163 @@ "type": "string", "enum": [ "USD", - "EUR" + "AED", + "AFN", + "ALL", + "AMD", + "ANG", + "AOA", + "ARS", + "AUD", + "AWG", + "AZN", + "BAM", + "BBD", + "BDT", + "BGN", + "BHD", + "BIF", + "BMD", + "BND", + "BOB", + "BRL", + "BSD", + "BTN", + "BWP", + "BYR", + "BZD", + "CAD", + "CDF", + "CHF", + "CLP", + "CNY", + "COP", + "CRC", + "CUP", + "CVE", + "CZK", + "DJF", + "DKK", + "DOP", + "DZD", + "EEK", + "EGP", + "ERN", + "ETB", + "EUR", + "FJD", + "FKP", + "GBP", + "GEL", + "GHS", + "GIP", + "GMD", + "GNF", + "GTQ", + "GYD", + "HKD", + "HNL", + "HRK", + "HTG", + "HUF", + "IDR", + "ILS", + "INR", + "IQD", + "IRR", + "ISK", + "JMD", + "JOD", + "JPY", + "KES", + "KGS", + "KHR", + "KMF", + "KPW", + "KRW", + "KWD", + "KYD", + "KZT", + "LAK", + "LBP", + "LKR", + "LRD", + "LSL", + "LTL", + "LVL", + "LYD", + "MAD", + "MDL", + "MGA", + "MKD", + "MMK", + "MNT", + "MOP", + "MRO", + "MUR", + "MVR", + "MWK", + "MXN", + "MYR", + "MZN", + "NAD", + "NGN", + "NIO", + "NOK", + "NPR", + "NZD", + "OMR", + "PAB", + "PEN", + "PGK", + "PHP", + "PKR", + "PLN", + "PYG", + "QAR", + "RON", + "RSD", + "RUB", + "RWF", + "SAR", + "SBD", + "SCR", + "SDG", + "SEK", + "SGD", + "SHP", + "SLL", + "SOS", + "SRD", + "SSP", + "STD", + "SYP", + "SZL", + "THB", + "TJS", + "TMT", + "TND", + "TOP", + "TRY", + "TTD", + "TWD", + "TZS", + "UAH", + "UGX", + "UYU", + "UZS", + "VEF", + "VND", + "VUV", + "WST", + "XAF", + "XCD", + "XOF", + "XPF", + "YER", + "ZAR", + "ZMK", + "ZMW" ] }, "appears_on_statement_as": { From 84ab4905a7de8213b0460248ac2bd7d9e2c90b9c Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 10 Apr 2014 23:54:02 +0000 Subject: [PATCH 06/10] Ensure that we get the same currency back. Thanks @matthewfl --- features/forex.feature | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/features/forex.feature b/features/forex.feature index e967003..15057e8 100644 --- a/features/forex.feature +++ b/features/forex.feature @@ -18,6 +18,12 @@ Feature: Forex """ Then I should get a 201 Created status code And the response is valid according to the "debits" schema + And the fields on this debit match: + """ + { + "currency": "EUR" + } + """ Scenario: Debiting a card directly in € When I POST to /debits with the body: @@ -36,3 +42,9 @@ Feature: Forex """ Then I should get a 201 Created status code And the response is valid according to the "debits" schema + And the fields on this debit match: + """ + { + "currency": "EUR" + } + """ From a2f687ee8d632dd65cb09fe393c3fe0e9aa4141c Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 11 Apr 2014 22:42:39 +0000 Subject: [PATCH 07/10] Cut down on currencies, add order currency field. All the currencies may come back at some point. --- fixtures/_models/debit.json | 170 +++--------------------------------- 1 file changed, 14 insertions(+), 156 deletions(-) diff --git a/fixtures/_models/debit.json b/fixtures/_models/debit.json index cce3e4f..01249a1 100644 --- a/fixtures/_models/debit.json +++ b/fixtures/_models/debit.json @@ -28,163 +28,21 @@ "type": "string", "enum": [ "USD", - "AED", - "AFN", - "ALL", - "AMD", - "ANG", - "AOA", - "ARS", - "AUD", - "AWG", - "AZN", - "BAM", - "BBD", - "BDT", - "BGN", - "BHD", - "BIF", - "BMD", - "BND", - "BOB", - "BRL", - "BSD", - "BTN", - "BWP", - "BYR", - "BZD", - "CAD", - "CDF", - "CHF", - "CLP", - "CNY", - "COP", - "CRC", - "CUP", - "CVE", - "CZK", - "DJF", - "DKK", - "DOP", - "DZD", - "EEK", - "EGP", - "ERN", - "ETB", "EUR", - "FJD", - "FKP", - "GBP", - "GEL", - "GHS", - "GIP", - "GMD", - "GNF", - "GTQ", - "GYD", - "HKD", - "HNL", - "HRK", - "HTG", - "HUF", - "IDR", - "ILS", - "INR", - "IQD", - "IRR", - "ISK", - "JMD", - "JOD", - "JPY", - "KES", - "KGS", - "KHR", - "KMF", - "KPW", - "KRW", - "KWD", - "KYD", - "KZT", - "LAK", - "LBP", - "LKR", - "LRD", - "LSL", - "LTL", - "LVL", - "LYD", - "MAD", - "MDL", - "MGA", - "MKD", - "MMK", - "MNT", - "MOP", - "MRO", - "MUR", - "MVR", - "MWK", - "MXN", - "MYR", - "MZN", - "NAD", - "NGN", - "NIO", - "NOK", - "NPR", - "NZD", - "OMR", - "PAB", - "PEN", - "PGK", - "PHP", - "PKR", - "PLN", - "PYG", - "QAR", - "RON", - "RSD", - "RUB", - "RWF", - "SAR", - "SBD", - "SCR", - "SDG", - "SEK", - "SGD", - "SHP", - "SLL", - "SOS", - "SRD", - "SSP", - "STD", - "SYP", - "SZL", - "THB", - "TJS", - "TMT", - "TND", - "TOP", - "TRY", - "TTD", - "TWD", - "TZS", - "UAH", - "UGX", - "UYU", - "UZS", - "VEF", - "VND", - "VUV", - "WST", - "XAF", - "XCD", - "XOF", - "XPF", - "YER", - "ZAR", - "ZMK", - "ZMW" + "GBP" + ] + }, + "amount_in_order_currency": { + "description": "The amount of the debit in cents, denominated in the order_currency.", + "type": "integer", + "minimum": 1 + }, + "order_currency": { + "type": "string", + "enum": [ + "USD", + "EUR", + "GBP" ] }, "appears_on_statement_as": { From 3b64750178052c9dbebac9383857d5f34e39572b Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 21 Apr 2014 23:14:14 +0000 Subject: [PATCH 08/10] Adding currency object --- fixtures/_models/currency.json | 164 +++++++++++++++++++++++++++++++++ fixtures/_models/debit.json | 24 ++--- 2 files changed, 171 insertions(+), 17 deletions(-) create mode 100644 fixtures/_models/currency.json diff --git a/fixtures/_models/currency.json b/fixtures/_models/currency.json new file mode 100644 index 0000000..aa5c04d --- /dev/null +++ b/fixtures/_models/currency.json @@ -0,0 +1,164 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "string", + "enum": [ + "AED", + "AFN", + "ALL", + "AMD", + "ANG", + "AOA", + "ARS", + "AUD", + "AWG", + "AZN", + "BAM", + "BBD", + "BDT", + "BGN", + "BHD", + "BIF", + "BMD", + "BND", + "BOB", + "BRL", + "BSD", + "BWP", + "BYR", + "BZD", + "CAD", + "CDF", + "CHF", + "CLP", + "CNY", + "COP", + "CRC", + "CUC", + "CVE", + "CZK", + "DJF", + "DKK", + "DOP", + "DZD", + "EEK", + "EGP", + "ERN", + "ETB", + "EUR", + "FJD", + "FKP", + "GBP", + "GEL", + "GHS", + "GIP", + "GMD", + "GNF", + "GQE", + "GTQ", + "GYD", + "HKD", + "HNL", + "HRK", + "HTG", + "HUF", + "IDR", + "ILS", + "INR", + "IQD", + "IRR", + "ISK", + "JMD", + "JOD", + "JPY", + "KES", + "KGS", + "KHR", + "KMF", + "KPW", + "KRW", + "KWD", + "KYD", + "KZT", + "LAK", + "LBP", + "LKR", + "LRD", + "LSL", + "LTL", + "LVL", + "LYD", + "MAD", + "MDL", + "MGA", + "MKD", + "MMK", + "MNT", + "MOP", + "MRO", + "MUR", + "MVR", + "MWK", + "MXN", + "MYR", + "MZM", + "NAD", + "NGN", + "NIO", + "NOK", + "NPR", + "NZD", + "OMR", + "PAB", + "PEN", + "PGK", + "PHP", + "PKR", + "PLN", + "PYG", + "QAR", + "RON", + "RSD", + "RUB", + "RWF", + "SAR", + "SBD", + "SCR", + "SDG", + "SEK", + "SGD", + "SHP", + "SLL", + "SOS", + "SRD", + "STD", + "SYP", + "SZL", + "THB", + "TJS", + "TMM", + "TMT", + "TND", + "TOP", + "TRY", + "TTD", + "TWD", + "TZS", + "UAH", + "UGX", + "USD", + "UYU", + "UZS", + "VEB", + "VND", + "VUV", + "WST", + "XAF", + "XCD", + "XOF", + "XPF", + "YER", + "ZAR", + "ZMK", + "ZWR" + ] +} diff --git a/fixtures/_models/debit.json b/fixtures/_models/debit.json index 01249a1..3d0af44 100644 --- a/fixtures/_models/debit.json +++ b/fixtures/_models/debit.json @@ -19,31 +19,21 @@ "type": "string", "format": "date-time" }, + "currency": { + "$ref": "_models/debit.json" + }, "amount": { "description": "The amount of the debit in cents.", "type": "integer", "minimum": 1 }, - "currency": { - "type": "string", - "enum": [ - "USD", - "EUR", - "GBP" - ] - }, - "amount_in_order_currency": { - "description": "The amount of the debit in cents, denominated in the order_currency.", + "amount_in_captured_currency": { + "description": "The amount of the debit in cents, denominated in the captured_currency.", "type": "integer", "minimum": 1 }, - "order_currency": { - "type": "string", - "enum": [ - "USD", - "EUR", - "GBP" - ] + "captured_currency": { + "$ref": "_models/debit.json" }, "appears_on_statement_as": { "$ref": "appears_on_statement_as.json" From b5a3013cc9594a56c8e4e10f5beb9de26dfc1b87 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 21 Apr 2014 23:16:01 +0000 Subject: [PATCH 09/10] Refer to the correct model. :cry: --- fixtures/_models/debit.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fixtures/_models/debit.json b/fixtures/_models/debit.json index 3d0af44..f5e2163 100644 --- a/fixtures/_models/debit.json +++ b/fixtures/_models/debit.json @@ -20,7 +20,7 @@ "format": "date-time" }, "currency": { - "$ref": "_models/debit.json" + "$ref": "_models/currency.json" }, "amount": { "description": "The amount of the debit in cents.", @@ -33,7 +33,7 @@ "minimum": 1 }, "captured_currency": { - "$ref": "_models/debit.json" + "$ref": "_models/currency.json" }, "appears_on_statement_as": { "$ref": "appears_on_statement_as.json" From bfe1227459e26a009a1d983b988ec449cea04004 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 12 May 2014 22:50:18 +0000 Subject: [PATCH 10/10] captured -> escrow in currency names --- fixtures/_models/debit.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fixtures/_models/debit.json b/fixtures/_models/debit.json index f5e2163..357fe18 100644 --- a/fixtures/_models/debit.json +++ b/fixtures/_models/debit.json @@ -27,12 +27,12 @@ "type": "integer", "minimum": 1 }, - "amount_in_captured_currency": { - "description": "The amount of the debit in cents, denominated in the captured_currency.", + "amount_in_escrow_currency": { + "description": "The amount of the debit in cents, denominated in the escrow_currency.", "type": "integer", "minimum": 1 }, - "captured_currency": { + "escrow_currency": { "$ref": "_models/currency.json" }, "appears_on_statement_as": {