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 TypeGood CardBad Card
Visa41111111111111114012888888881881
Mastercard55555555555544445105105105105100
AmEx378282246310005371449635398431
Discover60111111111111176011000990139424
JCB35699900100304003528327757705979
Diner's Club3056930902590430207712915383

Use any CVV number and a post-dated expiration date for the above cards.