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

fix(core): fix 3DS mandates, for the connector _mandate_details to be stored in the payment_methods table #4323

Merged
merged 9 commits into from
Apr 19, 2024

Conversation

Aprabhat19
Copy link
Contributor

@Aprabhat19 Aprabhat19 commented Apr 8, 2024

Type of Change

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

Description

After complete_authorize, or Psync the connector_mandate_details wasn't getting stored in the PaymentMethods table. Hence the recurringMandate would fail with the error Payment Methods not found
In this PR , we fix the 3ds mandate payments

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?

  • Create a 3DS off-session payment/
  • Create

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_njRmxwKH6ktMs37HQLB07DhgK1sFgROrpNiUiUgiSKyIzpoz3Wa5vKDCWc6PQlLe' \
--data-raw '{
    "amount": 6777,
    "currency": "USD",
    "confirm": false,
    
    "customer_id": "new-c77",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
     "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",   
"setup_future_usage":"off_session",
    "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"
        }
    },

    "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"
        }
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    }
}'

-> Confirm

curl --location 'http://localhost:8080/payments/pay_UvTYFgVG2EelieqJlHZu/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_njRmxwKH6ktMs37HQLB07DhgK1sFgROrpNiUiUgiSKyIzpoz3Wa5vKDCWc6PQlLe' \
--data '{
    "confirm": true,
    
    
    
        
        
        
        
        
        
        
        
          "payment_method": "card",
    "payment_method_type": "credit",
    
    "payment_method_data": {
        "card": {
             "card_number": "4242424242424242",
            "card_exp_month": "12",
            "card_exp_year": "2043",
            "card_holder_name": "Cy1",
            "card_cvc": "123"
        }
    },
        
      "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "in sit",
                "user_agent": "amet irure esse"
            }}

}'
  • Make a recurring off_Session:true payment
  • Create

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_njRmxwKH6ktMs37HQLB07DhgK1sFgROrpNiUiUgiSKyIzpoz3Wa5vKDCWc6PQlLe' \
--data-raw '{
    "amount": 1000,
    "currency": "USD",
    "confirm": true,
    
    "customer_id": "new-c77",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    
   
    "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"
        }
    },
    
    "off_session":true,
      "recurring_details":{
        "type":"payment_method_id",
        "data":"pm_SrFlrDpRmqb9ObWTB4E6"
    },
    "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"
        }
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    }
}'

Response

{
    "payment_id": "pay_Kr0zqnLF7YvlfGambRdv",
    "merchant_id": "merchant_1712557617",
    "status": "succeeded",
    "amount": 1000,
    "net_amount": 1000,
    "amount_capturable": 0,
    "amount_received": 1000,
    "connector": "cybersource",
    "client_secret": "pay_Kr0zqnLF7YvlfGambRdv_secret_1g5i4yaC24q3cryBXRaH",
    "created": "2024-04-08T06:33:18.853Z",
    "currency": "USD",
    "customer_id": "new-c77",
    "customer": {
        "id": "new-c77",
        "name": "Joseph Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "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": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "2043",
            "card_holder_name": "Cy1",
            "payment_checks": null,
            "authentication_data": null
        },
        "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": "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
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "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": "new-c77",
        "created_at": 1712557998,
        "expires": 1712561598,
        "secret": "epk_f0f3118f76554bc0862a93601aa6b628"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7125580011196185103955",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        }
    },
    "feature_metadata": null,
    "reference_id": "pay_Kr0zqnLF7YvlfGambRdv_1",
    "payment_link": null,
    "profile_id": "pro_WiTyPlqeoWjRO22EiiNb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_cwp0jm7FkjSYWpeXVkG0",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-04-08T06:48:18.853Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_SrFlrDpRmqb9ObWTB4E6",
    "payment_method_status": "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

@Aprabhat19 Aprabhat19 added A-core Area: Core flows C-bug Category: Bug A-payment-methods Area: Payment Methods labels Apr 8, 2024
@Aprabhat19 Aprabhat19 self-assigned this Apr 8, 2024
@Aprabhat19 Aprabhat19 requested a review from a team as a code owner April 8, 2024 06:09
vspecky
vspecky previously approved these changes Apr 17, 2024
@@ -475,6 +475,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
let m_merchant_account = merchant_account.clone();
let m_request = request.clone();
let m_key_store = key_store.clone();
let m_payment_method_id = payment_attempt.payment_method_id.clone();
Copy link
Member

Choose a reason for hiding this comment

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

payment_method_id can also be passed in the confirm request right? why are we always inferring it from payment_attempt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, right we won't need to infer it in the update and confirm. Will pass None

@pixincreate pixincreate added this pull request to the merge queue Apr 19, 2024
Merged via the queue into main with commit f4e5784 Apr 19, 2024
10 of 12 checks passed
@pixincreate pixincreate deleted the fix-3ds branch April 19, 2024 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows A-payment-methods Area: Payment Methods C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fix] 3DS mandates, for the connector _mandate_details to be stored in the payment_methods table
4 participants