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(connector): add amount conversion framework for noon #4843

Merged
merged 111 commits into from
Jun 19, 2024

Conversation

sahkal
Copy link
Contributor

@sahkal sahkal commented May 31, 2024

Type of Change

  • Refactoring

Description

This PR adds amount conversion framework to noon.

Note: Noon works in major unit String

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?

  • Authorise
  • Capture
  • Refund
  • Mandate

Authorise

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tIw3n0VwEYFqVRohXQ4VGtEzzSdODm2emaiVyT5UlijQeEL9uICp9xseYuoDmi21' \
--data-raw '{
    "amount": 65401,
    "currency": "AED",
    "confirm": true,
    "customer_id": "StripeCustomer",
    "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://duck.com",
    "payment_method": "card",
    "payment_method_type":"credit",
    "payment_method_data": {
        "card": {
            "card_number": "4456530000001096",
            "card_exp_month": "04",
            "card_exp_year": "2026",
            "card_holder_name": "joseph Doe",
            "card_cvc": "323"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "AE",
            "first_name": "sundari"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "AE",
            "first_name": "sundari"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "connector_metadata":{
        "noon":{
            "order_category": "pay"
        }
    }
}
'
Screenshot 2024-06-05 at 4 53 08 PM

Setup Mandate

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tIw3n0VwEYFqVRohXQ4VGtEzzSdODm2emaiVyT5UlijQeEL9uICp9xseYuoDmi21' \
--data-raw '{
    "amount": 65401,
    "currency": "AED",
    "confirm": true,
    "setup_future_usage":"off_session",
    "customer_acceptance": {
    "acceptance_type": "offline",
    "accepted_at": "1963-05-03T04:07:52.723Z",
    "online": {
      "ip_address": "127.0.0.1",
      "user_agent": "amet irure esse"
    }
  },
  "mandate_data": {
    "customer_acceptance": {
      "acceptance_type": "offline",
      "accepted_at": "1963-05-03T04:07:52.723Z",
      "online": {
        "ip_address": "127.0.0.1",
        "user_agent": "amet irure esse"
      }
    },
    "mandate_type": {
      "multi_use": {
        "amount": 65401,
        "currency": "AED"
      }
    }
  },
    "customer_id": "StripeCustomer",
    "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://duck.com",
    "payment_method": "card",
    "payment_method_type":"credit",
    "payment_method_data": {
        "card": {
            "card_number": "4456530000001096",
            "card_exp_month": "04",
            "card_exp_year": "2026",
            "card_holder_name": "joseph Doe",
            "card_cvc": "323"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "AE",
            "first_name": "sundari"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "AE",
            "first_name": "sundari"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }, 
    "connector_metadata":{
        "noon":{
            "order_category": "pay"
        }
    }
}
'
Screenshot 2024-06-05 at 5 00 49 PM

Recurring mandate

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tIw3n0VwEYFqVRohXQ4VGtEzzSdODm2emaiVyT5UlijQeEL9uICp9xseYuoDmi21' \
--data '{
    "amount": 65401,
    "currency": "AED",
    "confirm": true,
    "mandate_id":"man_UTzZbRSvS2hNqDJJmgcR",
    "off_session":true,
    "customer_id": "StripeCustomer",
    "description": "Its my first payment request",
    "connector_metadata":{
        "noon":{
            "order_category": "pay"
        }
    }
}
'
Screenshot 2024-06-05 at 5 05 00 PM

Refund

curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tIw3n0VwEYFqVRohXQ4VGtEzzSdODm2emaiVyT5UlijQeEL9uICp9xseYuoDmi21' \
--data '{
    "payment_id": "pay_ssJUsZhSeC5p6bT1KCq5",
    "amount": 65401,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
Screenshot 2024-06-05 at 5 08 55 PM

Manual Capture

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tIw3n0VwEYFqVRohXQ4VGtEzzSdODm2emaiVyT5UlijQeEL9uICp9xseYuoDmi21' \
--data-raw '{
    "amount": 65401,
    "currency": "AED",
    "confirm": true,
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 65401,
    "customer_id": "StripeCustomer",
    "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://duck.com",
    "payment_method": "card",
    "payment_method_type":"credit",
    "payment_method_data": {
        "card": {
            "card_number": "4456530000001096",
            "card_exp_month": "04",
            "card_exp_year": "2026",
            "card_holder_name": "joseph Doe",
            "card_cvc": "323"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "AE",
            "first_name": "sundari"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "AE",
            "first_name": "sundari"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "routing": {
        "type": "single",
        "data": "stripe"
    },
    "connector_metadata":{
        "noon":{
            "order_category": "pay"
        }
    }
}
'
Screenshot 2024-06-05 at 5 12 41 PM

Capture Call

curl --location 'http://localhost:8080/payments/pay_xeMQcPNY2E8jbfpDbgJh/capture' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tIw3n0VwEYFqVRohXQ4VGtEzzSdODm2emaiVyT5UlijQeEL9uICp9xseYuoDmi21' \
--data '{
  "amount_to_capture": 65401
}'
Screenshot 2024-06-05 at 5 14 31 PM

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

sahkal and others added 30 commits May 13, 2024 16:50
@sahkal sahkal requested a review from SamraatBansal June 5, 2024 11:03
@sahkal sahkal added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed high-risk labels Jun 5, 2024
@sahkal sahkal requested a review from AkshayaFoiger June 7, 2024 06:23
Base automatically changed from 5178-amount-conversion-do-amount-conversion-for-bluesnap to main June 12, 2024 07:25
@sahkal sahkal requested a review from a team as a code owner June 12, 2024 07:25
…2-amount-conversion-do-amount-conversion-for-noon
@sahkal sahkal added the A-core Area: Core flows label Jun 12, 2024
@sahkal sahkal requested a review from SamraatBansal June 13, 2024 16:54
crates/router/src/connector/noon.rs Outdated Show resolved Hide resolved
crates/router/src/connector/noon.rs Outdated Show resolved Hide resolved
@sahkal sahkal requested a review from SamraatBansal June 17, 2024 15:44
@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 19, 2024
Merged via the queue into main with commit 8c7e1a3 Jun 19, 2024
11 checks passed
@likhinbopanna likhinbopanna deleted the 5182-amount-conversion-do-amount-conversion-for-noon branch June 19, 2024 10:51
pixincreate added a commit that referenced this pull request Jun 20, 2024
…ress-skip

* 'main' of github.com:juspay/hyperswitch: (27 commits)
  feat(cypress): add 2 more payout connectors and bank transfer support for payout (#4993)
  chore(version): 2024.06.20.0
  Refactor(core): reverts the payment method list filtering using constraint graph (#5044)
  feat(router): add payment method type duplication check for `google_pay` (#5023)
  refactor(storage): remove `id` from payment intent, attempt and remove datamodel ext from payment intent (#4923)
  fix(events): Correct parsing of API events with user event_type for Clickhouse (#5022)
  fix(connector):  add local bank redirect type in compatibility layer, default the country to AT for Local Bank Redirect and add creds_identifier in access token  (#5038)
  refactor(connector): add amount conversion framework for noon (#4843)
  fix(logging): fix stack overflow on recording restricted keys (#4423)
  feat(core): Add logger for sessions call failure (#5036)
  chore(version): 2024.06.19.0
  fix(opensearch): handle index not present errors in search api (#4965)
  feat(multitenancy): add tenant_id as a field for data pipeline and support individual database for clickhouse  (#4867)
  refactor: add basic counter metrics for IMC (#5006)
  fix(payment_methods): populate card fields while saving card again during metadata change condition (#5019)
  feat(router): Override the `setup_future_usage` to `on_session` based on the merchant config (#5016)
  chore(docker-compose): pass correct configuration values for running SDK demo app  (#5012)
  refactor: Move trait ConnectorIntegration to crate hyperswitch_interfaces (#4946)
  chore(version): 2024.06.17.0
  chore(process_tracker): use `const` instead of `String` for `business_status` (#4849)
  ...
@SanchithHegde SanchithHegde removed S-waiting-on-review Status: This PR has been implemented and needs to be reviewed high-risk labels Jun 23, 2024
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 A-core Area: Core flows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants