hyperswitch-web icon indicating copy to clipboard operation
hyperswitch-web copied to clipboard

feat: add address element for shipping and billing address

Open aritro2002 opened this issue 1 year ago • 1 comments

Type of Change

  • [ ] Bugfix
  • [x] New feature
  • [ ] Enhancement
  • [ ] Refactoring
  • [ ] Dependency updates
  • [ ] Documentation
  • [ ] CI/CD

Description

I have added address elements for shipping and billing addresses. Two new elements have been created: ShippingAddressElement and BillingAddressElement. These elements include a method called getAddress, which is used to fetch the entered details.

By default, all fields are required, but optional fields can also be specified.

Option Supported: Full name: full_name Address Line 1: line1 Address Line 2: line2 City: city State: state Country: country Postal Code: postal_code Phone Number: phone Email: email

Screenshot 2024-12-03 at 4 11 59 PM Screenshot 2024-12-03 at 4 12 23 PM Screenshot 2024-12-03 at 4 13 19 PM Screenshot 2024-12-03 at 4 14 11 PM Screenshot 2024-12-03 at 4 14 44 PM Screenshot 2024-12-04 at 2 50 26 PM

How did you test it?

Clone the repo and then set script src to http://localhost:9050/HyperLoader.js in index.html and the widget name as shippingAddressElement or billingAddressElement in script.js. To make any field optional we need to feed list in the options

const unifiedCheckoutOptions = {
    optional: ["phone", "email", "city", "full_name"],
  };
  const unifiedCheckout = widgets.create(
    "shippingAddressElement",
    unifiedCheckoutOptions
  );

Checklist

  • [ ] I ran npm run re:build
  • [ ] I reviewed submitted code
  • [ ] I added unit tests for my changes where possible

aritro2002 avatar Dec 03 '24 10:12 aritro2002

Review changes with  SemanticDiff

semanticdiff-com[bot] avatar Dec 03 '24 10:12 semanticdiff-com[bot]

Closing this PR for address element for now. Will open this when needed.

@aritro2002 for reference

PritishBudhiraja avatar Jul 02 '25 06:07 PritishBudhiraja