hyperswitch
hyperswitch copied to clipboard
feat(pm_list): add dynamic fields for local bank transfer
Type of Change
- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Test Case
- Create a merchant
curl --location 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: "" ' \
--data-raw '{
"merchant_id": "merchant_1712920458",
"merchant_name": "NewAge Retailer",
"return_url": "https://chrome.google.com/",
"enable_payment_response_hash": false,
"payment_response_hash_key": null,
"redirect_to_merchant_with_http_post": false,
"merchant_details": {
"primary_contact_person": "joseph Test",
"primary_phone": "veniam aute officia ullamco esse",
"primary_email": "[email protected]",
"secondary_contact_person": "joseph Test2",
"secondary_phone": "proident adipisicing officia nulla",
"secondary_email": "[email protected]",
"website": "https://www.example.com",
"about_business": "Online Retail with a wide selection of organic products for North America",
"address": {
"city": "San Fransico",
"country": null,
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"zip": "94122",
"state": "California",
"first_name": null,
"last_name": null
}
},
"webhook_details": {
"webhook_version": "1.0.1",
"webhook_username": "ekart_retail",
"webhook_password": "password_ekart@123",
"webhook_url": "https://webhook.site/f456e002-24c1-4e40-99ec-e0ec147fbde4",
"payment_created_enabled": true,
"payment_succeeded_enabled": true,
"payment_failed_enabled": true
},
"payout_routing_algorithm": null,
"sub_merchants_enabled": false,
"parent_merchant_id": null,
"publishable_key": "pk_snd_3b33cd9404234113804aa1accaabe22f",
"metadata": {
"city": "NY",
"unit": "245"
},
"locker_id": "m0010",
"primary_business_details": [
{
"country": "CN",
"business": "default"
}
],
"organization_id": null
}'
- Create a ZSL MCA
curl --location 'http://localhost:8080/account/merchant_1712918904/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ""' \
--data '{
"connector_type": "fiz_operations",
"connector_name": "zsl",
"connector_account_details": {
"auth_type": "BodyKey",
"api_key": "",
"key1": ""
},
"test_mode": false,
"disabled": false,
"payment_methods_enabled": [
{
"payment_method": "bank_transfer",
"payment_method_types": [
{
"payment_method_type": "local_bank_transfer",
"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
}
]
}
],
"metadata": {
"city": "NY",
"unit": "245",
"account_name": "transaction_processing"
},
"business_country": "CN",
"business_label": "default",
"business_sub_label": null,
"frm_configs": null,
"connector_webhook_details": {
"merchant_secret": ""
}
}'
- Create a payment with confirm false
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ""' \
--data-raw '{
"amount": 120,
"currency": "CNY",
"confirm": false,
"capture_method": "automatic",
"capture_on": "2022-09-10T10:11:12Z",
"customer_id": "111111234567890",
"email": "[email protected]",
"name": "John Doe",
"phone": "999999999",
"phone_country_code": "+65",
"description": "Its my first payment request",
"authentication_type": "three_ds",
"return_url": "https://google.com",
"billing": {
"address": {
"country": "CN"
}
},
"browser_info": {
"language": "en"
},
"statement_descriptor_name": "joseph",
"statement_descriptor_suffix": "JS",
"payment_method": "bank_transfer",
"payment_method_type": "local_bank_transfer",
"payment_method_data": {
"bank_transfer": {
"local_bank_transfer": {}
}
}
}'
Response
{
"payment_id": "pay_1inpFkvKTZOGSg31ufzK",
"merchant_id": "merchant_1712918904",
"status": "requires_confirmation",
"amount": 120,
"net_amount": 120,
"amount_capturable": 0,
"amount_received": null,
"connector": null,
"client_secret": "pay_1inpFkvKTZOGSg31ufzK_secret_kIkL4HpWR1wwr7DIMVtY",
"created": "2024-04-12T10:55:04.227Z",
"currency": "CNY",
"customer_id": "111111234567890",
"customer": {
"id": "111111234567890",
"name": "John Doe",
"email": "[email protected]",
"phone": "999999999",
"phone_country_code": "+65"
},
"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": "bank_transfer",
"payment_method_data": {
"bank_transfer": {},
"billing": null
},
"payment_token": "token_TyUJSNilbY7FG1paBcJB",
"shipping": null,
"billing": {
"address": {
"city": null,
"country": "CN",
"line1": null,
"line2": null,
"line3": null,
"zip": null,
"state": null,
"first_name": null,
"last_name": null
},
"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": "local_bank_transfer",
"connector_label": null,
"business_country": null,
"business_label": "default",
"business_sub_label": null,
"allowed_payment_method_types": null,
"ephemeral_key": {
"customer_id": "111111234567890",
"created_at": 1712919304,
"expires": 1712922904,
"secret": "epk_4997f299ee614df8ac99edd4d6919a50"
},
"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_NflIGu4GsRMDUMc3NTXJ",
"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-04-12T11:10:04.227Z",
"fingerprint": null,
"browser_info": {
"language": "en"
},
"payment_method_id": null,
"payment_method_status": null,
"updated": "2024-04-12T10:55:04.265Z"
}
- List Payments
curl --location 'http://localhost:8080/account/payment_methods?client_secret={{client_secret}}' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:{{publishable_key}}' \
--data ''
Response
{
"redirect_url": "https://chrome.google.com/",
"currency": "CNY",
"payment_methods": [
{
"payment_method": "bank_transfer",
"payment_method_types": [
{
"payment_method_type": "local_bank_transfer",
"payment_experience": [
{
"payment_experience_type": "redirect_to_url",
"eligible_connectors": [
"zsl"
]
}
],
"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": [
"CN"
]
}
},
"value": "CN"
}
},
"surcharge_details": null,
"pm_auth_connector": null
}
]
},
{
"payment_method": "bank_transfer",
"payment_method_types": [
{
"payment_method_type": "local_bank_transfer",
"payment_experience": null,
"card_networks": null,
"bank_names": null,
"bank_debits": null,
"bank_transfers": {
"eligible_connectors": [
"zsl"
]
},
"required_fields": {
"billing.address.country": {
"required_field": "billing.address.country",
"display_name": "country",
"field_type": {
"user_address_country": {
"options": [
"CN"
]
}
},
"value": "CN"
}
},
"surcharge_details": null,
"pm_auth_connector": null
}
]
}
],
"mandate_payment": null,
"merchant_name": "NewAge Retailer",
"show_surcharge_breakup_screen": false,
"payment_type": "normal"
}
Checklist
- [x] I formatted the code
cargo +nightly fmt --all - [x] I addressed lints thrown by
cargo clippy - [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a CHANGELOG entry if applicable