hyperswitch
hyperswitch copied to clipboard
feat(connector): [Elavon] Implement cards Flow
Type of Change
- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
Added Cards flow for Elavon
Additional Changes
- [] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [x] This PR modifies application configuration/environment variables
Motivation and Context
Added Cards flow for Elavon
How did you test it?
Auth +Capture
Request
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_X02U5PA0RU9fDydCUhM951NOSCQEtkvMhpkxrciTOb0VcAMczyu4ylxEz70210JH' \
--data-raw '{
"amount": 1400,
"currency": "USD",
"confirm": true,
"capture_method": "automatic",
"email": "[email protected]",
"payment_method": "card",
"payment_method_type": "credit",
"payment_method_data": {
"card": {
"card_number": "4111111111111111",
"card_exp_month": "01",
"card_exp_year": "29",
"card_holder_name": "joseph Doe",
"card_cvc": "124"
}
}
}'
Response
{
"payment_id": "pay_PBGAjDQVwA1SfUkqIQaU",
"merchant_id": "merchant_1730784635",
"status": "succeeded",
"amount": 1400,
"net_amount": 1400,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": 1400,
"connector": "elavon",
"client_secret": "pay_PBGAjDQVwA1SfUkqIQaU_secret_DvxqB3TUPX5sjWwlIk4h",
"created": "2024-11-05T15:59:25.325Z",
"currency": "USD",
"customer_id": null,
"customer": {
"id": null,
"name": null,
"email": "[email protected]",
"phone": null,
"phone_country_code": null
},
"description": null,
"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": "1111",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "411111",
"card_extended_bin": null,
"card_exp_month": "01",
"card_exp_year": "29",
"card_holder_name": null,
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": null,
"shipping": null,
"billing": null,
"order_details": null,
"email": null,
"name": null,
"phone": null,
"return_url": null,
"authentication_type": "no_three_ds",
"statement_descriptor_name": null,
"statement_descriptor_suffix": null,
"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": "051124C45-603CD7B4-47C7-426E-B63E-E8217043459C",
"frm_message": null,
"metadata": null,
"connector_metadata": null,
"feature_metadata": null,
"reference_id": null,
"payment_link": null,
"profile_id": "pro_yzFt1TBeVUEs9Pc4O4J4",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_4xwh6f3O1nkokP1N5N7u",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2024-11-05T16:14:25.325Z",
"fingerprint": null,
"browser_info": null,
"payment_method_id": null,
"payment_method_status": null,
"updated": "2024-11-05T15:59:28.882Z",
"charges": null,
"frm_metadata": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": null
}
Auth Only
Request
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_X02U5PA0RU9fDydCUhM951NOSCQEtkvMhpkxrciTOb0VcAMczyu4ylxEz70210JH' \
--data-raw '{
"amount": 1400,
"currency": "USD",
"confirm": true,
"capture_method": "manual",
"email": "[email protected]",
"payment_method": "card",
"payment_method_type": "credit",
"payment_method_data": {
"card": {
"card_number": "4111111111111111",
"card_exp_month": "01",
"card_exp_year": "29",
"card_holder_name": "joseph Doe",
"card_cvc": "124"
}
}
}'
Response
{
"payment_id": "pay_cFs9lujpuOm2lJJ7yLUq",
"merchant_id": "merchant_1730784635",
"status": "requires_capture",
"amount": 1400,
"net_amount": 1400,
"shipping_cost": null,
"amount_capturable": 1400,
"amount_received": null,
"connector": "elavon",
"client_secret": "pay_cFs9lujpuOm2lJJ7yLUq_secret_kJwPzcJNoCekNw0Xoy2A",
"created": "2024-11-05T16:01:53.192Z",
"currency": "USD",
"customer_id": null,
"customer": {
"id": null,
"name": null,
"email": "[email protected]",
"phone": null,
"phone_country_code": null
},
"description": null,
"refunds": null,
"disputes": null,
"mandate_id": null,
"mandate_data": null,
"setup_future_usage": null,
"off_session": null,
"capture_on": null,
"capture_method": "manual",
"payment_method": "card",
"payment_method_data": {
"card": {
"last4": "1111",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "411111",
"card_extended_bin": null,
"card_exp_month": "01",
"card_exp_year": "29",
"card_holder_name": null,
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": null,
"shipping": null,
"billing": null,
"order_details": null,
"email": null,
"name": null,
"phone": null,
"return_url": null,
"authentication_type": "no_three_ds",
"statement_descriptor_name": null,
"statement_descriptor_suffix": null,
"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": "051124O2C-332C3670-20A1-42DA-B71F-BC54AED2807A",
"frm_message": null,
"metadata": null,
"connector_metadata": null,
"feature_metadata": null,
"reference_id": null,
"payment_link": null,
"profile_id": "pro_yzFt1TBeVUEs9Pc4O4J4",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_4xwh6f3O1nkokP1N5N7u",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2024-11-05T16:16:53.192Z",
"fingerprint": null,
"browser_info": null,
"payment_method_id": null,
"payment_method_status": null,
"updated": "2024-11-05T16:01:54.567Z",
"charges": null,
"frm_metadata": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": null
}
Capture
Request
curl --location 'http://localhost:8080/payments/pay_cFs9lujpuOm2lJJ7yLUq/capture' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_X02U5PA0RU9fDydCUhM951NOSCQEtkvMhpkxrciTOb0VcAMczyu4ylxEz70210JH' \
--data '{
"amount_to_capture": 650,
"statement_descriptor_name": "Joseph",
"statement_descriptor_suffix": "JS"
}'
Response
{
"payment_id": "pay_cFs9lujpuOm2lJJ7yLUq",
"merchant_id": "merchant_1730784635",
"status": "partially_captured",
"amount": 1400,
"net_amount": 1400,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": 650,
"connector": "elavon",
"client_secret": "pay_cFs9lujpuOm2lJJ7yLUq_secret_kJwPzcJNoCekNw0Xoy2A",
"created": "2024-11-05T16:01:53.192Z",
"currency": "USD",
"customer_id": null,
"customer": {
"id": null,
"name": null,
"email": "[email protected]",
"phone": null,
"phone_country_code": null
},
"description": null,
"refunds": null,
"disputes": null,
"mandate_id": null,
"mandate_data": null,
"setup_future_usage": null,
"off_session": null,
"capture_on": null,
"capture_method": "manual",
"payment_method": "card",
"payment_method_data": {
"card": {
"last4": "1111",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "411111",
"card_extended_bin": null,
"card_exp_month": "01",
"card_exp_year": "29",
"card_holder_name": null,
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": null,
"shipping": null,
"billing": null,
"order_details": null,
"email": null,
"name": null,
"phone": null,
"return_url": null,
"authentication_type": "no_three_ds",
"statement_descriptor_name": null,
"statement_descriptor_suffix": null,
"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": "051124O2C-332C3670-20A1-42DA-B71F-BC54AED2807A",
"frm_message": null,
"metadata": null,
"connector_metadata": null,
"feature_metadata": null,
"reference_id": null,
"payment_link": null,
"profile_id": "pro_yzFt1TBeVUEs9Pc4O4J4",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_4xwh6f3O1nkokP1N5N7u",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2024-11-05T16:16:53.192Z",
"fingerprint": null,
"browser_info": null,
"payment_method_id": null,
"payment_method_status": null,
"updated": "2024-11-05T16:02:14.492Z",
"charges": null,
"frm_metadata": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": null
}
Refunds
Request
curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_6rV2U010InOypaGTo6iqMHMvFapQAlBBg8LnGKYaP5f7HljVy9PIcYpF8SBovgDU' \
--data '{
"payment_id": "pay_cFs9lujpuOm2lJJ7yLUq",
"amount": 600,
"reason": "Customer returned product",
"refund_type": "instant",
"metadata": {
"udf1": "value1",
"new_customer": "true",
"login_date": "2019-09-10T10:11:12Z"
}
}'
Response
{
"refund_id": "ref_vZfboHyu9uG15sgsyBr4",
"payment_id": "pay_cFs9lujpuOm2lJJ7yLUq",
"amount": 600,
"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,
"created_at": "2024-11-05T16:02:43.922Z",
"updated_at": "2024-11-05T16:02:49.037Z",
"connector": "elavon",
"profile_id": "pro_yzFt1TBeVUEs9Pc4O4J4",
"merchant_connector_id": "mca_4xwh6f3O1nkokP1N5N7u",
"charges": null
}
Psync
Request
curl --location 'http://localhost:8080/payments/pay_cFs9lujpuOm2lJJ7yLUq?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_6rV2U010InOypaGTo6iqMHMvFapQAlBBg8LnGKYaP5f7HljVy9PIcYpF8SBovgDU' \
--data ''
Response
{
"payment_id": "pay_cFs9lujpuOm2lJJ7yLUq",
"merchant_id": "merchant_1730784635",
"status": "partially_captured",
"amount": 1400,
"net_amount": 1400,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": 650,
"connector": "elavon",
"client_secret": "pay_cFs9lujpuOm2lJJ7yLUq_secret_kJwPzcJNoCekNw0Xoy2A",
"created": "2024-11-05T16:01:53.192Z",
"currency": "USD",
"customer_id": null,
"customer": {
"id": null,
"name": null,
"email": "[email protected]",
"phone": null,
"phone_country_code": null
},
"description": null,
"refunds": [
{
"refund_id": "ref_vZfboHyu9uG15sgsyBr4",
"payment_id": "pay_cFs9lujpuOm2lJJ7yLUq",
"amount": 600,
"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,
"created_at": "2024-11-05T16:02:43.922Z",
"updated_at": "2024-11-05T16:02:49.037Z",
"connector": "elavon",
"profile_id": "pro_yzFt1TBeVUEs9Pc4O4J4",
"merchant_connector_id": "mca_4xwh6f3O1nkokP1N5N7u",
"charges": null
}
],
"disputes": null,
"mandate_id": null,
"mandate_data": null,
"setup_future_usage": null,
"off_session": null,
"capture_on": null,
"capture_method": "manual",
"payment_method": "card",
"payment_method_data": {
"card": {
"last4": "1111",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "411111",
"card_extended_bin": null,
"card_exp_month": "01",
"card_exp_year": "29",
"card_holder_name": null,
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": null,
"shipping": null,
"billing": null,
"order_details": null,
"email": null,
"name": null,
"phone": null,
"return_url": null,
"authentication_type": "no_three_ds",
"statement_descriptor_name": null,
"statement_descriptor_suffix": null,
"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": "051124O2C-332C3670-20A1-42DA-B71F-BC54AED2807A",
"frm_message": null,
"metadata": null,
"connector_metadata": null,
"feature_metadata": null,
"reference_id": null,
"payment_link": null,
"profile_id": "pro_yzFt1TBeVUEs9Pc4O4J4",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_4xwh6f3O1nkokP1N5N7u",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2024-11-05T16:16:53.192Z",
"fingerprint": null,
"browser_info": null,
"payment_method_id": null,
"payment_method_status": null,
"updated": "2024-11-05T16:02:14.492Z",
"charges": null,
"frm_metadata": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": null
}
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
Changed Files
@awasthi21 Why refund and save card flows everything is failing?
@Gnanasundari24 Some Refund flow are failing as as 3DS is not implemented
@awasthi21 Even though its not implemented you can map the error code and error message properly