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): [Adyen ] Add fixes for Adyen PaymentsRequest struct #6803

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cookieg13
Copy link
Contributor

@cookieg13 cookieg13 commented Dec 11, 2024

Type of Change

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

Description

  1. We are sending type twice in paymentMethod.This PR fixes it.
Screenshot 2024-12-11 at 14 22 04
  1. Line 2 is not mandatory in Adyen, but we have mandated it. This PR fixes it.
  2. We are sending keys which has null in payments request. This PR fixes it.

{ "amount": { "currency": "HKD", "value": 1000 }, "merchantAccount": "ZurichInsurance_HongKong_TEST", "paymentMethod": { "type": "adyencard", "type": "scheme", "number": "********1142", "expiryMonth": "03", "expiryYear": "2030", "cvc":, "holderName": "John Doe", "brand": "visa", "networkPaymentReference": "********0415050" Good, this is the NTR from the CIT! }, "reference": "pay_iKttX4eWOlYXUZVi2YJC_1", "returnUrl": "https://sandbox.hyperswitch.io/payments/pay_iKttX4eWOlYXUZVi2YJC/merchant_1724257022/redirect/response/adyen", "shopperInteraction": "ContAuth", "recurringProcessingModel": "UnscheduledCardOnFile", "additionalData": { "authorisationType": null, "manualCapture": null, "executeThreeD": null, "recurringProcessingModel": null, "recurring.recurringDetailReference": null, "recurring.shopperReference": null, "networkTxReference": null, "payoutEligible": null, "fundsAvailability": null }, "shopperReference": "merchant_1724257022_venkatesh_testing_adyen", "shopperEmail": "abc@gmail.com" }

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?

1. For testing fix 1( type being sent twice in "payment method") (expand to view more) 1. Set base url of adyen to below in config/development.toml file

adyen.base_url = "https://webhook.site/da9694a5-b8d3-4795-8c58-350348c0cd5c/"

2. Hit curl for /payments CIT

curl --location --request POST 'http://localhost:8080/payments'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'api-key: dev_yqQUK1etxKP6i7ZnNJ7qNO02pDmcoTjInBCRVK89NmXbvw5NR723adMoSUpGWSto'
--data-raw '{
"amount": 20000,
"currency": "EUR",
"confirm": false,
"capture_method": "automatic",
"capture_on": "2022-09-10T10:11:12Z",
"authentication_type": "three_ds",
"return_url": "https://google.com",
"email": "something@gmail.com",
"name": "Joseph Doe",
"phone": "999999999",
"phone_country_code": "+65",
"description": "Its my first payment request",
"setup_future_usage": "off_session",
"billing": {
"address": {
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"city": "San Fransico",
"state": "California",
"zip": "94122",
"country": "US",
"first_name": "joseph",
"last_name": "Doe"
},
"phone": {
"number": "8056594427",
"country_code": "+91"
}
},
"shipping": {
"address": {
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"city": "San Fransico",
"state": "California",
"zip": "94122",
"country": "US",
"first_name": "joseph",
"last_name": "Doe"
},
"phone": {
"number": "8056594427",
"country_code": "+91"
}
}
}'

3. Hit curl for /confirm CIT

curl --location --request POST 'http://localhost:8080/payments/pay_OUqcRtxgPbEWwJWXkPQL/confirm' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_yqQUK1etxKP6i7ZnNJ7qNO02pDmcoTjInBCRVK89NmXbvw5NR723adMoSUpGWSto' \ --data-raw '{ "confirm": true, "customer_id": "StripeCustomer", "payment_type": "setup_mandate", "customer_acceptance": { "acceptance_type": "online", "accepted_at": "1963-05-03T04:07:52.723Z", "online": { "ip_address": "127.0.0.1", "user_agent": "amet irure esse" } }, "payment_method": "card", "payment_method_type": "credit", "email": "test@novalnet.de", "payment_method_data": { "card": { "card_number": "4917610000000000", "card_exp_month": "03", "card_exp_year": "30", "card_cvc": "737" }, "billing": { "address": { "line1": "1467", "city": "San Fransico", "state": "California", "zip": "94122", "country": "US" }, "email": "test@novalnet.de", "phone": { "number": "8056594427", "country_code": "+91" } } }, "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 } }'

  1. Go to https://webhook.site/#!/view/da9694a5-b8d3-4795-8c58-350348c0cd5c/00ca9417-2ef3-4f3d-90ff-198e6e8a36c4/1
    Before (type being sent twice)
Screenshot 2024-12-11 at 14 22 04

After
Screenshot 2024-12-11 at 14 50 11

For testing fix 2 and 3 (expand to view more) 1. Make /payments call (i )for cards , ii) without line2)

curl --location --request POST 'http://localhost:8080/payments'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'api-key: dev_yqQUK1etxKP6i7ZnNJ7qNO02pDmcoTjInBCRVK89NmXbvw5NR723adMoSUpGWSto'
--data-raw '{
"amount": 700,
"currency": "USD",
"confirm": true,
"payment_link": false,
"capture_on": "2029-09-10T10:11:12Z",
"amount_to_capture": 700,
"name": "John Doe",
"email": "dg@example.com",
"phone": "999999999",
"phone_country_code": "+1",
"description": "Its my first payment request",
"authentication_type": "three_ds",
"return_url": "https://google.com",
"payment_method_data": {
"card": {
"card_number": "4917610000000000",
"card_exp_month": "03",
"card_exp_year": "30",
"card_cvc": "737"
},
"billing": {
"address": {
"line1": "1467",
"city": "San Fransico",
"state": "California",
"zip": "94122",
"country": "US"
}
}
},
"payment_method": "card",
"payment_method_type": "credit",
"browser_info": {
"color_depth": 24,
"java_enabled": true,
"java_script_enabled": true,
"language": "en-GB",
"screen_height": 720,
"screen_width": 1280,
"time_zone": -330,
"ip_address": "208.127.127.193",
"accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"
},
"metadata": {
"udf1": "value1",
"new_customer": "true",
"login_date": "2019-09-10T10:11:12Z"
},
"order_details": [
{
"product_name": "Tea",
"quantity": 1,
"amount": 110,
"product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg"
},
{
"product_name": "Tea",
"quantity": 1,
"amount": 110,
"product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg"
},
{
"product_name": "Tea",
"quantity": 1,
"amount": 110,
"product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg"
}
]
}'

Response

