Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/La-casa-del-bordadito/llms.txt

Use this file to discover all available pages before exploring further.

La Casa del Bordadito lets you save payment cards to your account so checkout is faster. Saved cards are listed in the Configuración sub-tab of the Cuenta screen and are pulled into the checkout flow whenever you choose card as your payment method. Cards are stored in Firebase Realtime Database under your user node.

Where cards are stored

Each saved card lives at Usuarios/{uid}/metodosPago/{cardId} in the Realtime Database. The PaymentMethod data class defines the structure:
data class PaymentMethod(
    var id: String         = "",
    var last4: String      = "",
    var brand: String      = "",   // "VISA", "MASTERCARD", "AMEX", "DISCOVER"
    var holderName: String = "",
    var expiry: String     = "",   // "MM/AA"
    var isDefault: Boolean = false
) {
    fun maskedNumber() = "**** **** **** $last4"
}
FieldDescription
idFirebase push key generated by ref.push().key
last4Last four digits of the card number
brandCard network string from EditCredit’s cardType
holderNameCardholder name as typed
expiryExpiry date formatted as MM/AA
isDefaulttrue for the first card added; false for subsequent ones

Adding a new card

1

Open the add-card screen

In the Cuenta tab, switch to Configuración. Tap Agrega tu primera tarjeta (shown when no cards exist yet) or Agregar otra tarjeta (shown when at least one card is already saved). Either button launches TarjetaAgregarActivity.
If you already have 5 saved cards, tapping the button shows the message “Máximo 5 tarjetas permitidas” and TarjetaAgregarActivity is not opened. Remove an existing card first.
2

Enter card details

The form contains four fields:
FieldValidation
Card numberValidated by editCreditView.isCardValid (EditCredit library)
Cardholder nameMust not be empty
Expiry dateMust match `^(0[1-9]1[0-2])/\d$— auto-formatted asMM/AA` while you type
CVVMust be exactly 3 digits
The card number field formats digits automatically and detects the card brand in real time as you type.
3

Card brand detection

The brand string is read directly from the EditCredit view after validation:
val brand  = binding.editCreditView.cardType.toString()
val rawNum = binding.editCreditView.textWithoutSeparator ?: ""
val last4  = rawNum.takeLast(4)
Supported brands detected by the library: Visa, Mastercard, Amex, Discover. Unrecognised prefixes produce "Unknown".
4

Save to Firebase

guardarTarjetaBD() pushes the new card under metodosPago. It first checks whether any cards already exist to set isDefault:
val ref = FirebaseDatabase.getInstance().getReference("Usuarios")
    .child(firebaseAuth.uid!!).child("metodosPago")

val id = ref.push().key ?: return

ref.get().addOnSuccessListener { snapshot ->
    val isDefault = !snapshot.exists() || snapshot.childrenCount == 0L
    val method = PaymentMethod(id, last4, brand, holder, expiry, isDefault)

    ref.child(id).setValue(method)
}

Deleting a card

Tap the delete action on any saved card in the Configuración list. An AlertDialog confirms the action:
“¿Deseas eliminar la tarjeta terminada en ?”
Confirming calls removeValue() on Usuarios/{uid}/metodosPago/{cardId}. The list updates in real time through the ValueEventListener already attached to metodosPago.

Using a card at checkout

When placing an order, select the Tarjeta toggle in the payment step. A dialog displays all saved cards, each shown with its brand and masked number (e.g., Visa **** **** **** 4242). Tap a card to select it — the metodoPago field of the order is recorded as the card’s description string.

Supported card brands

Visa

Prefix: 4

Mastercard

Prefix: 51–55, 2221–2720

Amex

Prefix: 34, 37

Discover

Prefix: 6011, 622126–622925, 644–649, 65
Card details (last 4 digits, brand, expiry, and holder name) are stored directly in Firebase Realtime Database for display purposes. No actual payment processing is performed — this is a demonstration flow and does not charge any real card. Full payment gateway integration (e.g., Stripe or Conekta) would be required before going live.

Build docs developers (and LLMs) love