Currencies

Ravelin expects monetary amounts to be in the currency’s ISO-4127 minor currency units. Instead of sending 10.50 USD, you send 1050 cents:

// $10.50
{"currency": "USD", "amount": 1050}

Other currencies, such as the Japanese Yen, or the Vietnamese Dong, are not considered in their minor units. 300¥ is:

// 300¥
{"currency": "JPY", "amount": 300}

The Malagasy ariary and the Mauritanian ouguiya are both subdivided into fifths. So if you have 1.2 UM, you would send Ravelin:

// 1.2 UM
{"currency": "MRU", "amount": 6}

Ravelin uses the transformations defined by the exponents in ISO 4127, interpreted as:

func CurrencyToBasicMultiplier(currency string) int {
	switch currency {
	case "BIF", "CLP", "CVE", "DJF", "GNF", "ISK", "JPY", "KMF",
		"KRW", "PYG", "RWF", "UGX", "UYI", "VND", "VUV", "XAF",
		"XOF", "XPF":
		return 1
	case "MGA", "MRU":
		return 5
	case "BHD", "IQD", "JOD", "KWD", "LYD", "OMR", "TND":
		return 1000
	}
	return 100
}

Note that ISO 4127 differs from both Wikipedia’s “Number to basic” in the List of Circulating Currencies, and the POSIX standard in different places. It may also be different from your PSP’s handling of these currencies. For example, Braintree handles LAK without subdivision while ISO 4127 and Stripe do.