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(connector): [BRAINTREE] Implement Card Mandates #5204

Merged
merged 3 commits into from
Jul 5, 2024

Conversation

awasthi21
Copy link
Contributor

@awasthi21 awasthi21 commented Jul 4, 2024

Type of Change

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

Description

Implemented Card Mandates for Braintree (3ds and non_3ds)

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 Call

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:' \
--data-raw '{
    "amount": 20000,
    "currency": "USD",
    "confirm": false,
    "customer_id": "Top19",
    "capture_method": "manual",
    "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"
        }
    }
}'

Confirm

curl --location 'http://localhost:8080/payments/pay_MxDyKb2h2SSRBDLXtWxs/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:' \
--data '{
    "confirm": true,
    "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"
        }
    },
    "customer_acceptance": {
          "acceptance_type": "online",
          "accepted_at":"1963-05-03T04:07:52.723Z",
          "online": {
            "ip_address":"127.0.0.1",
            "user_agent": "amet irure esse"
          }
    },
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "01",
            "card_exp_year": "39",
            "card_holder_name": "John T",
            "card_cvc": "123"
        }
    }
}'

List Payment Methods

curl --location 'http://localhost:8080/customers/Top19/payment_methods' \
--header 'Accept: application/json' \
--header 'api-key:'

Create-Payment-Request

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:' \
--data-raw '{
    "amount": 2010,
    "currency": "USD",
    "confirm": false,
    "customer_id": "Top19",
    "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"
        }
    }
}'

Create-Payment-Response

{
    "payment_id": "pay_MxDyKb2h2SSRBDLXtWxs",
    "merchant_id": "merchant_1720014590",
    "status": "requires_payment_method",
    "amount": 2010,
    "net_amount": 2010,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_MxDyKb2h2SSRBDLXtWxs_secret_njdcIRvNv9qtpPHoHyLz",
    "created": "2024-07-04T09:48:12.048Z",
    "currency": "USD",
    "customer_id": "Top19",
    "customer": {
        "id": "Top19",
        "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": null,
    "payment_method_data": 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": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "Top19",
        "created_at": 1720086492,
        "expires": 1720090092,
        "secret": "epk_34f753e3abf54234b9b6fd4cc0a5e811"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_Q19rbviljib3knkVAslu",
    "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-07-04T10:03:12.048Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-07-04T09:48:12.058Z",
    "charges": null,
    "frm_metadata": null
}

Confirm Payment -Request(Without Card Details)


curl --location 'http://localhost:8080/payments/pay_MxDyKb2h2SSRBDLXtWxs/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_YNXIHGKvXdrAQN4Pkxyq9sEI4sbeRzaLzhaNpXggqj6DZjCUVJIQ6PlTYRnQNqr9' \
--data '{
    "confirm": true,
    "payment_method": "card",
    "payment_token": "token_ypUMbG1eYkl5z5MPiCnC"
}
'

Confirm Payment -Response :

{
    "payment_id": "pay_MxDyKb2h2SSRBDLXtWxs",
    "merchant_id": "merchant_1720014590",
    "status": "processing",
    "amount": 2010,
    "net_amount": 2010,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "braintree",
    "client_secret": "pay_MxDyKb2h2SSRBDLXtWxs_secret_njdcIRvNv9qtpPHoHyLz",
    "created": "2024-07-04T09:48:12.048Z",
    "currency": "USD",
    "customer_id": "Top19",
    "customer": {
        "id": "Top19",
        "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": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "01",
            "card_exp_year": "39",
            "card_holder_name": "John T",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_ypUMbG1eYkl5z5MPiCnC",
    "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": null,
    "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": "dHJhbnNhY3Rpb25fZGJhdmIzbTA",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_Q19rbviljib3knkVAslu",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_Zo7X0AeELs3tli9fCH4s",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-07-04T10:03:12.048Z",
    "fingerprint": null,
    "browser_info": {
        "language": null,
        "time_zone": null,
        "ip_address": "::1",
        "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": "pm_moLKGxVh6Sg7wkJKS9bd",
    "payment_method_status": "active",
    "updated": "2024-07-04T09:48:15.420Z",
    "charges": null,
    "frm_metadata": null
}

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

@awasthi21 awasthi21 added the A-connector-integration Area: Connector integration label Jul 4, 2024
@awasthi21 awasthi21 self-assigned this Jul 4, 2024
@awasthi21 awasthi21 requested review from a team as code owners July 4, 2024 10:05
@awasthi21 awasthi21 requested review from akshay-97, SamraatBansal and AkshayaFoiger and removed request for akshay-97 July 4, 2024 10:06
Copy link
Member

Choose a reason for hiding this comment

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

Can you make the same changes in config/docker_compose.toml as well?

@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 5, 2024
Merged via the queue into main with commit 1904ffa Jul 5, 2024
19 checks passed
@likhinbopanna likhinbopanna deleted the 5679-add-subscriptioncards-for-braintree branch July 5, 2024 08:27
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants