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): [Paybox] add paybox connector #5575

Merged
merged 22 commits into from
Aug 14, 2024
Merged

Conversation

KiranKBR
Copy link
Contributor

@KiranKBR KiranKBR commented Aug 8, 2024

Type of Change

  • New feature

Description

Implemented Flows Authorize,Capture,PSync,Refund and RSync for card Payments.
For Paybox after the Payment we have to to do PSync as Force to get the status of Payment and same applies for Refund also.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

#5590

How did you test it?

Payment:

curl --location 'http://127.0.0.1:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_IUCGqoaqFnbYXDFcyRerYSYqx44KRHsJNsCHetqjQ0kqjsijMmBzZKsNOfcjDsUa' \
--data-raw '{
    "amount": 1000,
    "currency": "EUR",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 1000,
    "customer_id": "BamboraCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "1111222233334444",
            "card_exp_month": "05",
            "card_exp_year": "27",
            "card_holder_name": "John Doe",
            "card_cvc": "222"
        }
    },
    "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": "9123456789",
            "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": "9123456789",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS"
}'

Response:

{
    "payment_id": "pay_dA1GIgbVyqaXsDcES4dw",
    "merchant_id": "postman_merchant_GHAction_f962d351-d38d-431c-9c09-788d9fd68c8a",
    "status": "processing",
    "amount": 1000,
    "net_amount": 1000,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "paybox",
    "client_secret": "pay_dA1GIgbVyqaXsDcES4dw_secret_zAS5Q8sgJonxnvIq9WRy",
    "created": "2024-08-12T05:18:40.883Z",
    "currency": "EUR",
    "customer_id": "BamboraCustomer",
    "customer": {
        "id": "BamboraCustomer",
        "name": "John Doe",
        "email": "guest@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": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4444",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "111122",
            "card_extended_bin": null,
            "card_exp_month": "05",
            "card_exp_year": "27",
            "card_holder_name": "John Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_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": {
        "customer_id": "BamboraCustomer",
        "created_at": 1723439920,
        "expires": 1723443520,
        "secret": "epk_0cfd96fa1dbc4391bea59a4bdcd49dc1"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "0079564764",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "0038137048",
    "payment_link": null,
    "profile_id": "pro_lBL8sGEInU4ElAMrG82j",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_gNU267CSqzmqeBjI31Xz",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-08-12T05:33:40.881Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-08-12T05:18:43.645Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null
}

Force Psync:
request:

curl --location 'http://127.0.0.1:8080/payments/pay_dA1GIgbVyqaXsDcES4dw?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_IUCGqoaqFnbYXDFcyRerYSYqx44KRHsJNsCHetqjQ0kqjsijMmBzZKsNOfcjDsUa'

response:

{
    "payment_id": "pay_dA1GIgbVyqaXsDcES4dw",
    "merchant_id": "postman_merchant_GHAction_f962d351-d38d-431c-9c09-788d9fd68c8a",
    "status": "succeeded",
    "amount": 1000,
    "net_amount": 1000,
    "amount_capturable": 0,
    "amount_received": 1000,
    "connector": "paybox",
    "client_secret": "pay_dA1GIgbVyqaXsDcES4dw_secret_zAS5Q8sgJonxnvIq9WRy",
    "created": "2024-08-12T05:18:40.883Z",
    "currency": "EUR",
    "customer_id": "BamboraCustomer",
    "customer": {
        "id": "BamboraCustomer",
        "name": "John Doe",
        "email": "guest@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": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4444",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "111122",
            "card_extended_bin": null,
            "card_exp_month": "05",
            "card_exp_year": "27",
            "card_holder_name": "John Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_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": "0079564764",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "0038137048",
    "payment_link": null,
    "profile_id": "pro_lBL8sGEInU4ElAMrG82j",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_gNU267CSqzmqeBjI31Xz",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-08-12T05:33:40.881Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-08-12T05:24:12.303Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null
}

Refund:
request:

curl --location 'http://127.0.0.1:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_IUCGqoaqFnbYXDFcyRerYSYqx44KRHsJNsCHetqjQ0kqjsijMmBzZKsNOfcjDsUa' \
--data '{
    "payment_id": "pay_dA1GIgbVyqaXsDcES4dw",
    "amount": 1000,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

response:

{
    "refund_id": "ref_CL9wUYOMtrvST4IaY7pX",
    "payment_id": "pay_dA1GIgbVyqaXsDcES4dw",
    "amount": 1000,
    "currency": "EUR",
    "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,
    "created_at": "2024-08-12T05:24:44.370Z",
    "updated_at": "2024-08-12T05:24:46.081Z",
    "connector": "paybox",
    "profile_id": "pro_lBL8sGEInU4ElAMrG82j",
    "merchant_connector_id": "mca_gNU267CSqzmqeBjI31Xz",
    "charges": null
}

Refund ForceSync:
request:

curl --location 'http://127.0.0.1:8080/refunds/ref_7FR2uWPPcB3BCu0SPgoQ?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_IUCGqoaqFnbYXDFcyRerYSYqx44KRHsJNsCHetqjQ0kqjsijMmBzZKsNOfcjDsUa'

response:

{
    "refund_id": "ref_7FR2uWPPcB3BCu0SPgoQ",
    "payment_id": "pay_I355vemf48KDFwqGPpyy",
    "amount": 1000,
    "currency": "EUR",
    "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-08-10T20:18:24.724Z",
    "updated_at": "2024-08-11T10:46:31.950Z",
    "connector": "paybox",
    "profile_id": "pro_lBL8sGEInU4ElAMrG82j",
    "merchant_connector_id": "mca_gNU267CSqzmqeBjI31Xz",
    "charges": null
}

Cypress Test Results:
image

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

@KiranKBR KiranKBR requested review from a team as code owners August 8, 2024 21:55
@KiranKBR KiranKBR self-assigned this Aug 8, 2024
@KiranKBR KiranKBR added the A-connector-integration Area: Connector integration label Aug 8, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 8, 2024
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 9, 2024
@deepanshu-iiitu deepanshu-iiitu linked an issue Aug 12, 2024 that may be closed by this pull request
2 tasks
jarnura
jarnura previously approved these changes Aug 12, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 13, 2024
@KiranKBR KiranKBR requested a review from SamraatBansal August 13, 2024 11:16
@hyperswitch-bot hyperswitch-bot bot added M-api-contract-changes Metadata: This PR involves API contract changes and removed M-api-contract-changes Metadata: This PR involves API contract changes labels Aug 13, 2024
Copy link
Member

@pixincreate pixincreate left a comment

Choose a reason for hiding this comment

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

Other than that, LGTM.

cypress-tests/cypress/e2e/PaymentUtils/Paybox.js Outdated Show resolved Hide resolved
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 14, 2024
cypress-tests/cypress/e2e/PaymentUtils/Paybox.js Outdated Show resolved Hide resolved
cypress-tests/cypress/e2e/PaymentUtils/Paybox.js Outdated Show resolved Hide resolved
cypress-tests/cypress/e2e/PaymentUtils/Paybox.js Outdated Show resolved Hide resolved
cypress-tests/cypress/e2e/PaymentUtils/Paybox.js Outdated Show resolved Hide resolved
cypress-tests/cypress/e2e/PaymentUtils/Paybox.js Outdated Show resolved Hide resolved
pixincreate
pixincreate previously approved these changes Aug 14, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 14, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Aug 14, 2024
@Gnanasundari24
Copy link
Contributor

@KiranKBR Why all the testcases are failing?

@Gnanasundari24 Gnanasundari24 removed this pull request from the merge queue due to a manual request Aug 14, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Aug 14, 2024
Merged via the queue into main with commit e4f4fba Aug 14, 2024
12 of 14 checks passed
@Gnanasundari24 Gnanasundari24 deleted the paybox-flows branch August 14, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat(connector): [Paybox] Implement Paybox Payment Flows
6 participants