hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

refactor(payment_method_data): send optional billing details in response

Open Narayanbhat166 opened this issue 1 year ago • 0 comments

Type of Change

  • [x] Refactoring

Description

Since the payment_method_billing has been made optional, If passed in the request, it will be present in the response too.

Additional Changes

  • [ ] This PR modifies the API contract
  • [ ] This PR modifies the database schema
  • [ ] This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

  • Create a payment with confirm as false and with payment method billing.

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_cgBkVO7LcoXTqBEqqBRZQGfz9utfGqUFm7wBLhU5hm3oD7HHjXteBtzXVxIgpChw' \
--data '{
    "amount": 6540,
    "currency": "USD",
    "confirm": false,
    "customer_id": "cus_PAxm0MeCGM5TowgDKPc9",
    "payment_method_data": {
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": null,
                "zip": "94122",
                "state": "California",
                "first_name": "Narayan",
                "last_name": "Hegde"
            },
            "phone": null,
            "email": null
        }
    }
}'
  • Retrieve the payment and ensure that payment_method_data.billing is present
curl --location 'http://localhost:8080/payments/pay_ANYYJYUlRpU3Wpyqkm8O' \
--header 'Accept: application/json' \
--header 'api-key: dev_cgBkVO7LcoXTqBEqqBRZQGfz9utfGqUFm7wBLhU5hm3oD7HHjXteBtzXVxIgpChw'

Checklist

  • [x] I formatted the code cargo +nightly fmt --all
  • [x] I addressed lints thrown by cargo clippy
  • [x] I reviewed the submitted code
  • [x] I added unit tests for my changes where possible

Narayanbhat166 avatar May 07 '24 12:05 Narayanbhat166