Manual key in a Card Payment

Taking a Payment

Accept a manually entered card payment in your SDK integration by collecting card information and submitting a payment request.

Tokenization replaces card information with a reusable reference. An Omni PaymentMethod is the object that represents that payment information for use with Stax Payments’ API.

Collect payment information

Collect card information and populate a CreditCard object. The payment examples below use Swift and require an initialized omni SDK instance in your application; they are not Kotlin examples for Android.

Use the dummy card below only for testing.

let card = CreditCard(personName: "Joan Parsnip",
                      cardNumber: "4111111111111111",
                      cardExp: "1229",
                      addressZip: "32814")

Create a TransactionRequest (an object containing the amount and card for your payment), then pass it to Omni’s pay method. Keep the request to the required amount and card fields for this example.

// Amount is in cents: 3 represents a $0.03 test payment.
let transactionRequest = TransactionRequest(amount: Amount(cents: 3), card: card)
if let omni = omni {
    omni.pay(transactionRequest: transactionRequest, completion: { completedTransaction in
        print("Finished transaction successfully")
    }, error: { error in
        print("Payment failed: \(error)")
    })
} else {
    print("Payment not started: initialize the SDK first")
}

On success, the completion callback receives completedTransaction and prints:

Finished transaction successfully

If the request fails, the error callback prints Payment failed: followed by the SDK error. If the SDK instance is unavailable, the example prints Payment not started: initialize the SDK first without submitting a payment.




Testing

Use CreditCard.testCreditCard() to create a test card without collecting real payment information. These test-card examples use Kotlin for Android.

val creditCard = CreditCard.testCreditCard()

The result is a CreditCard object you can use in your test integration.

Use CreditCard.failingTestCreditCard() to create a card for testing your failure handling:

val failingCreditCard = CreditCard.failingTestCreditCard()

The result is a test CreditCard object intended for failure tests; use it to exercise your payment error handling.

Or you can create the CreditCard object with the following testing payment information located here: Payment Testing Cards


For these test cards only, use any CVV (the card’s security code) and a future expiration date. Confirm that your integration reports successful test payments and displays errors for failed tests.


Did this page help you?