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(pm_auth): pm_auth service migration #3047

Merged
merged 14 commits into from
Dec 6, 2023
Merged

feat(pm_auth): pm_auth service migration #3047

merged 14 commits into from
Dec 6, 2023

Conversation

Chethan-rao
Copy link
Contributor

@Chethan-rao Chethan-rao commented Dec 4, 2023

Type of Change

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

Description

PM Auth service migration

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 merchant account -
curl --location --request POST 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
  "merchant_id": "merchant_1701764398",
  "locker_id": "m0010",
  "merchant_name": "Sarthak",
  "merchant_details": {
    "primary_contact_person": "John Test",
    "primary_email": "JohnTest@test.com",
    "primary_phone": "sunt laborum",
    "secondary_contact_person": "John Test2",
    "secondary_email": "JohnTest2@test.com",
    "secondary_phone": "cillum do dolor id",
    "website": "www.example.com",
    "about_business": "Online Retail with a wide selection of organic products for North America",
    "address": {
      "line1": "1467",
      "line2": "Harrison Street",
      "line3": "Harrison Street",
      "city": "San Fransico",
      "state": "California",
      "zip": "94122",
      "country": "US"
    }
  },
  "return_url": "https://google.com/success",
  "webhook_details": {
     "webhook_username": "ekart_retail",
    "webhook_password": "password_ekart@123",
    "payment_created_enabled": true,
    "payment_succeeded_enabled": true,
    "payment_failed_enabled": true
  },
  "sub_merchants_enabled": false,
  "metadata": {
    "city": "NY",
    "unit": "245"
  },
  "primary_business_details": [
    {
      "country": "US",
      "business": "default"
    }
  ]
}'
  1. Create API key
  2. Create Plaid Connector account
curl --location --request POST 'http://localhost:8080/account/merchant_1701763754/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
  "connector_type": "payment_method_auth",
  "connector_name": "plaid",
  "connector_account_details": {
    "auth_type": "BodyKey",
    "api_key": "some key",
    "key1": "some key"
  },
  "test_mode": false,
  "disabled": false,
  "business_country": "US",
  "business_label":"default",
  "status": "active",
  "metadata": {
    "city": "NY",
    "unit": "245"
  }
}'
  1. Create payment connector account -
curl --location --request POST 'http://localhost:8080/account/merchant_1701763754/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "connector_name": "stripe",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": "some key"
    },
    "test_mode": false,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "minimum_amount": 0,
                    "maximum_amount": 10000
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "payment_method_type": "klarna",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "affirm",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "afterpay_clearpay",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "connector_webhook_details": {
        "merchant_secret": "MyWebhookSecret"
    },
    "business_country": "US",
    "business_label": "default",
    "pm_auth_config": {
        "enabled_payment_methods": [
           {
                "payment_method": "bank_debit",
                "payment_method_type": "ach",
                "connector_name": "plaid",
                "mca_id": "mca_F6MPzhuQvzhHhOsVdgxi"
            }
        ]
    }
}'
  1. Payments create -
curl --location --request POST 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_O08Uv8O5PjAfrxsSLuduC1bn3FTWEpk0N2vvAKnvhAfc7jISAnrNgkTtcbibjO00' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "business_country": "US",
    "business_label": "default",
    "email": "guest@example.com",
    "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",
    "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": "8056594430",
            "country_code": "+91"
        }
    },
    "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"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
  1. List PM for merchant -
curl --location --request GET 'http://localhost:8080/account/payment_methods?client_secret=pay_57JSBXgwKCHdgIyvLXDi_secret_1arVvWIGuP7XlWPMrt8W' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_588a676d99f8470ca0eb3a6d5b955f2a' \
--data-raw ''
  1. Link token API -
curl --location --request POST 'http://localhost:8080/payment_methods/auth/link' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_588a676d99f8470ca0eb3a6d5b955f2a' \
--data-raw '{
    "client_secret": "pay_57JSBXgwKCHdgIyvLXDi_secret_1arVvWIGuP7XlWPMrt8W",
    "payment_id": "pay_57JSBXgwKCHdgIyvLXDi",
    "payment_method": "bank_debit",
    "payment_method_type": "ach"
}'
  1. Get public token from plaid -
