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

refactor(connector): convert init payment flow to preprocessing flow for nuvei #4878

Merged

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented Jun 5, 2024

Type of Change

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

Description

convert init payment flow to preprocessing flow for nuvei

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. Create a merchant with Nuvei Connector.

  2. Create a normal payment

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_nAIZ8qcYQdYMKkNhMhv2OsHcE9wX94UvPbjgZy92JXizcfgg2AG95KiImp3ZtUaN' \
--data-raw '{
    "amount": 25100,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "connector": [
        "nuvei"
    ],
    "customer_id": "futurebilling",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "testing",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "setup_future_usage": "off_session",
    "payment_method_data": {
        "card": {
            
            
            "card_number": "2221008123677736",
            "card_exp_month": "12",
            "card_exp_year": "30",
            "card_holder_name": "CL-BRW2",
            "card_cvc": "217"
        }
    },
    "mandate_data": {
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "127.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 100,
                "currency": "USD",
                "metadata": {
                    "frequency": "1"
                },
                "end_date": "2025-05-03T04:07:52.723Z"
            }
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "jkjj Street",
            "line3": "no 1111 Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "JP",
            "first_name": "joseph",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "joseph",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "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"
    }
}'

Response

{
    "payment_id": "pay_UNIN5rgT5bAVDWUgf6AF",
    "merchant_id": "postman_merchant_GHAction_3ecfb887-8245-4332-a114-293797d0ea5c",
    "status": "succeeded",
    "amount": 25100,
    "net_amount": 25100,
    "amount_capturable": 0,
    "amount_received": 25100,
    "connector": "nuvei",
    "client_secret": "pay_UNIN5rgT5bAVDWUgf6AF_secret_CD6X6tUfPEBV3WxE3Kq8",
    "created": "2024-06-06T07:32:58.256Z",
    "currency": "USD",
    "customer_id": "futurebilling",
    "customer": {
        "id": "futurebilling",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "testing",
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_5BzYOJRuWyx2u6K8EJWw",
    "mandate_data": {
        "update_mandate_id": null,
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "127.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 100,
                "currency": "USD",
                "start_date": null,
                "end_date": "2025-05-03T04:07:52.723Z",
                "metadata": {
                    "frequency": "1"
                }
            }
        }
    },
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "7736",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "222100",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "30",
            "card_holder_name": "CL-BRW2",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_IEqGQkicvE3I14BQuu5n",
    "shipping": null,
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "JP",
            "line1": "1467",
            "line2": "jkjj Street",
            "line3": "no 1111 Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "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": {
        "customer_id": "futurebilling",
        "created_at": 1717659178,
        "expires": 1717662778,
        "secret": "epk_772ebf1a52cd404d995a0fed71c10c68"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "711000000036768658",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "454599348",
    "payment_link": null,
    "profile_id": "pro_Mgs1yiterd3wOFwptt4G",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5S8fI1O8NTky7ff9sirT",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-06-06T07:47:58.256Z",
    "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": "pm_QFLJnsdFEWgbsFzue9Uj",
    "payment_method_status": null,
    "updated": "2024-06-06T07:33:00.754Z",
    "charges": null,
    "frm_metadata": null
}

3 Create a 3DS payment.(complete redirection)

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_nAIZ8qcYQdYMKkNhMhv2OsHcE9wX94UvPbjgZy92JXizcfgg2AG95KiImp3ZtUaN' \
--data-raw '{
    "amount": 15100,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "connector": [
        "nuvei"
    ],
    "customer_id": "futurebilling",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "testing",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "setup_future_usage": "off_session",
    "payment_method_data": {
        "card": {
            
            
            "card_number": "2221008123677736",
            "card_exp_month": "12",
            "card_exp_year": "30",
            "card_holder_name": "CL-BRW2",
            "card_cvc": "217"
        }
    },
    "mandate_data": {
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "127.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 100,
                "currency": "USD",
                "metadata": {
                    "frequency": "1"
                },
                "end_date": "2025-05-03T04:07:52.723Z"
            }
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "jkjj Street",
            "line3": "no 1111 Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "JP",
            "first_name": "joseph",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "joseph",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "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"
    }
}'

