Manual key in a Card Payment
Taking a Payment
To accept a payment, you’ll need to collect information from the customer and tokenize it to create an Omni PaymentMethod. You can then use this PaymentMethod with Fattmerchant’s Omni API to run the transaction.
Collect payment information
You first want to collect card information and populate a CreditCard object.
var card = CreditCard(personName: "Joan Parsnip",
cardNumber: "4111111111111111",
cardExp: "1220",
addressZip: "32814")
Once you have a CreditCard object, create a _TransactionRequest _object with it and pass it to Omni’s pay method.
var transactionRequest = TransactionRequest(amount: Amount(cents: 3), card: card)
omni?.pay(transactionRequest: transactionRequest, completion: { completedTransaction ->
log("Finished transaction successfully")
}, error: { error in
log(error)
})
Testing
If you’d like to try tokenization without real payment information, you can use the _CreditCard.testCreditCard() _method to get a test credit card.
val creditCard = CreditCard.testCreditCard()
If you want to test failures, you can use the following method:
val failingCreditCard = CreditCard.failingTestCreditCard()
Or you can create the CreditCard object with the following testing payment information:
CREDIT CARD NUMBERS
Card Type | Good Card | Bad Card |
---|---|---|
Visa | 4111111111111111 | 4012888888881881 |
Mastercard | 5555555555554444 | 5105105105105100 |
AmEx | 378282246310005 | 371449635398431 |
Discover | 6011111111111117 | 6011000990139424 |
JCB | 3569990010030400 | 3528327757705979 |
Diner's Club | 30569309025904 | 30207712915383 |
Use any CVV number and a post-dated expiration date for the above cards.
Updated 7 months ago