# PaymentManager

interface PaymentManager

Processes payments for Mobile Payments SDK.

`PaymentManager` is a singleton instance, retrieved from MobilePaymentsSdk.paymentManager like the other managers. Use it by starting a payment with startPaymentActivity.

When calling startPaymentActivity, the developer has an option to either use the default payment prompt screen or provide a custom one (see PromptMode). This screen is where the customer is asked to swipe, insert, or tap a card.

If the custom screen is used, the Mobile Payments SDK will take control over UI, once the customer interacts with the card reader.

During the payment flow, Mobile Payments SDK will show screens (for example, to collect PIN numbers, and to confirm the completed transaction to the user), which will be dismissed by the time the payment completion callback is called.

## Types

IdempotencyKeyData
Link copied to clipboard
data class IdempotencyKeyData(val updatedAt: Date, val paymentAttemptId: String, val idempotencyKey: String)

Data retrieved from PaymentManager.getAllIdempotencyKeys.

## Properties

currentPaymentHandle
Link copied to clipboard
abstract val currentPaymentHandle: PaymentHandle?

A PaymentHandle for interacting with the currently active payment, or null if no payment is in progress.

## Functions

completePayment
Link copied to clipboard
abstract fun completePayment(paymentId: String, callback: Callback<PaymentResult>): PaymentHandle

Completes a previously-authorized payment.

getAllIdempotencyKeys
Link copied to clipboard
abstract fun getAllIdempotencyKeys(callback: Callback<GetAllIdempotencyKeysResult>): CallbackReference

Retrieves all payment attempt IDs and their respective idempotency keys from local storage.

getAvailableCardEntryMethods
Link copied to clipboard
abstract fun getAvailableCardEntryMethods(): Set<CardEntryMethod>

Retrieves the possible card entry methods to take a payment. This is the union of all the several card readers' supported card entry methods.

getIdempotencyKey
Link copied to clipboard
abstract fun getIdempotencyKey(paymentAttemptId: String): GetIdempotencyKeyResult

Retrieves the idempotency key used in the payment request associated with the given paymentAttemptId, if the paymentAttemptId was used in the last 24 hours. The returned idempotency key can be used to a cancel a payment via the Square Payments API: https://developer.squareup.com/reference/square/payments-api/cancel-payment-by-idempotency-key

getOfflinePaymentQueue
Link copied to clipboard
abstract fun getOfflinePaymentQueue(): OfflinePaymentQueue

Returns an OfflinePaymentQueue interface, used to interact with offline payments.

setAvailableCardEntryMethodChangedCallback
Link copied to clipboard
abstract fun setAvailableCardEntryMethodChangedCallback(callback: Callback<Set<CardEntryMethod>>): CallbackReference

Registers a callback to notify the application when the set of available card entry methods changes. For example, as a magstripe reader is inserted or removed, this callback will be called to reflect the availability of the SWIPED card entry method.

startPaymentActivity
Link copied to clipboard
abstract fun startPaymentActivity(paymentParameters: PaymentParameters, promptParameters: PromptParameters, callback: Callback<PaymentResult>): PaymentHandle

Begins a payment, using the provided paymentParameters to set the payment information.