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

feat: add test_mode for quickly testing payout links #5669

Merged
merged 8 commits into from
Aug 27, 2024

Conversation

kashif-m
Copy link
Contributor

@kashif-m kashif-m commented Aug 22, 2024

Type of Change

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

Description

Described in #5668

Additional Changes

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

Motivation and Context

Allows for easily testing payout links in non prod env.

How did you test it?

1. Create payout link without setting allowed_domains - *SHOULD FAIL*
curl --location 'http://localhost:8080/payouts/create' \
    --header 'Accept-Language: fr' \
    --header 'Content-Type: application/json' \
    --header 'api-key: dev_1axlWLG2ZUMWX1B8TMZ7m1Y7EMIzJl5BW1iLEB6etVvLbEQ1XCKSj6rXHYegkkd3' \
    --data '{
        "amount": 1,
        "currency": "EUR",
        "customer_id": "cus_8GU0bxEIp0EyvQiGSoXw",
        "description": "Its my first payout request",
        "billing": {
            "address": {
                "city": "Hoogeveen",
                "country": "NL",
                "line1": "Raadhuisplein",
                "line2": "92",
                "zip": "7901 BW",
                "state": "FL",
                "first_name": "John",
                "last_name": "Doe"
            },
            "phone": {
                "number": "0650242319",
                "country_code": "+31"
            }
        },
        "return_url": "https://www.google.co.in",
        "entity_type": "Individual",
        "confirm": false,
        "auto_fulfill": true,
        "session_expiry": 1000000,
        "priority": "instant",
        "profile_id": "pro_24e5hK7LExVPjGqadW55",
        "payout_link": true,
        "connector": [
            "adyen"
        ],
        "payout_link_config": {
            "theme": "#0066ff",
            "logo": "https://hyperswitch.io/favicon.ico",
            "merchant_name": "HyperSwitch Inc.",
            
            "enabled_payment_methods": [
                {
                    "payment_method": "card",
                    "payment_method_types": [
                        "debit",
                        "credit"
                    ]
                },
                {
                    "payment_method": "bank_transfer",
                    "payment_method_types": [
                        "ach",
                        "bacs",
                        "sepa"
                    ]
                },
                {
                    "payment_method": "wallet",
                    "payment_method_types": [
                        "pix",
                        "paypal",
                        "venmo"
                    ]
                }
            ]
        }
    }'

image

2. Create payout link without setting allowed_domains in test_mode - *PASS*
curl --location 'http://localhost:8080/payouts/create' \
    --header 'Accept-Language: fr' \
    --header 'Content-Type: application/json' \
    --header 'api-key: dev_1axlWLG2ZUMWX1B8TMZ7m1Y7EMIzJl5BW1iLEB6etVvLbEQ1XCKSj6rXHYegkkd3' \
    --data '{
        "amount": 1,
        "currency": "EUR",
        "customer_id": "cus_8GU0bxEIp0EyvQiGSoXw",
        "description": "Its my first payout request",
        "billing": {
            "address": {
                "city": "Hoogeveen",
                "country": "NL",
                "line1": "Raadhuisplein",
                "line2": "92",
                "zip": "7901 BW",
                "state": "FL",
                "first_name": "John",
                "last_name": "Doe"
            },
            "phone": {
                "number": "0650242319",
                "country_code": "+31"
            }
        },
        "return_url": "https://www.google.co.in",
        "entity_type": "Individual",
        "confirm": false,
        "auto_fulfill": true,
        "session_expiry": 1000000,
        "priority": "instant",
        "profile_id": "pro_24e5hK7LExVPjGqadW55",
        "payout_link": true,
        "connector": [
            "adyen"
        ],
        "payout_link_config": {
            "theme": "#0066ff",
            "logo": "https://hyperswitch.io/favicon.ico",
            "merchant_name": "HyperSwitch Inc.",
            "test_mode": true,
            "enabled_payment_methods": [
                {
                    "payment_method": "card",
                    "payment_method_types": [
                        "debit",
                        "credit"
                    ]
                },
                {
                    "payment_method": "bank_transfer",
                    "payment_method_types": [
                        "ach",
                        "bacs",
                        "sepa"
                    ]
                },
                {
                    "payment_method": "wallet",
                    "payment_method_types": [
                        "pix",
                        "paypal",
                        "venmo"
                    ]
                }
            ]
        }
    }'

image

image

3. Create payout link using allowed_domains without test_mode - *SHOULD OPEN ONLY IN AN IFRAME*
curl --location 'http://localhost:8080/payouts/create' \
    --header 'Accept-Language: fr' \
    --header 'Content-Type: application/json' \
    --header 'api-key: dev_1axlWLG2ZUMWX1B8TMZ7m1Y7EMIzJl5BW1iLEB6etVvLbEQ1XCKSj6rXHYegkkd3' \
    --data '{
        "amount": 1,
        "currency": "EUR",
        "customer_id": "cus_8GU0bxEIp0EyvQiGSoXw",
        "description": "Its my first payout request",
        "billing": {
            "address": {
                "city": "Hoogeveen",
                "country": "NL",
                "line1": "Raadhuisplein",
                "line2": "92",
                "zip": "7901 BW",
                "state": "FL",
                "first_name": "John",
                "last_name": "Doe"
            },
            "phone": {
                "number": "0650242319",
                "country_code": "+31"
            }
        },
        "return_url": "https://www.google.co.in",
        "entity_type": "Individual",
        "confirm": false,
        "auto_fulfill": true,
        "session_expiry": 1000000,
        "priority": "instant",
        "profile_id": "pro_24e5hK7LExVPjGqadW55",
        "payout_link": true,
        "connector": [
            "adyen"
        ],
        "payout_link_config": {
            "theme": "#0066ff",
            "logo": "https://hyperswitch.io/favicon.ico",
            "merchant_name": "HyperSwitch Inc.",
            
            "enabled_payment_methods": [
                {
                    "payment_method": "card",
                    "payment_method_types": [
                        "debit",
                        "credit"
                    ]
                },
                {
                    "payment_method": "bank_transfer",
                    "payment_method_types": [
                        "ach",
                        "bacs",
                        "sepa"
                    ]
                },
                {
                    "payment_method": "wallet",
                    "payment_method_types": [
                        "pix",
                        "paypal",
                        "venmo"
                    ]
                }
            ]
        }
    }'

image

image

image

Checklist

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

@kashif-m kashif-m added A-core Area: Core flows S-waiting-on-review Status: This PR has been implemented and needs to be reviewed R-waiting-on-L1 Review: Waiting on L1 reviewer Payouts Area: Payouts labels Aug 22, 2024
@kashif-m kashif-m self-assigned this Aug 22, 2024
@kashif-m kashif-m requested review from a team as code owners August 22, 2024 11:01
Copy link

semanticdiff-com bot commented Aug 22, 2024

Review changes with SemanticDiff.

Analyzed 8 of 11 files.

Overall, the semantic diff is 69% smaller than the GitHub diff.

Filename Status
✔️ crates/router/src/types/transformers.rs Analyzed
✔️ crates/router/src/core/payout_link.rs 54.4% smaller
✔️ crates/router/src/core/payouts.rs 44.04% smaller
✔️ crates/router/src/core/payouts/validator.rs 89.5% smaller
crates/router/src/core/generic_link/payout_link/initiate/script.js Unsupported file format
✔️ crates/diesel_models/src/business_profile.rs Analyzed
crates/common_utils/src/link_utils.rs Unsupported file format
✔️ crates/api_models/src/admin.rs Analyzed
crates/api_models/src/payouts.rs Unsupported file format
✔️ api-reference-v2/openapi_spec.json 12.5% smaller
✔️ api-reference/openapi_spec.json 12.5% smaller

@kashif-m kashif-m added the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 22, 2024
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 22, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 22, 2024
@kashif-m kashif-m linked an issue Aug 22, 2024 that may be closed by this pull request
2 tasks
SanchithHegde
SanchithHegde previously approved these changes Aug 23, 2024
crates/api_models/src/admin.rs Outdated Show resolved Hide resolved
crates/diesel_models/src/business_profile.rs Outdated Show resolved Hide resolved
@kashif-m kashif-m requested a review from jarnura August 26, 2024 09:41
@kashif-m kashif-m requested a review from SanchithHegde August 26, 2024 10:09
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Aug 27, 2024
Merged via the queue into main with commit 406256c Aug 27, 2024
14 checks passed
@Gnanasundari24 Gnanasundari24 deleted the payout-link-test-mode branch August 27, 2024 08:31
pixincreate added a commit that referenced this pull request Aug 27, 2024
* 'main' of github.com:juspay/hyperswitch:
  refactor(open_banking): Added merchant data update in mca update (#5655)
  feat: add test_mode for quickly testing payout links (#5669)
  refactor: introduce a domain type for profile ID (#5687)
  ci(cypress): update paybox configs (#5664)
  feat(openapi):  Add open api routes for routing v2 (#5686)
  feat(connector): [NOVALNET] Add template code (#5670)
  feat(user): business email update (#5674)
  chore(config): add production connector-configs for netcetera external 3ds flow (#5698)
  chore(version): 2024.08.27.0
  refactor(euclid): make the disabled node's relation as negative (#5701)
  feat: populate payment method details in payments response (#5661)
  build(deps): bump `diesel` to `2.2.3` and `sqlx` to `0.8.1` (#5688)
pixincreate added a commit that referenced this pull request Aug 27, 2024
* 'main' of github.com:juspay/hyperswitch: (134 commits)
  refactor(open_banking): Added merchant data update in mca update (#5655)
  feat: add test_mode for quickly testing payout links (#5669)
  refactor: introduce a domain type for profile ID (#5687)
  ci(cypress): update paybox configs (#5664)
  feat(openapi):  Add open api routes for routing v2 (#5686)
  feat(connector): [NOVALNET] Add template code (#5670)
  feat(user): business email update (#5674)
  chore(config): add production connector-configs for netcetera external 3ds flow (#5698)
  chore(version): 2024.08.27.0
  refactor(euclid): make the disabled node's relation as negative (#5701)
  feat: populate payment method details in payments response (#5661)
  build(deps): bump `diesel` to `2.2.3` and `sqlx` to `0.8.1` (#5688)
  feat(customer_v2):  added list customer v2 end point (#5517)
  feat(business_profile): add tax_connector_id column in business_profile table (#5576)
  chore: create v2 route for organization (#5679)
  refactor(payments_response): remove setter from payments response (#5676)
  feat(payment_methods_v2): Payment methods v2 API models (#5564)
  chore(version): 2024.08.26.0
  feat(connector): [Adyen] add dispute flows for adyen connector (#5514)
  chore(version): 2024.08.23.0
  ...
pixincreate added a commit that referenced this pull request Aug 27, 2024
…-key-check

* 'main' of github.com:juspay/hyperswitch:
  feat(core): Add mTLS certificates for each request (#5636)
  refactor(open_banking): Added merchant data update in mca update (#5655)
  feat: add test_mode for quickly testing payout links (#5669)
  refactor: introduce a domain type for profile ID (#5687)
  ci(cypress): update paybox configs (#5664)
  feat(openapi):  Add open api routes for routing v2 (#5686)
  feat(connector): [NOVALNET] Add template code (#5670)
  feat(user): business email update (#5674)
  chore(config): add production connector-configs for netcetera external 3ds flow (#5698)
  chore(version): 2024.08.27.0
  refactor(euclid): make the disabled node's relation as negative (#5701)
  feat: populate payment method details in payments response (#5661)
  build(deps): bump `diesel` to `2.2.3` and `sqlx` to `0.8.1` (#5688)
  feat(customer_v2):  added list customer v2 end point (#5517)
  feat(business_profile): add tax_connector_id column in business_profile table (#5576)
  chore: create v2 route for organization (#5679)
  refactor(payments_response): remove setter from payments response (#5676)
  feat(payment_methods_v2): Payment methods v2 API models (#5564)
  chore(version): 2024.08.26.0
@pixincreate pixincreate removed S-waiting-on-review Status: This PR has been implemented and needs to be reviewed R-waiting-on-L1 Review: Waiting on L1 reviewer labels Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows M-api-contract-changes Metadata: This PR involves API contract changes Payouts Area: Payouts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] allow testing payout links in test_mode
5 participants