hyperswitch
hyperswitch copied to clipboard
refactor(connector): [NMI] moved to hyperswitch_connectors
Type of Change
- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
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?
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
NMI test
Create payment processor
NOTE: used 3ds enabled key
{
"connector_type": "payment_processor",
"connector_name": "nmi",
"connector_account_details": {
"api_key":"********************",
"auth_type": "BodyKey",
"key1": "***********************"
},
"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": "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"
}
Create payment processor Response
{
"connector_type": "payment_processor",
"connector_name": "nmi",
"connector_label": "nmi_US_default",
"merchant_connector_id": "mca_sZo4dKynSU90CRdytdQT",
"profile_id": "pro_5wu4McY9AIOVmllRswYz",
"connector_account_details": {
"auth_type": "BodyKey",
"api_key": "***************************",
"key1": "********************************************"
},
"payment_methods_enabled": [
{
"payment_method": "card",
"payment_method_types": [
{
"payment_method_type": "credit",
"payment_experience": null,
"card_networks": [
"Visa",
"Mastercard"
],
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
},
{
"payment_method_type": "debit",
"payment_experience": null,
"card_networks": [
"Visa",
"Mastercard"
],
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
},
{
"payment_method": "pay_later",
"payment_method_types": [
{
"payment_method_type": "klarna",
"payment_experience": "redirect_to_url",
"card_networks": null,
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
},
{
"payment_method_type": "affirm",
"payment_experience": "redirect_to_url",
"card_networks": null,
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
},
{
"payment_method_type": "afterpay_clearpay",
"payment_experience": "redirect_to_url",
"card_networks": null,
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
}
],
"connector_webhook_details": {
"merchant_secret": "MyWebhookSecret",
"additional_secret": null
},
"metadata": {
"city": "NY",
"unit": "245"
},
"test_mode": false,
"disabled": false,
"frm_configs": null,
"business_country": "US",
"business_label": "default",
"business_sub_label": null,
"applepay_verified_domains": null,
"pm_auth_config": null,
"status": "active",
"additional_merchant_data": null,
"connector_wallets_details": null
}
create payment
{
"amount": 250,
"currency": "USD",
"confirm": true,
"amount_to_capture": 250,
"capture_method": "automatic",
"capture_on": "2022-09-10T10:11:12Z",
"customer_id": "nithin",
"email": "[email protected]",
"name": "John Doe",
"phone": "9731918444",
"phone_country_code": "+91",
"description": "Its my first payment request",
"authentication_type": "three_ds",
"return_url": "https://google.com",
"setup_future_usage": "on_session",
"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,
"screen_height": 723,
"screen_width": 1536,
"time_zone": 0,
"java_enabled": true,
"java_script_enabled": true,
"ip_address": "127.0.0.1"
},
"shipping": {
"address": {
"zip": "94122",
"country": "US",
"first_name": "John",
"last_name": "Doe"
}
},
"routing": {
"type": "single",
"data": "nmi"
},
"statement_descriptor_name": "joseph",
"statement_descriptor_suffix": "JS",
"metadata": {
"udf1": "value1",
"new_customer": "true",
"login_date": "2019-09-10T10:11:12Z"
},
"payment_method": "card",
"payment_method_type": "credit",
"payment_method_data": {
"card": {
"card_number": "4000000000002503",
"card_exp_month": "08",
"card_exp_year": "25",
"card_holder_name": "joseph Doe",
"card_cvc": "999"
}
},
"billing": {
"address": {
"zip": "560095",
"country": "IN",
"first_name": "Sakil",
"last_name": "Mostak"
}
}
}
create payment response
{
"payment_id": "pay_9hrmW9oFfnKedAy0P3Mn",
"merchant_id": "merchant_1743143179",
"status": "requires_customer_action",
"amount": 250,
"net_amount": 250,
"shipping_cost": null,
"amount_capturable": 250,
"amount_received": null,
"connector": "nmi",
"client_secret": "pay_9hrmW9oFfnKedAy0P3Mn_secret_gJqo6Tw0eee5XPrufvo1",
"created": "2025-03-28T10:29:46.830Z",
"currency": "USD",
"customer_id": "johndoe",
"customer": {
"id": "johndoe",
"name": "John Doe",
"email": "[email protected]",
"phone": "999999999",
"phone_country_code": "+91"
},
"description": "Its my first payment request",
"refunds": null,
"disputes": null,
"mandate_id": null,
"mandate_data": null,
"setup_future_usage": "on_session",
"off_session": null,
"capture_on": null,
"capture_method": "automatic",
"payment_method": "card",
"payment_method_data": {
"card": {
"last4": "2503",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "400000",
"card_extended_bin": null,
"card_exp_month": "08",
"card_exp_year": "25",
"card_holder_name": "joseph Doe",
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": "token_Qgf7HooZS0DBdeTuvyW2",
"shipping": {
"address": {
"city": null,
"country": "US",
"line1": null,
"line2": null,
"line3": null,
"zip": "94122",
"state": null,
"first_name": "John",
"last_name": "Doe"
},
"phone": null,
"email": null
},
"billing": {
"address": {
"city": null,
"country": "IN",
"line1": null,
"line2": null,
"line3": null,
"zip": "560095",
"state": null,
"first_name": "Sakil",
"last_name": "Mostak"
},
"phone": null,
"email": null
},
"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_9hrmW9oFfnKedAy0P3Mn/merchant_1743143179/pay_9hrmW9oFfnKedAy0P3Mn_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": "johndoe",
"created_at": 1743157786,
"expires": 1743161386,
"secret": "epk_46f549a6894b47b5bb741de8aa1381b5"
},
"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": "",
"payment_link": null,
"profile_id": "pro_5wu4McY9AIOVmllRswYz",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_sZo4dKynSU90CRdytdQT",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2025-03-28T10:44:46.830Z",
"fingerprint": null,
"browser_info": {
"language": "nl-NL",
"time_zone": 0,
"ip_address": "127.0.0.1",
"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": "2025-03-28T10:29:48.266Z",
"split_payments": null,
"frm_metadata": null,
"extended_authorization_applied": null,
"capture_before": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": null,
"card_discovery": "manual",
"issuer_error_code": null,
"issuer_error_message": null
}
Open redirect url "http://localhost:8080/payments/redirect/pay_9hrmW9oFfnKedAy0P3Mn/merchant_1743143179/pay_9hrmW9oFfnKedAy0P3Mn_1"
payment retrieve
NOTE use /payments/:id?force_sync=true
Response
{
"payment_id": "pay_9hrmW9oFfnKedAy0P3Mn",
"merchant_id": "merchant_1743143179",
"status": "succeeded",
"amount": 250,
"net_amount": 250,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": 250,
"connector": "nmi",
"client_secret": "pay_9hrmW9oFfnKedAy0P3Mn_secret_gJqo6Tw0eee5XPrufvo1",
"created": "2025-03-28T10:29:46.830Z",
"currency": "USD",
"customer_id": "johndoe",
"customer": {
"id": "johndoe",
"name": "John Doe",
"email": "[email protected]",
"phone": "999999999",
"phone_country_code": "+91"
},
"description": "Its my first payment request",
"refunds": null,
"disputes": null,
"mandate_id": null,
"mandate_data": null,
"setup_future_usage": "on_session",
"off_session": null,
"capture_on": null,
"capture_method": "automatic",
"payment_method": "card",
"payment_method_data": {
"card": {
"last4": "2503",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "400000",
"card_extended_bin": null,
"card_exp_month": "08",
"card_exp_year": "25",
"card_holder_name": "joseph Doe",
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": "token_Qgf7HooZS0DBdeTuvyW2",
"shipping": {
"address": {
"city": null,
"country": "US",
"line1": null,
"line2": null,
"line3": null,
"zip": "94122",
"state": null,
"first_name": "John",
"last_name": "Doe"
},
"phone": null,
"email": null
},
"billing": {
"address": {
"city": null,
"country": "IN",
"line1": null,
"line2": null,
"line3": null,
"zip": "560095",
"state": null,
"first_name": "Sakil",
"last_name": "Mostak"
},
"phone": null,
"email": null
},
"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": null,
"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": null,
"manual_retry_allowed": false,
"connector_transaction_id": "10550766500",
"frm_message": null,
"metadata": {
"udf1": "value1",
"login_date": "2019-09-10T10:11:12Z",
"new_customer": "true"
},
"connector_metadata": null,
"feature_metadata": null,
"reference_id": "pay_9hrmW9oFfnKedAy0P3Mn_1",
"payment_link": null,
"profile_id": "pro_5wu4McY9AIOVmllRswYz",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_sZo4dKynSU90CRdytdQT",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2025-03-28T10:44:46.830Z",
"fingerprint": null,
"browser_info": {
"language": "nl-NL",
"time_zone": 0,
"ip_address": "127.0.0.1",
"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": "2025-03-28T10:34:49.994Z",
"split_payments": null,
"frm_metadata": null,
"extended_authorization_applied": null,
"capture_before": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": null,
"card_discovery": "manual",
"issuer_error_code": null,
"issuer_error_message": null
}
refunds
"payment_id": "pay_9hrmW9oFfnKedAy0P3Mn",
"amount": 250,
"reason": "Customer returned product",
"refund_type": "instant",
"metadata": {
"udf1": "value1",
"new_customer": "true",
"login_date": "2019-09-10T10:11:12Z"
}
}
Response
{
"refund_id": "ref_rOGRIeo7mSWazFxB6TpF",
"payment_id": "pay_9hrmW9oFfnKedAy0P3Mn",
"amount": 250,
"currency": "USD",
"status": "pending",
"reason": "Customer returned product",
"metadata": {
"udf1": "value1",
"new_customer": "true",
"login_date": "2019-09-10T10:11:12Z"
},
"error_message": null,
"error_code": null,
"unified_code": null,
"unified_message": null,
"created_at": "2025-03-28T10:36:26.792Z",
"updated_at": "2025-03-28T10:36:29.898Z",
"connector": "nmi",
"profile_id": "pro_5wu4McY9AIOVmllRswYz",
"merchant_connector_id": "mca_sZo4dKynSU90CRdytdQT",
"split_refunds": null,
"issuer_error_code": null,
"issuer_error_message": null
}
## refund retrieve
response
```json
{
"refund_id": "ref_rOGRIeo7mSWazFxB6TpF",
"payment_id": "pay_9hrmW9oFfnKedAy0P3Mn",
"amount": 250,
"currency": "USD",
"status": "succeeded",
"reason": "Customer returned product",
"metadata": {
"udf1": "value1",
"new_customer": "true",
"login_date": "2019-09-10T10:11:12Z"
},
"error_message": null,
"error_code": null,
"unified_code": null,
"unified_message": null,
"created_at": "2025-03-28T10:36:26.792Z",
"updated_at": "2025-03-28T10:36:54.546Z",
"connector": "nmi",
"profile_id": "pro_5wu4McY9AIOVmllRswYz",
"merchant_connector_id": "mca_sZo4dKynSU90CRdytdQT",
"split_refunds": null,
"issuer_error_code": null,
"issuer_error_message": null
}