Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forex #564

Closed
wants to merge 10 commits into from
38 changes: 38 additions & 0 deletions features/forex.feature
Original file line number Diff line number Diff line change
@@ -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 €
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

� is either a new crypto currency or an encoding error...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dammit. Yeah, should be €. fixing...

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
5 changes: 3 additions & 2 deletions fixtures/_models/debit.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"currency": {
"type": "string",
"enum": [
"USD"
"USD",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make a specific currencies file for this similar to status

https://github.com/balanced/balanced-api/blob/master/fixtures/_models/status.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will eventually, this is changing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I just realized how long and unyielding that had become

"EUR"
]
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is captured_currency different from currency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currency is your base currency (currently this will be USD for all accounts/escrows). captured_currency is the amount you captured in. e.g. you capture in 1EUR with an exchange rate of 1.2 you would see

  • currency: USD
  • amount: 120
  • captured_currency: EUR
  • amount_in_captured_currency: 100

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, currency is denominated in cents. Will captured_currency be also denominated the same way?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if both currency and captured_currency are both USD, will amount_in_captured_currency be the same as amount or will it be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, integers of the smallest value of the currency.

They'll be the same. null is evil!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyungmin and I have come to the conclusion that since this information basically doesn't ever change, it will go in the documentation, and we'll provide some sample JavaScript to make it even easier to format correctly. Adding that information to the response just leads to sending the same information over the wire over and over again for little benefit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matin noted. I struggled to come up with the right word here, and I guess I was wrong. Do you have any suggestions for what the right term is?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this?

{
    "amount": 10000,
    "currency": "EUR",
    "amount_in": {
        "USD": 13755         
    }
}

The response can include whatever currencies are relevant for that marketplace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other alternative I would suggest is amount_in_escrow_currency and escrow_currency. This is consistent with the language we use elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Let's go with amount_in_escrow_currency and escrow_currency. I don't recall why I had an issue with that before, seems incredibly straightforward.

"appears_on_statement_as": {
Expand Down Expand Up @@ -122,4 +123,4 @@
"meta",
"links"
]
}
}