curl --location --request POST 'https://sandbox.plaid.com/sandbox/public_token/create' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_O08Uv8O5PjAfrxsSLuduC1bn3FTWEpk0N2vvAKnvhAfc7jISAnrNgkTtcbibjO00' \
--data-raw '{
    "client_id": "some key",
    "secret": "some key",
    "institution_id": "ins_20",
    "initial_products": [
        "auth"
    ],
    "options": {
        "webhook": "https://www.genericwebhookurl.com/webhook"
    }
}'
  1. Exchange token API -
curl --location --request POST 'http://localhost:8080/payment_methods/auth/exchange' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_588a676d99f8470ca0eb3a6d5b955f2a' \
--data-raw '{
    "client_secret": "pay_57JSBXgwKCHdgIyvLXDi_secret_1arVvWIGuP7XlWPMrt8W",
    "public_token": "public-sandbox-19e07c9f-8b96-4e96-81a1-e3e3d5c70dc6",
    "payment_id": "pay_57JSBXgwKCHdgIyvLXDi",
    "payment_method": "bank_debit",
    "payment_method_type": "ach"
}'
  1. Pm list for customer (take any payment token) -
curl --location --request GET 'http://localhost:8080/customers/StripeCustomer/payment_methods' \
--header 'Accept: application/json' \
--header 'api-key: dev_O08Uv8O5PjAfrxsSLuduC1bn3FTWEpk0N2vvAKnvhAfc7jISAnrNgkTtcbibjO00'
  1. Payments confirm with payment_token -
curl --location --request POST 'http://localhost:8080/payments/pay_57JSBXgwKCHdgIyvLXDi/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_O08Uv8O5PjAfrxsSLuduC1bn3FTWEpk0N2vvAKnvhAfc7jISAnrNgkTtcbibjO00' \
--data-raw '{
    "payment_method": "bank_debit",
    "payment_method_type": "ach",
    "payment_token": "token_2OqGjTK08Gen3iTEJq6u"
}'

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 requested review from a team as code owners December 4, 2023 10:10
@Sarthak1799 Sarthak1799 linked an issue Dec 4, 2023 that may be closed by this pull request
2 tasks
@Chethan-rao Chethan-rao requested a review from a team as a code owner December 4, 2023 10:36
@Chethan-rao Chethan-rao marked this pull request as draft December 4, 2023 10:38
@Chethan-rao Chethan-rao marked this pull request as ready for review December 5, 2023 08:02
@Sarthak1799 Sarthak1799 requested a review from vspecky December 5, 2023 08:40
crates/router/src/core/admin.rs Outdated Show resolved Hide resolved
@Chethan-rao Chethan-rao requested a review from vspecky December 5, 2023 10:14
@Chethan-rao Chethan-rao added A-core Area: Core flows S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-payment-methods Area: Payment Methods C-feature Category: Feature request or enhancement labels Dec 5, 2023
@Chethan-rao Chethan-rao added this to the November 2023 Release milestone Dec 5, 2023
vspecky
vspecky previously approved these changes Dec 5, 2023
vspecky
vspecky previously approved these changes Dec 5, 2023
Sarthak1799
Sarthak1799 previously approved these changes Dec 5, 2023
@pixincreate pixincreate added the S-needs-conflict-resolution Status: This PR needs conflicts to be resolved by the author label Dec 5, 2023
@Chethan-rao Chethan-rao dismissed stale reviews from Sarthak1799 and vspecky via 88e7d3e December 5, 2023 18:49
@Chethan-rao Chethan-rao requested a review from a team as a code owner December 5, 2023 18:49
@vspecky vspecky requested a review from a team December 6, 2023 07:50
@Sarthak1799 Sarthak1799 removed the S-needs-conflict-resolution Status: This PR needs conflicts to be resolved by the author label Dec 6, 2023
@pixincreate pixincreate enabled auto-merge December 6, 2023 13:15
@pixincreate pixincreate added this pull request to the merge queue Dec 6, 2023
Merged via the queue into main with commit 9c1c44a Dec 6, 2023
10 of 12 checks passed
@pixincreate pixincreate deleted the migrate-plaid branch December 6, 2023 15:32
@pixincreate pixincreate removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows A-payment-methods Area: Payment Methods C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

[FEATURE] Migrate PaymentMethodAuth to OSS
6 participants