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): [Novalnet] Add minimal customer data feature #6570

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cookieg13
Copy link
Contributor

@cookieg13 cookieg13 commented Nov 14, 2024

Type of Change

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

Description

Added minimal customer data feature. To use this the payments request body should have "no_nc": 1.
With this enabled, billing, customer_ip wont be needed in request body anymore
Details: https://developer.novalnet.com/onlinepayments/aboutminimalcustomerdata

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?

Tested locally for cards

/payments cURL

curl --location --request POST 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_uMzYVQ13nwcIGJPBPuAUYOoH7EpGhb48w3cYLMn1Y34u6fxzUqmACEhkWrK3SrSq' \ --data-raw '{ "amount": 10000, "currency": "EUR", "confirm": true, "payment_link": false, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "amount_to_capture": 10000, "customer_id": "StripeCustomer", "email": "[email protected]", "name": "John Doe", "phone": "999999999", "phone_country_code": "+1", "description": "Its my first payment request", "authentication_type": "three_ds", "return_url": "https://google.com", "payment_method": "card", "payment_method_type": "credit", "payment_method_data": { "card": { "card_number": "4000 0000 0000 1091", "card_exp_month": "12", "card_exp_year": "2025", "card_holder_name": "Max Mustermann", "card_cvc": "123" } }, "billing": { "email": "[email protected]" }, "browser_info": { "user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36", "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,\/;q=0.8", "language": "nl-NL", "color_depth": 24, "ip_address": "103.77.139.95", "screen_height": 723, "screen_width": 1536, "time_zone": 0, "java_enabled": true, "java_script_enabled": true }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" } }'

/payment response

{ "payment_id": "pay_SXHaUZKFxM1nMu6a0bvt", "merchant_id": "merchant_1731578904", "status": "requires_customer_action", "amount": 10000, "net_amount": 10000, "shipping_cost": null, "amount_capturable": 10000, "amount_received": null, "connector": "novalnet", "client_secret": "pay_SXHaUZKFxM1nMu6a0bvt_secret_WaOVo5M3DOfuO8Ny0Jek", "created": "2024-11-14T11:11:25.351Z", "currency": "EUR", "customer_id": "StripeCustomer", "customer": { "id": "StripeCustomer", "name": "John Doe", "email": "[email protected]", "phone": "999999999", "phone_country_code": "+1" }, "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": "card", "payment_method_data": { "card": { "last4": "1091", "card_type": null, "card_network": null, "card_issuer": null, "card_issuing_country": null, "card_isin": "400000", "card_extended_bin": null, "card_exp_month": "12", "card_exp_year": "2025", "card_holder_name": null, "payment_checks": null, "authentication_data": null }, "billing": null }, "payment_token": null, "shipping": null, "billing": { "address": null, "phone": null, "email": "[email protected]" }, "order_details": null, "email": "[email protected]", "name": "John Doe", "phone": "999999999", "return_url": "https://google.com/", "authentication_type": "three_ds", "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "next_action": { "type": "redirect_to_url", "redirect_to_url": "http://localhost:8080/payments/redirect/pay_SXHaUZKFxM1nMu6a0bvt/merchant_1731578904/pay_SXHaUZKFxM1nMu6a0bvt_1" }, "cancellation_reason": null, "error_code": null, "error_message": null, "unified_code": null, "unified_message": null, "payment_experience": null, "payment_method_type": "credit", "connector_label": null, "business_country": null, "business_label": "default", "business_sub_label": null, "allowed_payment_method_types": null, "ephemeral_key": { "customer_id": "StripeCustomer", "created_at": 1731582685, "expires": 1731586285, "secret": "epk_ad675fe4e7e24456bc5639df098a9085" }, "manual_retry_allowed": null, "connector_transaction_id": null, "frm_message": null, "metadata": { "udf1": "value1", "login_date": "2019-09-10T10:11:12Z", "new_customer": "true" }, "connector_metadata": null, "feature_metadata": null, "reference_id": null, "payment_link": null, "profile_id": "pro_E9P6mpTKHjYrjQ33lcs7", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_xiG3VZewShhbSQslXD60", "incremental_authorization_allowed": null, "authorization_count": null, "incremental_authorizations": null, "external_authentication_details": null, "external_3ds_authentication_attempted": false, "expires_on": "2024-11-14T11:26:25.351Z", "fingerprint": null, "browser_info": { "language": "nl-NL", "time_zone": 0, "ip_address": "103.77.139.95", "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36", "color_depth": 24, "java_enabled": true, "screen_width": 1536, "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8", "screen_height": 723, "java_script_enabled": true }, "payment_method_id": null, "payment_method_status": null, "updated": "2024-11-14T11:11:25.662Z", "charges": null, "frm_metadata": null, "merchant_order_reference_id": null, "order_tax_amount": null, "connector_mandate_id": null }

Screenshot 2024-11-14 at 16 43 17

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

@cookieg13 cookieg13 requested review from a team as code owners November 14, 2024 11:24
Copy link

semanticdiff-com bot commented Nov 14, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs  49% smaller
  crates/router/src/configs/defaults/payment_connector_required_fields.rs  0% smaller

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 14, 2024
@cookieg13 cookieg13 self-assigned this Nov 14, 2024
mobile: item.router_data.get_optional_billing_phone_number(),
billing,
customer_ip,
//for now mobile, billing, customer_ip is hardcoded to None since novalnet has limited merchant requirement, will be made dyanmic later
Copy link
Contributor Author

@cookieg13 cookieg13 Nov 14, 2024

Choose a reason for hiding this comment

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

Added minimal customer data feature. To use this the payments request body should have "no_nc": 1.
With this enabled, billing, customer_ip wont be needed in request body anymore

@cookieg13 cookieg13 force-pushed the minimalCustomerInfoNovalnet branch 2 times, most recently from 5d37750 to 7876be7 Compare November 15, 2024 09:36
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 15, 2024
@cookieg13 cookieg13 removed the request for review from a team November 15, 2024 09:55
Comment on lines 185 to 198
let billing = NovalnetPaymentsRequestBilling {
house_no: item.router_data.get_billing_line1()?,
street: item.router_data.get_billing_line2()?,
city: Secret::new(item.router_data.get_billing_city()?),
zip: item.router_data.get_billing_zip()?,
country_code: item.router_data.get_billing_country()?,
};

let customer_ip = item
.router_data
.request
.get_browser_info()?
.get_ip_address()?;

Copy link
Contributor

Choose a reason for hiding this comment

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

you don't have to remove them, you can make them as optional fields right?

city: Secret::new(item.router_data.get_billing_city()?),
zip: item.router_data.get_billing_zip()?,
country_code: item.router_data.get_billing_country()?,
house_no: item.router_data.get_billing_line1().ok(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
house_no: item.router_data.get_billing_line1().ok(),
house_no: item.router_data.get_optional_billing_line1(),

Can you use optional utils function in all other places ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants