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): updated payments response with payment_method_id & payment_method_status #3883

Merged
merged 53 commits into from
Mar 11, 2024

Conversation

prajjwalkumar17
Copy link
Contributor

@prajjwalkumar17 prajjwalkumar17 commented Feb 29, 2024

Type of Change

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

Description

This change incorporates every payment's response with 2 additional fields namely:
-> payment_method_id
-> payment_method_status

Additional Changes

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

Motivation and Context

The change will provide more context about the payment_method being used to carry out the payment.

How did you test it?

We will have payment_method_id and payment_method_status in every payment's response(except Create).
Sample curl:

Payment done using token:

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

{
    "payment_token": "token_XXXXXXXXX",
    "payment_method": "card",
    "card_cvc": "123"
}

Response should include these two fields

   "payment_method_id": "pm_pzFcNslye3gZLxUlmDbg",
    "payment_method_status": null

(This will be updated after @vspecky PR linking issue here)

Payment done using Payment Data & Customer Acceptance:

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

curl --location 'http://127.0.0.1:8080/payments/pay_GnDHbieYt7GBDhJj79j3/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_eZdRVkfE8sbYE7JSzm2Tu0HAca0PHRY6u3JoSFBukHuxoYeXw7bgwr7Gy2DJn1kS' \
--data '{
    "payment_method": "card",
        "payment_method_data": {
        "card": {
            "card_number": "5555 5555 5555 4444",
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737"
        }
    } ,  
  "retry_action": "manual_retry",
        "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    }
}'

Response should include these two fields null as we are doing the operation of saving card in tokio spawn.

    "payment_method_id": null,
    "payment_method_status": null

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 self-assigned this Feb 29, 2024
@prajjwalkumar17 prajjwalkumar17 requested review from a team as code owners February 29, 2024 03:22
@prajjwalkumar17 prajjwalkumar17 marked this pull request as draft February 29, 2024 03:22
@prajjwalkumar17 prajjwalkumar17 linked an issue Feb 29, 2024 that may be closed by this pull request
@prajjwalkumar17 prajjwalkumar17 added A-core Area: Core flows C-refactor Category: Refactor labels Feb 29, 2024
@prajjwalkumar17 prajjwalkumar17 added this to the February 2024 Release milestone Feb 29, 2024
@prajjwalkumar17 prajjwalkumar17 changed the title refactor(core): updated payment's response with payment_method_id refactor(core): updated payment's response with 'payment_method_id' & 'payment_method_status' Mar 1, 2024
@prajjwalkumar17 prajjwalkumar17 changed the title refactor(core): updated payment's response with 'payment_method_id' & 'payment_method_status' refactor(core): updated payment's response with payment_method_id & payment_method_status Mar 1, 2024
@prajjwalkumar17 prajjwalkumar17 marked this pull request as ready for review March 1, 2024 11:45
@prajjwalkumar17 prajjwalkumar17 requested review from a team as code owners March 1, 2024 11:45
@prajjwalkumar17 prajjwalkumar17 requested a review from vspecky March 1, 2024 11:46
vspecky
vspecky previously approved these changes Mar 8, 2024
apoorvdixit88
apoorvdixit88 previously approved these changes Mar 8, 2024
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 left a comment

Choose a reason for hiding this comment

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

Dashboard specific changes are ok

Narayanbhat166
Narayanbhat166 previously approved these changes Mar 8, 2024
srujanchikke
srujanchikke previously approved these changes Mar 9, 2024
Copy link
Contributor

@srujanchikke srujanchikke left a comment

Choose a reason for hiding this comment

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

Reviewed connector code!

@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 10, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 10, 2024
@SanchithHegde SanchithHegde changed the title refactor(core): updated payment's response with payment_method_id & payment_method_status refactor(core): updated payments response with payment_method_id & payment_method_status Mar 10, 2024
@SanchithHegde SanchithHegde enabled auto-merge March 10, 2024 15:05
@SanchithHegde SanchithHegde added this pull request to the merge queue Mar 10, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 10, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 11, 2024
Merged via the queue into main with commit 7391416 Mar 11, 2024
10 of 12 checks passed
@likhinbopanna likhinbopanna deleted the feat/core_pm_id_in_response branch March 11, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Payment Method ID to be provided in payment response
7 participants