Skip to main content

Remember card(ComfortPay)

ComfortPay is separate service that gives ability to remember user credit card for future usage.

warning

If you want to use this functionality you need to be eligible for this feature. For more info please contact Tatrabanka support.

Register to save user card

To be able to save user credit card you need to do one payment and specify parameter card_detail.comfort_pay.

payment_data = InitiatePaymentRequest(
base_payment=BasePayment(
instructed_amount=Amount(
amount_value=10.0,
currency="EUR",
),
end_to_end="ORDER123456",
),
card_detail=CardDetail(
card_holder="Janko Hruška",
comfort_pay=RegisterForComfortPayObj(register_for_comfort_pay=True)
)
...
)

Retrieve and save card token

After the successful payment with card_detail.comfort_pay = RegisterForComfortPayObj(register_for_comfort_pay=True) you will receive data about customer card in saved_card variable.

payment_id="b54afd37-5bb9-4080-9416-5ec450779087" # Retrieved from create payment intent
response = client.get_payment_status(payment_id)
#response["saved_card"] -> {'cid': '123456789', 'credit_card': 'Visa', 'masked_card_number': '440577******5558'}
PropertyPurpose
cidThis token should be saved to persistent storage on customer
masked_card_numberCan be shown to user to be able to pickup from saved cards
credit_cardCredit card type name

Use saved token

After you saved cid token to customer. You should show customer saved cards on your website. When user selects one of the saved cards, you need to pass cid to generate_signed_card_id_from_cid and result of this function can be passed to comfort_pay.SignedCardIdObj().

cid = customer.cid  # cid taken from stored customer
signed_cid = client.generate_signed_card_id_from_cid(cid)
payment_data = InitiatePaymentRequest(
base_payment=BasePayment(
instructed_amount=Amount(
amount_value=120.0,
currency="EUR",
),
end_to_end="ORDER123456",
),
user_data=UserData(
first_name="Janko",
last_name="Hruska",
email="janko.hruska@example.com",
phone="+421911123456",
),
card_detail=CardDetail(
card_holder="Janko Hruška",
comfort_pay=SignedCardIdObj(signed_card_id=signed_cid)
)
...
)