{
"payment_id": "pay_2JxnSiO0TsBTkYeTqjJt",
"merchant_id": "merchant_1733902978",
"status": "requires_customer_action",
"amount": 700,
"net_amount": 700,
"shipping_cost": null,
"amount_capturable": 700,
"amount_received": null,
"connector": "adyen",
"client_secret": "pay_2JxnSiO0TsBTkYeTqjJt_secret_lllW1w9eIZj3miCW5ldU",
"created": "2024-12-11T09:21:32.834Z",
"currency": "USD",
"customer_id": null,
"customer": {
"id": null,
"name": "John Doe",
"email": "dg@example.com",
"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": null,
"payment_method": "card",
"payment_method_data": {
"card": {
"last4": "0000",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "491761",
"card_extended_bin": null,
"card_exp_month": "03",
"card_exp_year": "30",
"card_holder_name": null,
"payment_checks": null,
"authentication_data": null
},
"billing": {
"address": {
"city": "San Fransico",
"country": "US",
"line1": "1467",
"line2": null,
"line3": null,
"zip": "94122",
"state": "California",
"first_name": null,
"last_name": null
},
"phone": null,
"email": null
}
},
"payment_token": null,
"shipping": null,
"billing": null,
"order_details": [
{
"brand": null,
"amount": 110,
"category": null,
"quantity": 1,
"product_id": null,
"product_name": "Tea",
"product_type": null,
"sub_category": null,
"product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg",
"product_tax_code": null,
"requires_shipping": null
},
{
"brand": null,
"amount": 110,
"category": null,
"quantity": 1,
"product_id": null,
"product_name": "Tea",
"product_type": null,
"sub_category": null,
"product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg",
"product_tax_code": null,
"requires_shipping": null
},
{
"brand": null,
"amount": 110,
"category": null,
"quantity": 1,
"product_id": null,
"product_name": "Tea",
"product_type": null,
"sub_category": null,
"product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg",
"product_tax_code": null,
"requires_shipping": null
}
],
"email": null,
"name": null,
"phone": null,
"return_url": "https://google.com/",
"authentication_type": "three_ds",
"statement_descriptor_name": null,
"statement_descriptor_suffix": null,
"next_action": {
"type": "redirect_to_url",
"redirect_to_url": "http://localhost:8080/payments/redirect/pay_2JxnSiO0TsBTkYeTqjJt/merchant_1733902978/pay_2JxnSiO0TsBTkYeTqjJt_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": null,
"manual_retry_allowed": null,
"connector_transaction_id": "BD3J85G7X2V52775",
"frm_message": null,
"metadata": {
"udf1": "value1",
"login_date": "2019-09-10T10:11:12Z",
"new_customer": "true"
},
"connector_metadata": null,
"feature_metadata": null,
"reference_id": "BD3J85G7X2V52775",
"payment_link": null,
"profile_id": "pro_Q5hoSY3fyaGlippNh43p",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_Gb4ezGGk0nsfaea3MiD7",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2024-12-11T09:36:32.833Z",
"fingerprint": null,
"browser_info": {
"language": "en-GB",
"time_zone": -330,
"ip_address": "208.127.127.193",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
"color_depth": 24,
"java_enabled": true,
"screen_width": 1280,
"accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8",
"screen_height": 720,
"java_script_enabled": true
},
"payment_method_id": null,
"payment_method_status": null,
"updated": "2024-12-11T09:21:34.449Z",
"charges": null,
"frm_metadata": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": null
}

  1. Checking the raw_connector_request
    Before (null fields present in payment request body)

raw_connector_request: Object {"amount": Object {"currency": String("USD"), "value": Number(700)}, "merchantAccount": String("*** alloc::string::String "), "paymentMethod": Object {"type": String("scheme"), "number": String("491761*******"), "expiryMonth": String("*** alloc::string::String "), "expiryYear": String(" alloc::string::String "), "cvc": String(" alloc::string::String "), "holderName": Null, "brand": Null, "networkPaymentReference": Null}, "reference": String("pay_Fy3r0FLKxdUkV1Nc7SDz_1"), "returnUrl": String("http://localhost:8080/payments/pay_Fy3r0FLKxdUkV1Nc7SDz/merchant_1733902978/redirect/response/adyen"), "browserInfo": Object {"userAgent": String("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"), "acceptHeader": String("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8"), "language": String("en-GB"), "colorDepth": Number(24), "screenHeight": Number(720), "screenWidth": Number(1280), "timeZoneOffset": Number(-330), "javaEnabled": Bool(true)}, "shopperInteraction": String("Ecommerce"), "additionalData": Object {"authorisationType": Null, "manualCapture": Null, "executeThreeD": String("true"), "recurringProcessingModel": Null, "recurring.recurringDetailReference": Null, "recurring.shopperReference": Null, "networkTxReference": Null, "payoutEligible": Null, "fundsAvailability": Null}, "shopperName": Object {"firstName": Null, "lastName": Null}, "shopperIP": String("208..."), "shopperEmail": String("@example.com"), "countryCode": String("US"), "metadata": String("** serde_json::value::Value ***")}

After (null fields are not present in payment request body)

raw_connector_request: Object {"amount": Object {"currency": String("USD"), "value": Number(700)}, "merchantAccount": String("*** alloc::string::String "), "paymentMethod": Object {"type": String("scheme"), "number": String("491761*******"), "expiryMonth": String("*** alloc::string::String "), "expiryYear": String(" alloc::string::String "), "cvc": String(" alloc::string::String ")}, "reference": String("pay_2JxnSiO0TsBTkYeTqjJt_1"), "returnUrl": String("http://localhost:8080/payments/pay_2JxnSiO0TsBTkYeTqjJt/merchant_1733902978/redirect/response/adyen"), "browserInfo": Object {"userAgent": String("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"), "acceptHeader": String("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8"), "language": String("en-GB"), "colorDepth": Number(24), "screenHeight": Number(720), "screenWidth": Number(1280), "timeZoneOffset": Number(-330), "javaEnabled": Bool(true)}, "shopperInteraction": String("Ecommerce"), "additionalData": Object {"executeThreeD": String("true")}, "shopperName": Object {}, "shopperIP": String("208..."), "shopperEmail": String("@example.com"), "billingAddress": Object {"city": String("San Fransico"), "country": String("US"), "houseNumberOrName": String("** alloc::string::String "), "postalCode": String(" alloc::string::String "), "stateOrProvince": String(" alloc::string::String ")}, "countryCode": String("US"), "metadata": String(" serde_json::value::Value ***")}

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 self-assigned this Dec 11, 2024
@cookieg13 cookieg13 requested a review from a team as a code owner December 11, 2024 09:53
Copy link

semanticdiff-com bot commented Dec 11, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector/adyen/transformers.rs  5% smaller

@cookieg13 cookieg13 changed the title add adyen fixes feat(connector): [Adyen ] Add fixes Dec 11, 2024
@@ -627,6 +665,7 @@ pub struct PmdForPaymentType {
#[serde(rename_all = "camelCase")]
pub struct JCSVoucherData {
first_name: Secret<String>,

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this

@@ -92,25 +92,36 @@ pub enum AuthType {
#[derive(Clone, Default, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdditionalData {
#[serde(skip_serializing_if = "Option::is_none")]
Copy link
Contributor

Choose a reason for hiding this comment

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

@cookieg13 cookieg13 changed the title feat(connector): [Adyen ] Add fixes feat(connector): [Adyen ] Add fixes for Adyen PaymentsRequest struct Dec 12, 2024
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.

3 participants