Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(connector): [Fiuu] Add support for cards recurring payments #6361

Merged
merged 14 commits into from
Oct 25, 2024

Conversation

srujanchikke
Copy link
Contributor

@srujanchikke srujanchikke commented Oct 18, 2024

Type of Change

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

Description

Add mandates support for fiuu

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?

Complete flow for mandates can be tested for fiuu, since it only works in Production environment. But CIT can be tested in sandbox.

Test cases

added cypress tests :
cypress tests cannot be written for manual capture mandates, since token is not stored in our system when payment status is authoirzed and after authoirze we don't recieve connector mandate id via psync/ webhooks.

Screenshot 2024-10-25 at 9 12 37 AM

payments create curl

       curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ••••••' \
--data '{
    "amount": 1650,
    "currency": "EUR",
    "confirm": false,
    "customer_id": "customer123"
}'

payments confirm curl(non 3ds)

      curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ••••••' \
--data-raw '{
    "amount": 100,
    "currency": "MYR",
    "confirm": true,
    "payment_link": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 100,
    "customer_id": "askdjfhak",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "5105105105105100",
            "card_exp_month": "12",
            "card_exp_year": "2030",
            "card_holder_name": "Max Mustermann",
            "card_cvc": "444"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "CA",
            "line3": "CA",
            "city": "Musterhausen",
            "state": "California",
            "zip": "12345",
            "country": "MY",
            "first_name": "Max",
            "last_name": "Mustermann"
        },
        "email": "test@novalnet.de",
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "Musterstr",
            "line2": "CA",
            "line3": "CA",
            "city": "Musterhausen",
            "state": "California",
            "zip": "94122",
            "country": "MY",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "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,
        "ip_address": "103.77.139.95",
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "2024-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    }
}'

payments confirm curl(3ds)

To test this flow you must enable source verification of webhooks, since we get connector mandate id after customer redirection

      curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ••••••' \
--data-raw '{
    "amount": 100,
    "currency": "MYR",
    "confirm": true,
    "payment_link": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 100,
    "customer_id": "askdjfhak",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "5105105105105100",
            "card_exp_month": "12",
            "card_exp_year": "2030",
            "card_holder_name": "Max Mustermann",
            "card_cvc": "444"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "CA",
            "line3": "CA",
            "city": "Musterhausen",
            "state": "California",
            "zip": "12345",
            "country": "MY",
            "first_name": "Max",
            "last_name": "Mustermann"
        },
        "email": "test@novalnet.de",
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "Musterstr",
            "line2": "CA",
            "line3": "CA",
            "city": "Musterhausen",
            "state": "California",
            "zip": "94122",
            "country": "MY",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "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,
        "ip_address": "103.77.139.95",
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "2024-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    }
}'

MIT payment

{
    "amount": 100,
    "currency": "MYR",
    "confirm": true,
    "customer_id": "askdjfhak",
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_5eoWmqvkM5yNV6NXLq1Y"
    },
    "off_session": true
}

Failed MIT response(MIT is only available in prod, so this expected to be failed in sandbox)

{
    "payment_id": "pay_fPsF4EScs9b6XBaDmkTH",
    "merchant_id": "merchant_1729234816",
    "status": "failed",
    "amount": 100,
    "net_amount": 100,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "fiuu",
    "client_secret": "pay_fPsF4EScs9b6XBaDmkTH_secret_xAGbTuDRi7DaS4p8cMpz",
    "created": "2024-10-18T09:35:01.594Z",
    "currency": "MYR",
    "customer_id": "askdjfhak",
    "customer": {
        "id": "askdjfhak",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "5100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "510510",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "2030",
            "card_holder_name": "Max Mustermann",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": "Your transaction has been denied due to merchant account issue",
    "error_message": "Your transaction has been denied due to merchant account issue",
    "unified_code": "UE_000",
    "unified_message": "Something went wrong",
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "askdjfhak",
        "created_at": 1729244101,
        "expires": 1729247701,
        "secret": "epk_a494b068207e428f953b7fc8918f6208"
    },
    "manual_retry_allowed": true,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_F72cs1AonZSiAcoUAPab",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5e5QYpZY6LNZKRvOju4h",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-10-18T09:50:01.594Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_5eoWmqvkM5yNV6NXLq1Y",
    "payment_method_status": "active",
    "updated": "2024-10-18T09:35:02.149Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "e2740266aab85558"
}

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

@srujanchikke srujanchikke requested review from a team as code owners October 18, 2024 03:39
Copy link

semanticdiff-com bot commented Oct 18, 2024

Review changes with SemanticDiff.

Analyzed 7 of 11 files.

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

Filename Status
✔️ cypress-tests/cypress/support/commands.js 97.56% smaller
✔️ cypress-tests/cypress/e2e/PaymentUtils/Fiuu.js Analyzed
✔️ crates/router/src/core/payments/operations/payment_create.rs 41.29% smaller
✔️ crates/router/src/configs/defaults.rs Analyzed
✔️ crates/hyperswitch_connectors/src/utils.rs Analyzed
✔️ crates/hyperswitch_connectors/src/connectors/fiuu.rs 43.48% smaller
✔️ crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs 3.83% smaller
config/development.toml Unsupported file format
config/deployments/integration_test.toml Unsupported file format
config/deployments/production.toml Unsupported file format
config/deployments/sandbox.toml Unsupported file format

@srujanchikke srujanchikke self-assigned this Oct 18, 2024
@srujanchikke srujanchikke added A-connector-integration Area: Connector integration S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-feature Category: Feature request or enhancement labels Oct 18, 2024
awasthi21
awasthi21 previously approved these changes Oct 18, 2024
awasthi21
awasthi21 previously approved these changes Oct 18, 2024
@srujanchikke srujanchikke added M-configuration-changes Metadata: This PR involves configuration changes and removed M-configuration-changes Metadata: This PR involves configuration changes labels Oct 18, 2024
@awasthi21 awasthi21 self-requested a review October 21, 2024 06:48
awasthi21
awasthi21 previously approved these changes Oct 21, 2024
dracarys18
dracarys18 previously approved these changes Oct 21, 2024
Copy link
Member

@dracarys18 dracarys18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from @juspay/hyperswitch-framework

@Gnanasundari24
Copy link
Contributor

@srujanchikke Have you run the cypress for fiuu? If not,please run and share the result in PR

@srujanchikke srujanchikke requested review from a team as code owners October 24, 2024 20:56
ShankarSinghC
ShankarSinghC previously approved these changes Oct 25, 2024
status: 200,
body: {
error_code: "No error code",
error_message:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this behaviour happening for Fiuu also ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fixed
Screenshot 2024-10-25 at 4 19 46 PM

@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 25, 2024
Merged via the queue into main with commit 4647a2f Oct 25, 2024
17 checks passed
@likhinbopanna likhinbopanna deleted the fiuu_mandates branch October 25, 2024 13:24
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Oct 27, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants