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

refactor(core): removed the processing status for payment_method_status #4213

Merged
merged 2 commits into from
Apr 1, 2024

Conversation

prajjwalkumar17
Copy link
Contributor

Type of Change

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

Description

This will remove the processing status from payment_method_status and by default makes everything active or failure.
This is a patch to ensure that no payment_method goes to non-terminal.

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?

Sample curl:

Payment Create with confirm as false:

curl --location 'http://127.0.0.1:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_eZdRVkfE8sbYE7JSzm2Tu0HAca0PHRY6u3JoSFBukHuxoYeXw7bgwr7Gy2DJn1kS' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "cus_v6LovN3Zs9k8QQ2UYcbi",
    "business_country": "US",
    "business_label": "default",
    "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": "4111111111111111",
            "card_exp_month": "10",
            "card_exp_year": "40",
            "card_holder_name": "John",
            "card_cvc": "737"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594430",
            "country_code": "+91"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}

'

Payment's Confirm using token

curl --location 'http://127.0.0.1:8080/payments/pay_y5QhUc1Z5Y14FYOQ7qcm/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_xxxx' \
--data '{
    "payment_token": "token_UCstChJwCzgeWKlPJijf",
    "card_cvc": "123"
}'

Response should include these two fields

   "payment_method_id": "pm_pzFcNslye3gZLxUlmDbg",
    "payment_method_status": "active" (previously it was null)

The possible status and mappings are as follows:

            AttemptStatus::Failure => Self::Inactive,

             AttemptStatus::Voided
            | AttemptStatus::Started
            | AttemptStatus::Pending
            | AttemptStatus::Unresolved
            | AttemptStatus::CodInitiated
            | AttemptStatus::Authorizing
            | AttemptStatus::VoidInitiated
            | AttemptStatus::AuthorizationFailed
            | AttemptStatus::RouterDeclined
            | AttemptStatus::AuthenticationSuccessful
            | AttemptStatus::PaymentMethodAwaited
            | AttemptStatus::AuthenticationFailed
            | AttemptStatus::AuthenticationPending
            | AttemptStatus::CaptureInitiated
            | AttemptStatus::CaptureFailed
            | AttemptStatus::VoidFailed
            | AttemptStatus::AutoRefunded
            | AttemptStatus::PartialCharged
            | AttemptStatus::PartialChargedAndChargeable
            | AttemptStatus::ConfirmationAwaited
            | AttemptStatus::DeviceDataCollectionPending
            | AttemptStatus::Charged
            | AttemptStatus::Authorized => Self::Active,

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
  • I added a CHANGELOG entry if applicable

@prajjwalkumar17 prajjwalkumar17 added the A-core Area: Core flows label Mar 26, 2024
@prajjwalkumar17 prajjwalkumar17 added this to the March 2024 milestone Mar 26, 2024
@prajjwalkumar17 prajjwalkumar17 self-assigned this Mar 26, 2024
@prajjwalkumar17 prajjwalkumar17 requested a review from a team as a code owner March 26, 2024 16:10
@prajjwalkumar17 prajjwalkumar17 linked an issue Mar 26, 2024 that may be closed by this pull request
@prajjwalkumar17

This comment was marked as outdated.

@likhinbopanna likhinbopanna added this pull request to the merge queue Apr 1, 2024
Merged via the queue into main with commit a843713 Apr 1, 2024
19 of 23 checks passed
@likhinbopanna likhinbopanna deleted the refactor/paymnet_method_status branch April 1, 2024 07:45
pixincreate added a commit that referenced this pull request Apr 1, 2024
* 'main' of github.com:juspay/hyperswitch:
  refactor(core): removed the processing status for payment_method_status (#4213)
  docs(README): remove link to outdated early access form
  build(deps): bump `error-stack` from version `0.3.1` to `0.4.1` (#4188)
  chore(version): 2024.04.01.0
  feat(mandates): allow off-session payments using `payment_method_id` (#4132)
  ci(CI-pr): determine modified crates more deterministically (#4233)
  chore(config): add billwerk base URL in deployment configs (#4243)
  feat(payment_method): API to list countries and currencies supported by a country and payment method type (#4126)
  chore(version): 2024.03.28.0
  refactor(config): allow wildcard origin for development and Docker Compose setups (#4231)
  fix(core): Amount capturable remain same for `processing` status in capture (#4229)
  fix(euclid_wasm): checkout wasm metadata issue (#4198)
  fix(trustpay): [Trustpay] Add error code mapping '800.100.100'  (#4224)
  feat(connector): [billwerk] add connector template code (#4123)
  fix(connectors): fix wallet token deserialization error  (#4133)
  fix(log): adding span metadata to `tokio` spawned futures (#4118)
  chore(version): 2024.03.27.0
  fix(connector): [CRYPTOPAY] Skip metadata serialization if none (#4205)
  fix(connector): [Trustpay] fix deserialization error for incoming webhook response for trustpay and add error code mapping '800.100.203' (#4199)
  fix(core): make eci in AuthenticationData optional (#4187)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Patch]: Remove processing state from payment_method_status
5 participants