Skip to main content
Version: Lab (preview)

configureTokenize

The configureTokenize function initializes the PayTheory Fragment for tokenizing payment methods. It sets up the payment fields and validation for storing payment information without processing a payment.

Function Signature​

fun configureTokenize(
configuration: PayTheoryConfiguration,
merchantActivity: PayTheoryMerchantActivity
)

Parameters​

ParameterTypeDescription
configurationPayTheoryConfigurationConfiguration object containing all tokenization 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 {
paymentMethodType = PaymentMethodType.CARD
}

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

Key Configuration Parameters for Tokenization​

ParameterTypeRequiredDescription
payTheoryButtonPayTheoryButtonYesButton that triggers tokenization
apiKeyStringYesYour Pay Theory API key
paymentMethodTypePaymentMethodTypeYesType of payment method to tokenize (CARD or BANK)
requireAccountNameBooleanNoWhether to require account name field
requireBillingAddressBooleanNoWhether to require billing address fields
metadataMap<String, Any>NoAdditional data to associate with token
payorInfoPayorInfoNoInformation about the person paying
payorIdStringNoExisting payor ID to use
skipTokenizeValidationBooleanNoSkip payment method validation. Should only be used if you intend to immediately use the tokenized payment method

Important Notes​

  • The amount parameter should not be set when tokenizing payment methods
  • Cash payment methods cannot be tokenized
  • The API key must be valid and contain the correct partner and stage information
  • A network connection is required for tokenization
  • The fragment must be configured before calling tokenize()

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