Using PayTR Direct API, you can save users' credit card information on PayTR during payment and continue to receive payments quickly in subsequent payments without having to re-enter card information. In this article, we will explain the "Save New Card" process in detail.
Related Guide:
Card Saving Process
-
Payment Form: A "Save My Card" checkbox is displayed while the user enters payment information.
-
POST Data:
-
store_card=1 is sent.
-
If there is a previously saved card, the utoken information is also sent.
-
-
When Payment is Completed: A new utoken is created by PayTR or the new card is merged with the existing utoken.
-
Notification URL: If the payment is successful, the utoken information is included in the incoming notification. It should be saved in your system.
Data to be Used in Token Generation
-
merchant_id
-
user_ip
-
merchant_oid
-
email
-
payment_amount
-
payment_type ('card')
-
installment_count (0,2,3..)
-
currency
-
test_mode
-
non_3d
In addition, store_card and utoken, if available, should be added to the POST content.
POST REQUEST Parameters
Parameter | Required | Description |
---|---|---|
merchant_id | Yes | Merchant number |
paytr_token | Yes | Output token |
user_ip | Yes | Customer IP address |
merchant_oid | Yes | Order number |
Yes | Customer email address | |
payment_type | Yes | 'card' |
payment_amount | Yes | Payment amount |
installment_count | Yes | Number of installments |
card_type | No | Card type |
currency | No | Currency |
test_mode | No | Test mode |
non_3d | Yes | Whether 3D Secure will be used |
cc_owner | Yes | Cardholder |
card_number | Yes | Card number |
expiry_month | Yes | Month |
expiry_year | Yes | Year |
cvv | Yes | CVV code |
merchant_ok_url | Yes | Successful payment page |
merchant_fail_url | Yes | Failed payment page |
user_name | Yes | Customer name |
user_address | Yes | Customer address |
user_phone | Yes | Customer phone number |
user_basket | Yes | Basket JSON |
debug_on | No | Error display |
utoken | No | If there is a previously saved card |
store_card | Yes | Card saving request |
Sample PHP Form Code
<input type="checkbox" name="store_card" value="1"/> Save My Card
<input type="hidden" name="utoken" value="<?php echo $utoken; ?>">
Important Notes
-
If Utoken is not sent, a new token is created and no association is established with the old cards.
-
If the store_card parameter is not sent as 1, the card saving process will not be performed.
-
In the customer's subsequent payments, they are only allowed to select the card using utoken.
Conclusion
Thanks to this structure, you can securely save users' card information in the PayTR infrastructure, providing both a PCI DSS compliant infrastructure and accelerating the payment process.