Swiftpack.co - paylike/swift-money as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by paylike.
paylike/swift-money 0.1.0
Money implementation in swift
⭐️ 0
🕓 1 week ago
.package(url: "https://github.com/paylike/swift-money.git", from: "0.1.0")


Small utility library to help working with payment amounts inside the Paylike ecosystem


Currently this package only supports a fraction of our JavaScript library. We may extend functionality later.



// dependencies: 
.package(url: "git@github.com:paylike/swift-money.git", .upToNextMajor(from: "0.1.0")

// target:
.product(name: "PaylikeMoney", package: "swift-money")

Cocoapods: https://cocoapods.org/pods/PaylikeMoney

pod 'PaylikeMoney'


Check PaylikeCurrencies for our supported currencies

let eur = PaylikeCurrencies.byCode(CurrencyCode.EUR)

// Create from double
let amount = PaylikeMoney.fromDouble(currency: eur, n: 0.01) // EUR 0.01

// Create by hand
let amount2 = PaymentAmount(currency: eur, value: 1, exponent: 0) // EUR 1

amount.toString() // "EUR 0.01"

amount.toString(opts: PaymentAmountStringOptions(currency: false)) // "0.01"
amount.toString(opts: PaymentAmountStringOptions(padFractions: 3)) // "EUR 0.010"
amount.toString(opts: PaymentAmountStringOptions(padIntegers: 2)) // "EUR   0.01"


Stars: 0
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics