Skip to main content
Version: Live

configurePayment

The configurePayment function initializes the PayTheory Fragment for processing payments. It sets up the payment fields and validation for collecting and processing payment information.

Function Signature​

fun configurePayment(
configuration: PayTheoryConfiguration,
merchantActivity: PayTheoryMerchantActivity
)

Parameters​

ParameterTypeDescription
configurationPayTheoryConfigurationConfiguration object containing all payment settings
merchantActivityPayTheoryMerchantActivityActivity that implements the PayTheoryMerchantActivity interface

Example Usage​

// Get submit button reference and the PayTheoryFragment
val submitButton = findViewById<PayTheoryButton>(R.id.submit_button)
val payTheoryFragment = supportFragmentManager.findFragmentById(R.id.payment_fragment) as PayTheoryFragment


// Create configuration
val configuration = PayTheoryConfiguration(
apiKey = resources.getString(R.string.api_key),
payTheoryButton = submitButton
).apply {
amount = 1000
paymentMethodType = PaymentMethodType.BANK
}

// Configure the payment after fragment is attached
payTheoryFragment.configurePayment(
merchantActivity = requireActivity() as PayTheoryMerchantActivity,
configuration = configuration
)

Key Configuration Parameters for Payments​

ParameterTypeRequiredDescription
payTheoryButtonPayTheoryButtonYesButton that triggers payment
apiKeyStringYesYour Pay Theory API key
amountIntYesPayment amount in cents (must be > 0)
paymentMethodTypePaymentMethodTypeYesType of payment (CARD, BANK, or CASH)
requireAccountNameBooleanNoWhether to require account name field
requireBillingAddressBooleanNoWhether to require billing address fields
feeModeStringNoFee handling mode ("service_fee", "surcharge", etc.)
confirmationBooleanNoWhether to require payment confirmation
metadataMap<String, Any>NoAdditional data to associate with payment
payorInfoPayorInfoNoInformation about the person paying
sendReceiptBooleanNoWhether to send a receipt
receiptDescriptionStringNoDescription for the receipt
paymentParametersStringNoAdditional payment parameters
referenceStringNoReference identifier for the payment
accountCodeStringNoAccount code for the payment
invoiceIdStringNoInvoice identifier

Important Notes​

  • The amount parameter must be greater than 0 (will throw an exception if ≤ 0)
  • The API key must be valid and contain the correct partner and stage information
  • A network connection is required for payment processing
  • The fragment must be configured before calling transact()
  • Different payment methods (CARD, BANK, CASH) will display different input fields
  • Billing address zip code is always required, even if requireBillingAddress is false

For complete details on all available configuration options, please see: