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 setup mandate payments to store connector mandate details #6450

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

Aprabhat19
Copy link
Contributor

Type of Change

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

Description

This is hot fix for the PR
Earlier, for setup mandate flows we were not populating the Payment Method Info field, due to which for the Setup Mandate Payments the connector_mandate_details where not getting populated in the payment methods table. This PR fixes setup mandate payments to store connector mandate details, in the payment methods table.

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 Off -session payment , with 0 dollar
Create
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-feature: router-custom' \
--header 'api-key: dev_x0Y92cBUtNSQwvW9B6xfQRtg8NxoURcyMbGh9kiqxO5EfMidDo31Ji6McelAQv9M' \
--data-raw '{
    "amount": 0,
    "currency": "USD",
    "confirm": false,
    
    "customer_id": "CustomerX777",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "no_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"
        }
    },

    
      "metadata": {
    "app": "a"
  },
    "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_JDQtw7MFaPchY3gJ0xGC/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-feature: router-custom' \
--header 'api-key: pk_dev_e42fea0492c243978ec319ee82a94c51' \
--data '{
    "confirm": true,
      "payment_type": "setup_mandate",
    "client_secret":"pay_JDQtw7MFaPchY3gJ0xGC_secret_bpP5xPEd2Zvr5jEroitS",
    "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"
        }
    },
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36",
        "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "125.0.0.1"
    }, 
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    
     
    "payment_method": "card",

     "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
"card_number": "4242424242424242",   
            "card_exp_month": "06",
            "card_exp_year": "2030",
            "card_holder_name": "John T",
    
            
            "card_cvc": "737"
        }
    }
}'
Reponse
{
    "payment_id": "pay_JDQtw7MFaPchY3gJ0xGC",
    "merchant_id": "merchant_1730098839",
    "status": "succeeded",
    "amount": 0,
    "net_amount": 0,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "stripe",
    "client_secret": "pay_JDQtw7MFaPchY3gJ0xGC_secret_bpP5xPEd2Zvr5jEroitS",
    "created": "2024-10-28T07:19:45.274Z",
    "currency": "USD",
    "customer_id": "CustomerX777",
    "customer": {
        "id": "CustomerX777",
        "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": "off_session",
    "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": "06",
            "card_exp_year": "2030",
            "card_holder_name": null,
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": null,
                "address_postal_code_check": 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": "no_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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "seti_1QEnEtD5R7gDAGffhfd9hFkh",
    "frm_message": null,
    "metadata": {
        "app": "a"
    },
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        }
    },
    "feature_metadata": null,
    "reference_id": "seti_1QEnEtD5R7gDAGffhfd9hFkh",
    "payment_link": null,
    "profile_id": "pro_SdclHp0ZF1u6viEq46vN",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_bn8MAJKkNFGaqH6qaRG9",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-10-28T07:34:45.274Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "125.0.0.1",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_method_id": "pm_akEAWRV4UHi885VyYzGz",
    "payment_method_status": "active",
    "updated": "2024-10-28T07:19:48.342Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QEnEtD5R7gDAGffZ1kEyYpk"
}
  • The payment is a success

  • The connector mandate details would be stored in the table

Screenshot 2024-10-28 at 12 57 20 PM - the list customer also has requires cvv is also false
{
    "customer_payment_methods": [
        {
            "payment_token": "token_7X6J0bZ7CkkwGs6txRuH",
            "payment_method_id": "pm_akEAWRV4UHi885VyYzGz",
            "customer_id": "CustomerX777",
            "payment_method": "card",
            "payment_method_type": "debit",
            "payment_method_issuer": null,
            "payment_method_issuer_code": null,
            "recurring_enabled": true,
            "installment_payment_enabled": false,
            "payment_experience": [
                "redirect_to_url"
            ],
            "card": {
                "scheme": null,
                "issuer_country": null,
                "last4_digits": "4242",
                "expiry_month": "06",
                "expiry_year": "2030",
                "card_token": null,
                "card_holder_name": "John T",
                "card_fingerprint": null,
                "nick_name": null,
                "card_network": null,
                "card_isin": "424242",
                "card_issuer": null,
                "card_type": null,
                "saved_to_locker": true
            },
            "metadata": null,
            "created": "2024-10-28T07:50:07.878Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": false,
            "last_used_at": "2024-10-28T07:50:07.878Z",
            "default_payment_method_set": true,
            "billing": {
                "address": {
                    "city": "San Fransico",
                    "country": "US",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "John",
                    "last_name": "T"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": null
            }
        }
    ],
    "is_guest_customer": false
}

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

@Aprabhat19 Aprabhat19 requested a review from a team as a code owner October 28, 2024 09:17
Copy link

semanticdiff-com bot commented Oct 28, 2024

Review changes with SemanticDiff.

Analyzed 1 of 1 files.

Filename Status
✔️ crates/router/src/core/payments/operations/payment_response.rs Analyzed

@Aprabhat19 Aprabhat19 self-assigned this Oct 28, 2024
@likhinbopanna likhinbopanna merged commit a71219c into hotfix-2024.10.18.0 Oct 28, 2024
15 of 18 checks passed
@likhinbopanna likhinbopanna deleted the fix-setupmandates branch October 28, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix(core): fix setup mandate payments to store connector mandate details
4 participants