Skip to content

Conversation

Chethan-rao
Copy link
Contributor

@Chethan-rao Chethan-rao commented Mar 13, 2024

Type of Change

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

Description

This PR enables country, currency filter for cards in list payment methods for merchants

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?

Payment Method List needs to be verified for USD and Non-USD payments via BOA:

  1. Payments Request(with confirm false):
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY_HERE' \
--data-raw '{
    "amount": 1404,
    "currency": "INR",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "CustomerX",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "billing": {
        "address": {
            "line1": "eqnkl",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "תל אביב",
            "state": "California",
            "zip": "46282",
            "country": "US",
            "first_name": "joseph",
            "last_name": "ewcjwd"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+97"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "business_label": "food",
    "business_country": "US"
}'

Payments Response:

{
    "payment_id": "pay_3ftTdmvei4RVQamsfyfJ",
    "merchant_id": "merchant_1706697715",
    "status": "requires_payment_method",
    "amount": 1404,
    "net_amount": 1404,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_3ftTdmvei4RVQamsfyfJ_secret_SM3IbzER2kXk3jmHe1s2",
    "created": "2024-03-13T07:26:39.814Z",
    "currency": "INR",
    "customer_id": "CustomerX",
    "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": "תל אביב",
            "country": "US",
            "line1": "eqnkl",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "46282",
            "state": "California",
            "first_name": "joseph",
            "last_name": "ewcjwd"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+97"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "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": "US",
    "business_label": "food",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "CustomerX",
        "created_at": 1710314799,
        "expires": 1710318399,
        "secret": "epk_35a516b093434ef6a7bff36ae0efd437"
    },
    "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_j9PVFpZYzQU1j7yyjkJJ",
    "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-03-13T07:41:39.813Z",
    "fingerprint": null,
    "payment_method_id": null,
    "payment_method_status": null
}
  1. Payment Methods List Request:
`curl --location 'http://localhost:8080/account/payment_methods?client_secret=CLIENT_SECRET_HERE' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY_HERE'`

Payment Methods List Response:

  • For Non-USD Currencies:
{
    "redirect_url": "https://google.com/success",
    "currency": "INR",
    "payment_methods": [],
    "mandate_payment": null,
    "merchant_name": "NewAge Retailer",
    "show_surcharge_breakup_screen": false,
    "payment_type": "normal"
}
  • For USD:
{
    "redirect_url": "https://google.com/success",
    "currency": "USD",
    "payment_methods": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "google_pay",
                    "payment_experience": [
                        {
                            "payment_experience_type": "redirect_to_url",
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        }
                    ],
                    "card_networks": null,
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.last_name": {
                            "required_field": "billing.address.last_name",
                            "display_name": "billing_last_name",
                            "field_type": "user_billing_name",
                            "value": "ewcjwd"
                        },
                        "billing.address.country": {
                            "required_field": "billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_address_country": {
                                    "options": [
                                        "ALL"
                                    ]
                                }
                            },
                            "value": "US"
                        },
                        "billing.address.city": {
                            "required_field": "billing.address.city",
                            "display_name": "city",
                            "field_type": "user_address_city",
                            "value": "תל אביב"
                        },
                        "email": {
                            "required_field": "email",
                            "display_name": "email",
                            "field_type": "user_email_address",
                            "value": "[email protected]"
                        },
                        "billing.address.line1": {
                            "required_field": "billing.address.line1",
                            "display_name": "line1",
                            "field_type": "user_address_line1",
                            "value": "eqnkl"
                        },
                        "billing.address.first_name": {
                            "required_field": "billing.address.first_name",
                            "display_name": "billing_first_name",
                            "field_type": "user_billing_name",
                            "value": "joseph"
                        },
                        "billing.address.zip": {
                            "required_field": "billing.address.zip",
                            "display_name": "zip",
                            "field_type": "user_address_pincode",
                            "value": "46282"
                        },
                        "billing.address.state": {
                            "required_field": "billing.address.state",
                            "display_name": "state",
                            "field_type": "user_address_state",
                            "value": "California"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                },
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": [
                        {
                            "payment_experience_type": "invoke_sdk_client",
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        }
                    ],
                    "card_networks": null,
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.country": {
                            "required_field": "billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_address_country": {
                                    "options": [
                                        "ALL"
                                    ]
                                }
                            },
                            "value": "US"
                        },
                        "billing.address.first_name": {
                            "required_field": "billing.address.first_name",
                            "display_name": "billing_first_name",
                            "field_type": "user_billing_name",
                            "value": "joseph"
                        },
                        "billing.address.state": {
                            "required_field": "billing.address.state",
                            "display_name": "state",
                            "field_type": "user_address_state",
                            "value": "California"
                        },
                        "billing.address.last_name": {
                            "required_field": "billing.address.last_name",
                            "display_name": "billing_last_name",
                            "field_type": "user_billing_name",
                            "value": "ewcjwd"
                        },
                        "email": {
                            "required_field": "email",
                            "display_name": "email",
                            "field_type": "user_email_address",
                            "value": "[email protected]"
                        },
                        "billing.address.city": {
                            "required_field": "billing.address.city",
                            "display_name": "city",
                            "field_type": "user_address_city",
                            "value": "תל אביב"
                        },
                        "billing.address.line1": {
                            "required_field": "billing.address.line1",
                            "display_name": "line1",
                            "field_type": "user_address_line1",
                            "value": "eqnkl"
                        },
                        "billing.address.zip": {
                            "required_field": "billing.address.zip",
                            "display_name": "zip",
                            "field_type": "user_address_pincode",
                            "value": "46282"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                }
            ]
        },
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "debit",
                    "payment_experience": null,
                    "card_networks": [
                        {
                            "card_network": "Discover",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        },
                        {
                            "card_network": "Mastercard",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        },
                        {
                            "card_network": "Visa",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        },
                        {
                            "card_network": "JCB",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        }
                    ],
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.line1": {
                            "required_field": "billing.address.line1",
                            "display_name": "line1",
                            "field_type": "user_address_line1",
                            "value": "eqnkl"
                        },
                        "billing.address.country": {
                            "required_field": "billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_address_country": {
                                    "options": [
                                        "ALL"
                                    ]
                                }
                            },
                            "value": "US"
                        },
                        "payment_method_data.card.card_exp_month": {
                            "required_field": "payment_method_data.card.card_exp_month",
                            "display_name": "card_exp_month",
                            "field_type": "user_card_expiry_month",
                            "value": null
                        },
                        "billing.address.state": {
                            "required_field": "billing.address.state",
                            "display_name": "state",
                            "field_type": "user_address_state",
                            "value": "California"
                        },
                        "billing.address.zip": {
                            "required_field": "billing.address.zip",
                            "display_name": "zip",
                            "field_type": "user_address_pincode",
                            "value": "46282"
                        },
                        "payment_method_data.card.card_cvc": {
                            "required_field": "payment_method_data.card.card_cvc",
                            "display_name": "card_cvc",
                            "field_type": "user_card_cvc",
                            "value": null
                        },
                        "billing.address.first_name": {
                            "required_field": "billing.address.first_name",
                            "display_name": "billing_first_name",
                            "field_type": "user_billing_name",
                            "value": "joseph"
                        },
                        "payment_method_data.card.card_exp_year": {
                            "required_field": "payment_method_data.card.card_exp_year",
                            "display_name": "card_exp_year",
                            "field_type": "user_card_expiry_year",
                            "value": null
                        },
                        "email": {
                            "required_field": "email",
                            "display_name": "email",
                            "field_type": "user_email_address",
                            "value": "[email protected]"
                        },
                        "billing.address.city": {
                            "required_field": "billing.address.city",
                            "display_name": "city",
                            "field_type": "user_address_city",
                            "value": "תל אביב"
                        },
                        "payment_method_data.card.card_number": {
                            "required_field": "payment_method_data.card.card_number",
                            "display_name": "card_number",
                            "field_type": "user_card_number",
                            "value": null
                        },
                        "billing.address.last_name": {
                            "required_field": "billing.address.last_name",
                            "display_name": "billing_last_name",
                            "field_type": "user_billing_name",
                            "value": "ewcjwd"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                },
                {
                    "payment_method_type": "credit",
                    "payment_experience": null,
                    "card_networks": [
                        {
                            "card_network": "Visa",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        },
                        {
                            "card_network": "Mastercard",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        },
                        {
                            "card_network": "JCB",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        },
                        {
                            "card_network": "Discover",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "bankofamerica"
                            ]
                        }
                    ],
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "payment_method_data.card.card_cvc": {
                            "required_field": "payment_method_data.card.card_cvc",
                            "display_name": "card_cvc",
                            "field_type": "user_card_cvc",
                            "value": null
                        },
                        "billing.address.state": {
                            "required_field": "billing.address.state",
                            "display_name": "state",
                            "field_type": "user_address_state",
                            "value": "California"
                        },
                        "billing.address.country": {
                            "required_field": "billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_address_country": {
                                    "options": [
                                        "ALL"
                                    ]
                                }
                            },
                            "value": "US"
                        },
                        "payment_method_data.card.card_number": {
                            "required_field": "payment_method_data.card.card_number",
                            "display_name": "card_number",
                            "field_type": "user_card_number",
                            "value": null
                        },
                        "billing.address.city": {
                            "required_field": "billing.address.city",
                            "display_name": "city",
                            "field_type": "user_address_city",
                            "value": "תל אביב"
                        },
                        "payment_method_data.card.card_exp_month": {
                            "required_field": "payment_method_data.card.card_exp_month",
                            "display_name": "card_exp_month",
                            "field_type": "user_card_expiry_month",
                            "value": null
                        },
                        "billing.address.last_name": {
                            "required_field": "billing.address.last_name",
                            "display_name": "billing_last_name",
                            "field_type": "user_billing_name",
                            "value": "ewcjwd"
                        },
                        "payment_method_data.card.card_exp_year": {
                            "required_field": "payment_method_data.card.card_exp_year",
                            "display_name": "card_exp_year",
                            "field_type": "user_card_expiry_year",
                            "value": null
                        },
                        "billing.address.zip": {
                            "required_field": "billing.address.zip",
                            "display_name": "zip",
                            "field_type": "user_address_pincode",
                            "value": "46282"
                        },
                        "billing.address.line1": {
                            "required_field": "billing.address.line1",
                            "display_name": "line1",
                            "field_type": "user_address_line1",
                            "value": "eqnkl"
                        },
                        "billing.address.first_name": {
                            "required_field": "billing.address.first_name",
                            "display_name": "billing_first_name",
                            "field_type": "user_billing_name",
                            "value": "joseph"
                        },
                        "email": {
                            "required_field": "email",
                            "display_name": "email",
                            "field_type": "user_email_address",
                            "value": "[email protected]"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                }
            ]
        }
    ],
    "mandate_payment": null,
    "merchant_name": "NewAge Retailer",
    "show_surcharge_breakup_screen": false,
    "payment_type": "normal"
}

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

@Chethan-rao Chethan-rao added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-payment-methods Area: Payment Methods C-refactor Category: Refactor labels Mar 13, 2024
@Chethan-rao Chethan-rao added this to the March 2024 milestone Mar 13, 2024
@Chethan-rao Chethan-rao self-assigned this Mar 13, 2024
@Chethan-rao Chethan-rao requested a review from a team as a code owner March 13, 2024 07:23
@Chethan-rao Chethan-rao linked an issue Mar 13, 2024 that may be closed by this pull request
2 tasks
@pixincreate pixincreate added this pull request to the merge queue Mar 14, 2024
@pixincreate pixincreate removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Mar 14, 2024
Merged via the queue into main with commit 9ae10dc Mar 14, 2024
@pixincreate pixincreate deleted the pm-config-for-cards branch March 14, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payment-methods Area: Payment Methods C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REFACTOR] Enable country currency filter for cards
4 participants