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(payment_methods): Implement Process tracker workflow for Payment method Status update #4668

Merged
merged 16 commits into from
Jun 21, 2024

Conversation

Sarthak1799
Copy link
Contributor

@Sarthak1799 Sarthak1799 commented May 17, 2024

Type of Change

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

Description

This PR -

  • Implemented a process tracker workflow for status update after pm client_secret expiry

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?

When vaulting is done within session -

  1. Create a Payment_method
curl --location --request POST 'http:https://localhost:8080/payment_methods' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_cHN6hMdCFUUrNWjYSxnwhiuMsg83rXTX9jBmtHmCL6sq9a43PswY304MSt3a9blR' \
--data-raw '{
    "customer_id": "cus_LALaPcTuxxmCBORKevPC"
}'

Response -

{
    "merchant_id": "sarthak1",
    "customer_id": "cus_LALaPcTuxxmCBORKevPC",
    "payment_method_id": "pm_gnnmqGeng12XWnsr3AWy",
    "payment_method": null,
    "payment_method_type": null,
    "card": null,
    "recurring_enabled": false,
    "installment_payment_enabled": false,
    "payment_experience": null,
    "metadata": null,
    "created": "2024-06-19T08:58:05.050Z",
    "last_used_at": null,
    "client_secret": "pm_gnnmqGeng12XWnsr3AWy_secret_ikc5JKsFFREjtR9hk5Co"
}
  1. Vault using /save
curl --location --request POST 'http:https://localhost:8080/payment_methods/pm_gnnmqGeng12XWnsr3AWy/save' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_16e38a16176e45298a70da6c56c5028d' \
--data-raw '{
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_issuer": "visa",
    "client_secret": "pm_gnnmqGeng12XWnsr3AWy_secret_ikc5JKsFFREjtR9hk5Co",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "08",
            "card_exp_year": "2028",
            "card_holder_name": "joseph"
        }
    }
}'

Response -

{
    "merchant_id": "sarthak1",
    "customer_id": null,
    "payment_method_id": "pm_gnnmqGeng12XWnsr3AWy",
    "payment_method": "card",
    "payment_method_type": "credit",
    "card": {
        "scheme": null,
        "issuer_country": null,
        "last4_digits": "4242",
        "expiry_month": "08",
        "expiry_year": "2028",
        "card_token": null,
        "card_holder_name": "joseph",
        "card_fingerprint": null,
        "nick_name": null,
        "card_network": null,
        "card_isin": "424242",
        "card_issuer": null,
        "card_type": null,
        "saved_to_locker": true
    },
    "recurring_enabled": false,
    "installment_payment_enabled": false,
    "payment_experience": [
        "redirect_to_url"
    ],
    "metadata": null,
    "created": "2024-06-19T08:58:19.752Z",
    "last_used_at": "2024-06-19T08:58:19.752Z",
    "client_secret": "pm_gnnmqGeng12XWnsr3AWy_secret_ikc5JKsFFREjtR9hk5Co"
}

DB entry for PT -
image

When vaulting is not done within session -

  1. Create Payment method -
curl --location --request POST 'http:https://localhost:8080/payment_methods' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_cHN6hMdCFUUrNWjYSxnwhiuMsg83rXTX9jBmtHmCL6sq9a43PswY304MSt3a9blR' \
--data-raw '{
    "customer_id": "cus_LALaPcTuxxmCBORKevPC"
}'

Response -

{
    "merchant_id": "sarthak1",
    "customer_id": "cus_LALaPcTuxxmCBORKevPC",
    "payment_method_id": "pm_LlMdO3mS6HQ9EJLfDpL3",
    "payment_method": null,
    "payment_method_type": null,
    "card": null,
    "recurring_enabled": false,
    "installment_payment_enabled": false,
    "payment_experience": null,
    "metadata": null,
    "created": "2024-06-19T09:04:11.634Z",
    "last_used_at": null,
    "client_secret": "pm_LlMdO3mS6HQ9EJLfDpL3_secret_4565heI7J2bLsBgTLbJ5"
}
  1. Vault using /save after session expiry -
curl --location --request POST 'http:https://localhost:8080/payment_methods/pm_LlMdO3mS6HQ9EJLfDpL3/save' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_16e38a16176e45298a70da6c56c5028d' \
--data-raw '{
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_issuer": "visa",
    "client_secret": "pm_LlMdO3mS6HQ9EJLfDpL3_secret_4565heI7J2bLsBgTLbJ5",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "08",
            "card_exp_year": "2028",
            "card_holder_name": "joseph"
        }
    }
}'

Response -

{
    "error": {
        "type": "invalid_request",
        "message": "The payment method with the specified details already exists in our records",
        "code": "HE_01"
    }
}

DB entry after session expiry -
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

@Sarthak1799 Sarthak1799 added A-process-tracker Area: Process tracker C-feature Category: Feature request or enhancement A-payment-methods Area: Payment Methods labels May 17, 2024
@Sarthak1799 Sarthak1799 self-assigned this May 17, 2024
@Sarthak1799 Sarthak1799 requested review from a team as code owners May 17, 2024 07:57
@Sarthak1799 Sarthak1799 linked an issue May 27, 2024 that may be closed by this pull request
2 tasks
crates/router/src/core/payment_methods.rs Outdated Show resolved Hide resolved
crates/router/src/core/payment_methods.rs Outdated Show resolved Hide resolved
crates/router/src/core/payment_methods/cards.rs Outdated Show resolved Hide resolved
Copy link
Member

@vspecky vspecky left a comment

Choose a reason for hiding this comment

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

Logic LGTM

Chethan-rao
Chethan-rao previously approved these changes Jun 14, 2024
Copy link
Member

@NishantJoshi00 NishantJoshi00 left a comment

Choose a reason for hiding this comment

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

LGTM

@NishantJoshi00
Copy link
Member

Can you attach some test cases

@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 21, 2024
Merged via the queue into main with commit 5cde7ee Jun 21, 2024
11 checks passed
@likhinbopanna likhinbopanna deleted the payment-methods-pt branch June 21, 2024 09:06
pixincreate added a commit that referenced this pull request Jun 24, 2024
…ough-hyperswitch-cypress

* 'main' of github.com:juspay/hyperswitch:
  feat(router): add support for googlepay step up flow (#2744)
  fix(access_token): use `merchant_connector_id` in access token (#5106)
  feat: added kafka events for authentication create and update (#4991)
  feat(ci): add vector to handle logs pipeline (#5021)
  feat(users): Decision manager flow changes for SSO (#4995)
  ci(cypress): Fix payment method id for non supported connectors (#5075)
  refactor(core): introduce an interface to switch between old and new connector integration implementations on the connectors (#5013)
  refactor(events): populate object identifiers in outgoing webhooks analytics events during retries (#5067)
  Refactor: [Fiserv] Remove Default Case Handling (#4767)
  chore(version): 2024.06.24.0
  fix(router): avoid considering pre-routing results during `perform_session_token_routing` (#5076)
  refactor(redis): spawn one subscriber thread for handling all the published messages to different channel (#5064)
  feat(users): setup user authentication methods schema and apis (#4999)
  feat(payment_methods): Implement Process tracker workflow for Payment method Status update (#4668)
  chore(version): 2024.06.20.1
  chore(postman): update Postman collection files
  fix(payment_methods): support last used for off session token payments (#5039)
  ci(postman): add net_amount field test cases (#3286)
  refactor(connector): [Mifinity]dynamic fields for mifinity (#5056)
  refactor(payment_method): [Klarna] store and populate payment_type for klarna_sdk Paylater in response (#4956)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payment-methods Area: Payment Methods A-process-tracker Area: Process tracker C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Process tracker flow for PaymentMethod Status update
5 participants