hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

refactor(billing): store `payment_method_data_billing` for recurring payments

Open Narayanbhat166 opened this issue 1 year ago • 0 comments

Type of Change

  • [x] Refactoring

Description

When a card or any payment method is saved, the billing address associated with it is also stored. This has to be presented back when the payment method is listed. This PR adds support for storing and retrieving the payment_method_billing during listing the payment methods associated to a customer.

Motivation and Context

How did you test it?

  • Create a CIT payment with payment_method_data.billing.
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_oN54ym4AmrV4om0Cs5Roq2JShISv69npT9BgwdsYABeTkhCmI77V5Gdpeqy7hwWE' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "customer": {
        "id": "cus_abc",
        "email": "[email protected]"
    },
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "127.0.0.1",
            "user_agent": "amet irure esse"
        }
    },
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "4000000000001091",
            "card_exp_month": "12",
            "card_exp_year": "26",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        },
        "billing": {
            "address": {
                "line1": "1467",
                "line2": "Harrison Street",
                "city": "San Fransico",
                "state": "California",
                "zip": "94122",
                "country": "US",
                "first_name": "Narayan",
                "last_name": "Bhat"
            }
        }
    },
    "setup_future_usage": "off_session"
}'
  • Do list customer payment methods, and ensure that the billing field is populated

Checklist

  • [x] I formatted the code cargo +nightly fmt --all
  • [x] I addressed lints thrown by cargo clippy
  • [x] I reviewed the submitted code

Narayanbhat166 avatar May 02 '24 05:05 Narayanbhat166