[WEB - SDK] - Add Payment Method with Dynamic Field Rendering - Boleto
The Hyperswitch SDK is a versatile tool built to streamline payment integration for developers. It simplifies the process of adding multiple payment methods, allowing you to quickly implement support for various gateways without the need to manually integrate each one. With Hyperswitch, you can efficiently manage payments across platforms, reducing complexity and boosting development speed.
Getting started
- Get familiar with ReScript.
- Check the README.md for project structure and setup instructions.
- To setup locally, follow these steps
# Clone repository
cd hyperswitch-web
yarn install
yarn run server # This starts the mock server
yarn run re:start # In another terminal
# Start Demo App in another terminal
cd hyperswitch-react-demo-app
yarn install
yarn run start # This starts the demo app
Description:
We are looking to implement a new payment method in our WebSDK that supports dynamic field rendering. The goal is to allow the backend to define the fields required for the payment method and have the frontend WebSDK render these fields dynamically based on the response.
This feature should be flexible enough to handle different payment methods, each potentially requiring different types of input fields (e.g., text fields, dropdowns, checkboxes, etc.).
Requirements:
-
Payment Method Integration Details:
In this section, we provide details on the payment call response and the confirm call payload for the newly integrated payment method. Ensure you have configured the payment method at Hyperswitch Dashboard correctly. The backend already includes support for this payment method, so no additional configuration is needed.
Payment Method List Response for Boleto -
{ "payment_method": "voucher", "payment_method_types": [ { "payment_method_type": "boleto", "payment_experience": [ { "payment_experience_type": "redirect_to_url", "eligible_connectors": ["adyen"] } ], "card_networks": null, "bank_names": null, "bank_debits": null, "bank_transfers": null, "required_fields": { "billing.address.state": { "required_field": "payment_method_data.billing.address.state", "display_name": "state", "field_type": "user_address_state", "value": "California" }, "billing.address.first_name": { "required_field": "payment_method_data.billing.address.first_name", "display_name": "card_holder_name", "field_type": "user_full_name", "value": "joseph" }, "billing.address.line1": { "required_field": "payment_method_data.billing.address.line1", "display_name": "line1", "field_type": "user_address_line1", "value": "1467" }, "billing.address.city": { "required_field": "payment_method_data.billing.address.city", "display_name": "city", "field_type": "user_address_city", "value": "San Francisco" }, "billing.address.line2": { "required_field": "payment_method_data.billing.address.line2", "display_name": "line2", "field_type": "user_address_line2", "value": "Harrison Street" }, "billing.address.zip": { "required_field": "payment_method_data.billing.address.zip", "display_name": "zip", "field_type": "user_address_pincode", "value": "94122" }, "billing.address.last_name": { "required_field": "payment_method_data.billing.address.last_name", "display_name": "card_holder_name", "field_type": "user_full_name", "value": "Doe" }, "payment_method_data.voucher.boleto.social_security_number": { "required_field": "payment_method_data.voucher.boleto.social_security_number", "display_name": "social_security_number", "field_type": "text", "value": null }, "billing.address.country": { "required_field": "payment_method_data.billing.address.country", "display_name": "country", "field_type": { "user_address_country": { "options": ["BR"] } }, "value": "BR" } }, "surcharge_details": null, "pm_auth_connector": null } ] }Confirm call Payload should look like:
curl --location 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_NjinrcPO8hJCWRArZdNLxS5u3H04sKbrP0RWPsJ53UbLDb2nmFg6eIy5mUOcxNZt' \ --data '{ "amount": 1000, "currency": "BRL", "confirm": true, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "amount_to_capture": 1000, "phone_country_code": "+1", "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://duck.com", "payment_method": "voucher", "payment_method_type": "boleto", "payment_method_data": { "voucher": { "boleto": { "social_security_number": "56861752509" } }, "billing": { "address": { "line1": "1467", "line2": "Harrison Street", "city": "San Fransico", "state": "SP", "zip": "04386040", "country": "BR", "first_name": "joseph", "last_name": "Doe" } } } }' -
Dynamic Field Rendering:
- Based on the backend response, the WebSDK should dynamically generate the necessary input fields.
- Each field should be properly validated (e.g., required, length, pattern matching) based on the backend specifications.
- Support different types of fields such as:
- Text fields (e.g., for name, card number)
- Select dropdowns (e.g., for country or card type)
- Checkbox fields (e.g., for terms and conditions)
- User Inputs:
- Once the user fills in the fields, the WebSDK should package the input data and send it back to the backend for payment processing.
Contribution Guidelines:
- Fork the repository and create a new branch for your work.
- Ensure the WebSDK follows best practices for API integration and field rendering.
- Write clean, well-documented code with clear commit messages.
- Add unit tests to ensure the dynamic field rendering works as expected.
- Make sure to follow our coding standards and contribution guidelines.
Helpful Resources:
- Link to WebSDK documentation: WebSDK Docs
- Link to the API endpoint specifications: API Docs
Submission Process:
- Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
- Once assigned, submit a pull request (PR).
- Maintainers will review and provide feedback, if any.
- Maintainers can unassign issues due to inactivity, read more here.
Refer here for Terms and conditions for the contest.
If you have any questions or need help getting started, feel free to ask in the comments!
Hi @sakksham7 @gorakhnathy7 , I would like to work on this issue. Please assign it to me.
Hey @Ankesh2004 Thanks for your interest. But, as I can see, you have requested too many issues at once, I would suggested working on the issues one by one. Kindly avoid raising an assignment request on too many issues at once.
Hey @gorakhnathy7 @sakksham7, I would like to work on this issue.
Hey @codermks you are already assigned another issue. Kindly let me know once you are done with it.
Since @codermks multiple issues, I’d be happy to take on this issue if no one else is actively working on it @gorakhnathy7
Hey @Monis-Ahmed-Rizvi Assigning this issue to you, Thanks for your interest!
Hey @Monis-Ahmed-Rizvi
Kindly let us know, if you're still working on the issue? If you have any questions or need assistance, feel free to reach out in the community.