Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-SDK] - Add Payment Method with Dynamic Field Rendering - PaySafeCard #658

Open
sakksham7 opened this issue Sep 23, 2024 · 0 comments
Open

Comments

@sakksham7
Copy link
Contributor

sakksham7 commented Sep 23, 2024

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

  1. Get familiar with ReScript.
  2. Check the README.md for project structure and setup instructions.
  3. 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:

  1. 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 Online Banking Poland -

    {
      "payment_method": "gift_card",
      "payment_method_types": [
        {
          "payment_method_type": "pay_safe_card",
          "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": {},
          "surcharge_details": null,
          "pm_auth_connector": null
        },
        {
          "payment_method_type": "givex",
          "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": {
            "payment_method_data.gift_card.cvc": {
              "required_field": "payment_method_data.gift_card.cvc",
              "display_name": "gift_card_cvc",
              "field_type": "user_card_cvc",
              "value": null
            },
            "payment_method_data.gift_card.number": {
              "required_field": "payment_method_data.gift_card.number",
              "display_name": "gift_card_number",
              "field_type": "user_card_number",
              "value": null
            }
          },
          "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: *************************************' \
    --data-raw '{
        "amount": 6540,
        "currency": "PLN",
        "confirm": true,
        "capture_method": "automatic",
        "capture_on": "2022-09-10T10:11:12Z",
            "description": "Its my first payment request",
    
        "payment_method": "bank_redirect",
        "payment_method_type": "online_banking_poland",
        "payment_method_data": {
            "bank_redirect": {
                "online_banking_poland": {
                    "issuer": "velo_bank"
                }
            },
            "billing": {
                "email": "[email protected]"
            }
        },
        "browser_info": {
            "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
            "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            "language": "nl-NL",
            "color_depth": 24,
            "screen_height": 723,
            "screen_width": 1536,
            "time_zone": 0,
            "java_enabled": true,
            "java_script_enabled": true,
            "ip_address": "13.232.74.226"
        }
    }'
  2. 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)
  1. 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:

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!

@sakksham7 sakksham7 added Enhancement / Refactoring New feature or request or any refactoring Good First Issue Good for newcomers Hacktoberfest Issues that are up for grabs for Hacktoberfest participants Medium Effort: Requires a fair amount of work hyperswitch-web This issue relates to hyperswitch-web SDK. rescript This issue requires a solution implemented using ReScript. labels Sep 23, 2024
@sakksham7 sakksham7 changed the title [SDK] - Add Payment Method with Dynamic Field Rendering - PaySafeCard [WEB-SDK] - Add Payment Method with Dynamic Field Rendering - PaySafeCard Sep 25, 2024
@sakksham7 sakksham7 removed Enhancement / Refactoring New feature or request or any refactoring Good First Issue Good for newcomers Hacktoberfest Issues that are up for grabs for Hacktoberfest participants Medium Effort: Requires a fair amount of work hyperswitch-web This issue relates to hyperswitch-web SDK. rescript This issue requires a solution implemented using ReScript. labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant