SwiftLuhn alternatives and similar libraries
Based on the "Payments" category.
Alternatively, view SwiftLuhn alternatives based on common mentions on social networks and blogs.
-
SwiftyStoreKit
Lightweight In App Purchases Swift framework for iOS 8.0+, tvOS 9.0+ and macOS 10.10+ ⛺ -
RevenueCat
In-app purchases and subscriptions made easy. Support for iOS, watchOS, tvOS, macOS, and visionOS. -
CreditCardForm-iOS
CreditCardForm is iOS framework that allows developers to create the UI which replicates an actual Credit Card. -
monza
Ruby Gem for Rails - Easy iTunes In-App Purchase Receipt validation, including auto-renewable subscriptions -
FreemiumKit
The fastest & easiest way to provide in-app purchases & subscriptions in apps for iOS, macOS, tvOS, and visionOS. -
Glassfy
DISCONTINUED. Open source SDK to quickly integrate subscriptions, stop worring about code maintenance, and getting advanced real-time data. Full support for iOS, iPadOS, WatchOS, MacOS
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SwiftLuhn or a related project?
README
SwiftLuhn
Warning! This repository is no longer maintained.
This is a port of the Luhn Algorithm, generally used for validating debit/credit card details, written in Swift.
SwiftLuhn's HEAD is written in Swift 4. If your project doesn't support Swift 4 yet, please use the 0.2.1 tag.
Objective-C port can be found at https://github.com/MaxKramer/ObjectiveLuhn.
Usage
To run the example project, clone the repo, and run pod install
from the Example directory first.
Installation
SwiftLuhn is available through CocoaPods or Carthage (with or without using our pre-built binary).
To install it, simply add the following line to your Podfile:
pod "SwiftLuhn" # use '0.2.1' for Swift 3.X
Or alternatively the following line to your Cartfile:
github "MaxKramer/SwiftLuhn"
Usage
Validation
Call the class method which will throws an exception SwiftLuhn.CardError
if the card is invalid.
let cardNumber = "378282246310005"
do {
try SwiftLuhn.performLuhnAlgorithm(with: cardNumber)
// process payment
}
catch {
// invalid, alert user
}
Alternatively, you can use the String
category:
let isValid = cardNumber.isValidCardNumber()
Card Types
You can also get the type of the card being used which will be one of:
Card Type |
---|
American Express |
Visa |
Mastercard |
Discover |
Diner's Club |
JCB |
do {
let cardType = try SwiftLuhn.cardType(of: cardNumber)
}
catch {
// card is invalid
}
Unit Tests
To run the unit test suite, please open the example project and hit CMD + U.
Sources
Name | Website | Reason |
---|---|---|
Paypal | http://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm | List of valid credit card numbers for the unit tests |
Author
Max Kramer, [email protected], @maxkramer
License
SwiftLuhn is available under the MIT license. See the LICENSE file for more info.
*Note that all licence references and agreements mentioned in the SwiftLuhn README section above
are relevant to that project's source code only.