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(router): [stripe] remove passing of customer_acceptance from Mandate Payment Request #5922

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

AkshayaFoiger
Copy link
Contributor

Type of Change

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

Description

Remove passing customer_acceptance from mandate payment request as, this mandates collecting ip_address within the customer_acceptance filed. Causing issue in backwards compatibility. For mandate payment, where customer_acceptance passed inside mandate_data - browser_info.ip_address is made mandatory. This change will not break the current setup

Hotfix for #5920

How did you test it?

Do a mandate payment with customer_acceptance, passed inside the

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Q5lDnJyyZPJQBTu6xnMQ3l6TevlS8H6hreld9Fc2MhHG2qYLwfK8NKxv0fd9z0Ib' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "tester1t236",
 "setup_future_usage": "off_session",
            "customer_acceptance": {
            "acceptance_type": "offline",
            
            "online": {
                
                "user_agent": "amet irure esse"
            }
        },
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242", 
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737",
            "card_network": "Visa"
        }
    },
    "off_session": true
}'

Response

{
    "payment_id": "pay_28Z8NGWQb9mUpkiscqeI",
    "merchant_id": "postman_merchant_GHAction_aa253a44-6c71-48ff-a883-070b210acecd",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "amount_capturable": 0,
    "amount_received": 6540,
    "connector": "stripe",
    "client_secret": "pay_28Z8NGWQb9mUpkiscqeI_secret_zzEGpbZyxO0qL7YwNy4Y",
    "created": "2024-09-17T09:06:46.139Z",
    "currency": "USD",
    "customer_id": "tester1t236",
    "customer": {
        "id": "tester1t236",
        "name": null,
        "email": null,
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "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": "03",
            "card_exp_year": "30",
            "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": null,
    "billing": {
        "address": null,
        "phone": null,
        "email": "[email protected]"
    },
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": null,
    "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": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "tester1t236",
        "created_at": 1726564006,
        "expires": 1726567606,
        "secret": "epk_742fd5f69af24890a175a35e58d7ea18"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3PzxMwD5R7gDAGff1n8tOIYf",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3PzxMwD5R7gDAGff1n8tOIYf",
    "payment_link": null,
    "profile_id": "pro_CtUqopilw81GJSu7FrLG",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_jrHH0dDWmkWB0PDidaaO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-09-17T09:21:46.139Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-09-17T09:06:47.344Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null
}
  1. MIT
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Q5lDnJyyZPJQBTu6xnMQ3l6TevlS8H6hreld9Fc2MhHG2qYLwfK8NKxv0fd9z0Ib' \
--data '{
    "amount": 999,
    "currency": "USD",
    "confirm": true,
    "customer_id": "tester1t236",
    "return_url": "https://google.com",
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_0atZy25rnp4Upea62OL4"
    },
    "off_session": true   
}'

Response

{
    "payment_id": "pay_iyy0GoKr1cWnDCQbJafw",
    "merchant_id": "postman_merchant_GHAction_aa253a44-6c71-48ff-a883-070b210acecd",
    "status": "succeeded",
    "amount": 999,
    "net_amount": 999,
    "amount_capturable": 0,
    "amount_received": 999,
    "connector": "stripe",
    "client_secret": "pay_iyy0GoKr1cWnDCQbJafw_secret_YrQhkkP0mfRgiS4NhdZW",
    "created": "2024-09-17T09:10:15.843Z",
    "currency": "USD",
    "customer_id": "tester1t236",
    "customer": {
        "id": "tester1t236",
        "name": null,
        "email": null,
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": null,
            "card_network": "Visa",
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": null,
                "address_postal_code_check": null
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "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": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "tester1t236",
        "created_at": 1726564215,
        "expires": 1726567815,
        "secret": "epk_277642003c204535bb44ca6deb2bb867"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3PzxQKD5R7gDAGff1IbQYHXz",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3PzxQKD5R7gDAGff1IbQYHXz",
    "payment_link": null,
    "profile_id": "pro_CtUqopilw81GJSu7FrLG",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_jrHH0dDWmkWB0PDidaaO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-09-17T09:25:15.843Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_0atZy25rnp4Upea62OL4",
    "payment_method_status": "active",
    "updated": "2024-09-17T09:10:16.991Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null
}
  1. Create a mandate payment by passing customer_acceptance within the mandate data
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Q5lDnJyyZPJQBTu6xnMQ3l6TevlS8H6hreld9Fc2MhHG2qYLwfK8NKxv0fd9z0Ib' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "tester1t236",
    "setup_future_usage": "off_session",
    "mandate_data": {
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "13.232.74.226",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "single_use": {
                "amount": 6540,
                "currency": "USD"
            }
        }
    },
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242", 
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737",
            "card_network": "Visa"
        }
    },
    "off_session": true,   
}'

Response

{
    "payment_id": "pay_pS1lyObTEUe2Aa1Gav5C",
    "merchant_id": "postman_merchant_GHAction_aa253a44-6c71-48ff-a883-070b210acecd",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "amount_capturable": 0,
    "amount_received": 6540,
    "connector": "stripe",
    "client_secret": "pay_pS1lyObTEUe2Aa1Gav5C_secret_aOo1XetqAUDUZ28xoXYb",
    "created": "2024-09-17T09:11:55.669Z",
    "currency": "USD",
    "customer_id": "tester1t236",
    "customer": {
        "id": "tester1t236",
        "name": null,
        "email": null,
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_sv2RkDNHoodgljuAbegW",
    "mandate_data": {
        "update_mandate_id": null,
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "13.232.74.226",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "single_use": {
                "amount": 6540,
                "currency": "GBP",
                "start_date": null,
                "end_date": null,
                "metadata": null
            }
        }
    },
    "setup_future_usage": "off_session",
    "off_session": true,
    "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": "03",
            "card_exp_year": "30",
            "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": null,
    "billing": {
        "address": null,
        "phone": null,
        "email": "[email protected]"
    },
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": null,
    "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": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "tester1t236",
        "created_at": 1726564315,
        "expires": 1726567915,
        "secret": "epk_844470aed8da40d8a6dab0bdbf50d21e"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3PzxRwD5R7gDAGff13carNp3",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3PzxRwD5R7gDAGff13carNp3",
    "payment_link": null,
    "profile_id": "pro_CtUqopilw81GJSu7FrLG",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_jrHH0dDWmkWB0PDidaaO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-09-17T09:26:55.669Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_wguSSTbhAZ4Go7SF5SGp",
    "payment_method_status": null,
    "updated": "2024-09-17T09:11:57.451Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null
}
  1. MIT
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Q5lDnJyyZPJQBTu6xnMQ3l6TevlS8H6hreld9Fc2MhHG2qYLwfK8NKxv0fd9z0Ib' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",

    "customer_id": "tester1t236",
    "off_session": true,
    
     "mandate_id": "man_sv2RkDNHoodgljuAbegW",  
}'

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

@AkshayaFoiger AkshayaFoiger requested a review from a team as a code owner September 17, 2024 10:38
Copy link

semanticdiff-com bot commented Sep 17, 2024

Review changes with SemanticDiff.

Analyzed 1 of 1 files.

Overall, the semantic diff is 80% smaller than the GitHub diff.

Filename Status
✔️ crates/router/src/connector/stripe/transformers.rs 79.13% smaller

@AkshayaFoiger AkshayaFoiger self-assigned this Sep 17, 2024
@AkshayaFoiger AkshayaFoiger added A-connector-integration Area: Connector integration C-bug Category: Bug labels Sep 17, 2024
@AkshayaFoiger AkshayaFoiger linked an issue Sep 17, 2024 that may be closed by this pull request
2 tasks
@AkshayaFoiger AkshayaFoiger changed the base branch from main to hotfix-2024.09.13.0 September 17, 2024 10:39
@AkshayaFoiger AkshayaFoiger force-pushed the stripe-customer-acceptance branch from 9bc5fec to 232aea5 Compare September 17, 2024 11:32
@likhinbopanna likhinbopanna merged commit adc0503 into hotfix-2024.09.13.0 Sep 17, 2024
15 checks passed
@likhinbopanna likhinbopanna deleted the stripe-customer-acceptance branch September 17, 2024 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants