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(bank-transfer): remove billing from banktransfer payment data #4377

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented Apr 17, 2024

Type of Change

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

Description

This PR includes changes to use payment_method_data.billing.first_name , payment_method_data.last_name and payment_method_data.email instead of payment_method_data.[BankTransfers->BillingDetails] at the connector level. The backwards compatibility is provided.

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?

  1. Create a ACH bank transfer via Sripe
{
    "amount": 800,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 800,
    "customer_id": "poll",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://hs-payments-test.netlify.app/payments",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "HarrisonStreet",
            "line3": "HarrisonStreet",
            "city": "SanFransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "Swangi",
            "last_name": "Kumari"
        },
        "email": "guest@example.com"
    },
    "routing": {
        "type": "single",
        "data": "stripe"
    }
}

Response

{
    "payment_id": "pay_PwoaBj57cd97qTY3fD2i",
    "merchant_id": "postman_merchant_GHAction_d6c78e4f-0f9d-4f4a-9743-6766d9fdf233",
    "status": "requires_payment_method",
    "amount": 800,
    "net_amount": 800,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_PwoaBj57cd97qTY3fD2i_secret_tTbRu9L1cHCJW5u9FpPR",
    "created": "2024-04-22T06:12:35.400Z",
    "currency": "USD",
    "customer_id": "poll",
    "customer": {
        "id": "poll",
        "name": "John Doe",
        "email": "guest@example.com",
        "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": null,
    "payment_method_data": null,
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "SanFransico",
            "country": "US",
            "line1": "1467",
            "line2": "HarrisonStreet",
            "line3": "HarrisonStreet",
            "zip": "94122",
            "state": "California",
            "first_name": "Swangi",
            "last_name": "Kumari"
        },
        "phone": null,
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://hs-payments-test.netlify.app/payments",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "poll",
        "created_at": 1713766355,
        "expires": 1713769955,
        "secret": "epk_be566b80279a4733b916245f2b312084"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_5XMYHhXjaL8JU6uri9nT",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": null,
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-04-22T06:27:35.399Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-04-22T06:12:35.413Z"
}
  1. Confirm Payment
{
    "payment_method": "bank_transfer",
    "payment_method_type": "ach",
    "payment_method_data": {
        "bank_transfer": {
            "ach_bank_transfer": {
                
            }
        }
    },
    "client_secret": "{{client_secret}}"
}

Response:

{
    "payment_id": "pay_PwoaBj57cd97qTY3fD2i",
    "merchant_id": "postman_merchant_GHAction_d6c78e4f-0f9d-4f4a-9743-6766d9fdf233",
    "status": "requires_customer_action",
    "amount": 800,
    "net_amount": 800,
    "amount_capturable": 800,
    "amount_received": null,
    "connector": "stripe",
    "client_secret": "pay_PwoaBj57cd97qTY3fD2i_secret_tTbRu9L1cHCJW5u9FpPR",
    "created": "2024-04-22T06:12:35.400Z",
    "currency": "USD",
    "customer_id": "poll",
    "customer": {
        "id": "poll",
        "name": "John Doe",
        "email": "guest@example.com",
        "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": null,
    "payment_method_data": null,
    "payment_token": "token_y0va7HQFGFLXKHBGI04r",
    "shipping": null,
    "billing": {
        "address": {
            "city": "SanFransico",
            "country": "US",
            "line1": "1467",
            "line2": "HarrisonStreet",
            "line3": "HarrisonStreet",
            "zip": "94122",
            "state": "California",
            "first_name": "Swangi",
            "last_name": "Kumari"
        },
        "phone": null,
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://hs-payments-test.netlify.app/payments",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "next_action": {
        "type": "display_bank_transfer_information",
        "bank_transfer_steps_and_charges_details": {
            "ach_credit_transfer": {
                "account_number": "test_4da19cff5e84",
                "bank_name": "TEST BANK",
                "routing_number": "110000000",
                "swift_code": "TSTEZ122"
            },
            "receiver": {
                "amount_received": 0,
                "amount_charged": 0,
                "amount_remaining": null
            }
        }
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "ach",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_5XMYHhXjaL8JU6uri9nT",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_I4CDvZU9TtNMzAgdFIZX",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-04-22T06:27:35.399Z",
    "fingerprint": null,
    "browser_info": {
        "language": null,
        "time_zone": null,
        "ip_address": null,
        "user_agent": null,
        "color_depth": null,
        "java_enabled": null,
        "screen_width": null,
        "accept_header": null,
        "screen_height": null,
        "java_script_enabled": null
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-04-22T06:12:45.594Z"
}

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

@swangi-kumari swangi-kumari added the A-connector-compatibility Area: Connector compatibility label Apr 17, 2024
@swangi-kumari swangi-kumari self-assigned this Apr 17, 2024
@swangi-kumari swangi-kumari marked this pull request as ready for review April 22, 2024 10:38
@swangi-kumari swangi-kumari requested review from a team as code owners April 22, 2024 10:38
@swangi-kumari swangi-kumari added A-connector-integration Area: Connector integration M-configuration-changes Metadata: This PR involves configuration changes labels Apr 22, 2024
@@ -1252,12 +1252,13 @@ fn get_bank_debit_data(
}
}

fn create_stripe_payment_method(
fn create_stripe_payment_method<F, Req, Res>(
payment_method_data: &domain::PaymentMethodData,
auth_type: enums::AuthenticationType,
payment_method_token: Option<types::PaymentMethodToken>,
is_customer_initiated_mandate_payment: Option<bool>,
billing_address: StripeBillingAddress,
Copy link
Member

Choose a reason for hiding this comment

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

you already have the billing address here right, do we need to use routerdata again here?

Comment on lines 1345 to 1349
let billing_details = StripeBillingAddress {
email: Some(billing_details.email.clone()),
name: Some(billing_details.name.clone()),
email: item.get_optional_billing_email(),
name: item.get_optional_billing_full_name(),
..Default::default()
};
Copy link
Member

Choose a reason for hiding this comment

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

This billing address need not be constructed, since we already have the billing address

Comment on lines 1369 to 1370
email: item.get_optional_billing_email(),
name: item.get_optional_billing_full_name(),
Copy link
Member

Choose a reason for hiding this comment

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

In this case too, this need not be constructed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-compatibility Area: Connector compatibility A-connector-integration Area: Connector integration M-configuration-changes Metadata: This PR involves configuration changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants