php – How to create a "Gift Card" with personalized discount in Magento 1.9 on the cart page

The functionality will be =

  1. Enter the gift card number (16 digits)
  2. Enter the PIN of the gift card (6 digits)
  3. Enter the amount (amount entered by the user)

I have already created the entry fields mentioned above on the cart page. But I do not know how to continue.

Website: https://www.happyvalleytea.com/

view of the cart page: https://www.happyvalleytea.com/checkout/cart/ (add any product to the cart)

When the user clicks on the button to apply the gift card, the transaction will be made at an external provider (through a call to the API). The response received from the API should be used as a discount on the cart page.