Response

{
    "payment_id": "pay_fFwpMu8KtV1MzQfJgi5q",
    "merchant_id": "postman_merchant_GHAction_3ecfb887-8245-4332-a114-293797d0ea5c",
    "status": "requires_customer_action",
    "amount": 15100,
    "net_amount": 15100,
    "amount_capturable": 15100,
    "amount_received": null,
    "connector": "nuvei",
    "client_secret": "pay_fFwpMu8KtV1MzQfJgi5q_secret_PJiS06fcUOlcsxUQMKzX",
    "created": "2024-06-05T09:50:56.124Z",
    "currency": "USD",
    "customer_id": "futurebilling",
    "customer": {
        "id": "futurebilling",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "testing",
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_e7O8y9BDQHvHPw7liaBu",
    "mandate_data": {
        "update_mandate_id": null,
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "127.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 100,
                "currency": "USD",
                "start_date": null,
                "end_date": "2025-05-03T04:07:52.723Z",
                "metadata": {
                    "frequency": "1"
                }
            }
        }
    },
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "7736",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "222100",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "30",
            "card_holder_name": "CL-BRW2",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_RwnkvFc13UMoo0KEjSEW",
    "shipping": null,
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "JP",
            "line1": "1467",
            "line2": "jkjj Street",
            "line3": "no 1111 Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "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": null,
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_fFwpMu8KtV1MzQfJgi5q/postman_merchant_GHAction_3ecfb887-8245-4332-a114-293797d0ea5c/pay_fFwpMu8KtV1MzQfJgi5q_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": "futurebilling",
        "created_at": 1717581056,
        "expires": 1717584656,
        "secret": "epk_1500f8de473148e1a4dcb5dffb2d5848"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "711000000036640698",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "453850598",
    "payment_link": null,
    "profile_id": "pro_Mgs1yiterd3wOFwptt4G",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5S8fI1O8NTky7ff9sirT",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-06-05T10:05:56.124Z",
    "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": "pm_XdgSfruRSDfB6ajkWbfM",
    "payment_method_status": null,
    "updated": "2024-06-05T09:50:59.466Z",
    "charges": null,
    "frm_metadata": null
}

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

@hrithikesh026 hrithikesh026 added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor labels Jun 5, 2024
@hrithikesh026 hrithikesh026 added this to the May 2024 Release milestone Jun 5, 2024
@hrithikesh026 hrithikesh026 self-assigned this Jun 5, 2024
@hrithikesh026 hrithikesh026 requested review from a team as code owners June 5, 2024 04:43
Base automatically changed from move-session-token-call-to-core to main June 5, 2024 08:24
Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.connector_mandate_id.clone()
}
_ => None,
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid the wildcard match arm, and expand it instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be picking this up in this PR #4884

@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 6, 2024
Merged via the queue into main with commit e7acaa5 Jun 6, 2024
13 checks passed
@likhinbopanna likhinbopanna deleted the convert-init-payment-flow-to-preprocessing-nuvei branch June 6, 2024 13:36
pixincreate added a commit that referenced this pull request Jun 7, 2024
…out-fix

* 'main' of github.com:juspay/hyperswitch:
  refactor(connector): convert init payment flow to preprocessing flow for shift4 (#4884)
  ci(cypress): Add billing address for bank redirects (#4903)
  refactor(openapi): move openapi to a separate folder (#4859)
  chore(version): 2024.06.07.0
  refactor(outgoing_webhooks): raise errors in the analytics pipeline in case of API client errors or non-2xx responses (#4894)
  chore(config): [MIFINITY] add configs for Mifinity in WASM (#4895)
  feat(router): add `acquirer_country_code` in acquirer_details and send it in netcetera authentication flow (#4835)
  refactor(connector): convert init payment flow to preprocessing flow for nuvei (#4878)
  feat(connector): [MIFINITY] Implement payment flows and Mifinity payment method (#4592)
  fix(connectors): [BOA/CYBS] make avs code optional (#4898)
  feat(events): add metadata info to events (#4875)
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants