Skip to content

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
@awasthi21 awasthi21 requested a review from SamraatBansal July 4, 2024 12:16
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
@likhinbopanna likhinbopanna deleted the 5679-add-subscriptioncards-for-braintree branch July 5, 2024 08:27
pixincreate added a commit that referenced this pull request Jul 8, 2024
…ify-cypress

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.07.08.0
  fix(connector): [adyen] remove browser info for mit and [paypal] add refund key in headers (#5225)
  chore(version): 2024.07.06.0
  feat(router): Pass the shipping email whenever the billing details are included in the session token response (#5228)
  fix(cypress): fix metadata missing while creating connector if not in auth (#5215)
  refactor: fix unit and documentation tests (#4754)
  feat(events): add hashed customer_email and feature_metadata (#5220)
  feat(events): Add payment metadata to hyperswitch-payment-intent-events (#5170)
  fix(analytics): using HashSet to represent the returned metrics (#5179)
  feat(core): billing_details inclusion in Payment Intent (#5090)
  feat(router): pass fields to indicate if the customer address details to be connector from wallets (#5210)
  fix(refunds): Add aliases on refund status for backwards compatibility (#5216)
  Feat(connector): [BRAINTREE] Implement Card Mandates (#5204)
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.

5 participants