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(events): add audit event for CompleteAuthorize #6310

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

hex1c
Copy link
Contributor

@hex1c hex1c commented Oct 14, 2024

Type of Change

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

Description

Created from #4674

This covers adding events for CompleteAuthorize operation

How did you test it

Use globalpay as connector, wallet as payment_method and paypal as payment_method_type

          "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "paypal",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
         }

Create a payment:

{
    "amount": 600,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 600,
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "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": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect":{}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "DE",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "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": "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"
    }
}

Response:

{
    "payment_id": "pay_AkkvFG6dZN3gasgy729h",
    "merchant_id": "postman_merchant_GHAction_93d97914-663d-4099-b4a2-a9ec314d654e",
    "status": "requires_customer_action",
    "amount": 600,
    "net_amount": 600,
    "amount_capturable": 600,
    "amount_received": null,
    "connector": "globalpay",
    "client_secret": "pay_AkkvFG6dZN3gasgy729h_secret_XLheDrFzLzXL7eF0BOxV",
    "created": "2024-11-06T14:35:59.773Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "DE",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_AkkvFG6dZN3gasgy729h/postman_merchant_GHAction_93d97914-663d-4099-b4a2-a9ec314d654e/pay_AkkvFG6dZN3gasgy729h_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "paypal",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "StripeCustomer",
        "created_at": 1730903759,
        "expires": 1730907359,
        "secret": "epk_2f5f6461495c44d5836e790820a006f4"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "TRN_N8FIKEvvsrYO5xqzUcwgzTLg9dXnCq_3gasgy729h_1",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_AkkvFG6dZN3gasgy729h_1",
    "payment_link": null,
    "profile_id": "pro_S5r08g7HrBg5FT2NWS3l",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_8uJfYpthurOSVoLJwxfR",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-06T14:50:59.773Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-11-06T14:36:02.437Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Hit the redirction_url and complete the payment.

Audit logs will get generated and can be viewed in hyperswitch-audit-events topic in kafka with PaymentCompleteAuthorize event-type.

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

@hex1c hex1c requested review from a team as code owners October 14, 2024 13:49
Copy link

semanticdiff-com bot commented Oct 14, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments/operations/payment_complete_authorize.rs  0% smaller
  crates/router/src/events/audit_events.rs  0% smaller

@gorakhnathy7 gorakhnathy7 added hacktoberfest-accepted Pull requests accepted as Hacktoberfest contributions hacktoberfest Issues that are up for grabs for Hacktoberfest participants labels Oct 31, 2024
tsdk02
tsdk02 previously approved these changes Nov 4, 2024
@tsdk02
Copy link
Contributor

tsdk02 commented Nov 5, 2024

Hey @hex1c,
Please link an issue with this PR.
Thanks

@gorakhnathy7 gorakhnathy7 requested review from Chethan-rao and removed request for lsampras and sai-harsha-vardhan November 5, 2024 06:11
ShankarSinghC
ShankarSinghC previously approved these changes Nov 5, 2024
@gorakhnathy7 gorakhnathy7 linked an issue Nov 5, 2024 that may be closed by this pull request
@Gnanasundari24
Copy link
Contributor

@tsdk02 Can you add the testcases for this PR.

CC : @gorakhnathy7

@tsdk02
Copy link
Contributor

tsdk02 commented Nov 6, 2024

@tsdk02 Can you add the testcases for this PR.

CC : @gorakhnathy7

@Gnanasundari24 I have added the test case, and it works as expected.

@gorakhnathy7 gorakhnathy7 removed the request for review from Chethan-rao November 7, 2024 06:58
@likhinbopanna likhinbopanna added this pull request to the merge queue Nov 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Nov 7, 2024
@maverox
Copy link
Contributor

maverox commented Nov 13, 2024

@hex1c The conflicts are still unresolved.

@tsdk02 tsdk02 requested a review from Chethan-rao December 4, 2024 10:59
@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 5, 2024
Merged via the queue into juspay:main with commit dc26317 Dec 5, 2024
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues that are up for grabs for Hacktoberfest participants hacktoberfest-accepted Pull requests accepted as Hacktoberfest contributions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add audit events for CompleteAuthorize update
8 participants