Skip to content

Conversation

awasthi21
Copy link
Contributor

@awasthi21 awasthi21 commented Jan 2, 2025

Type of Change

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

Description

Added Xendit Cards & Mandates Flow

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?

Screenshot 2025-01-09 at 1 17 47 PM Screenshot 2025-01-09 at 1 20 37 PM Screenshot 2025-01-09 at 1 20 58 PM Screenshot 2025-01-09 at 1 21 10 PM

**Three-DS **

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tq4ULEe1sBlAVdBP2vInkkBCLMBBPimfl5cfsGZKq19Apf2XxUxxJYfYQ0iDTvkb' \
--data-raw '{
    "amount": 651200,
    "currency": "IDR",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "First_Customer",
    "name": "John Doe",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4000000000001091",
            "card_exp_month": "12",
            "card_exp_year": "27",
            "card_holder_name": "joseph Doe",
            "card_cvc": "124"
        }
    },
    "billing": {
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
}'
Response
{
    "payment_id": "pay_J396NwTCTnQR6aNN06cj",
    "merchant_id": "merchant_1736237814",
    "status": "requires_customer_action",
    "amount": 651200,
    "net_amount": 651200,
    "shipping_cost": null,
    "amount_capturable": 651200,
    "amount_received": null,
    "connector": "xendit",
    "client_secret": "pay_J396NwTCTnQR6aNN06cj_secret_D8MZIqPS0np9YOmdaY1k",
    "created": "2025-01-09T08:02:30.946Z",
    "currency": "IDR",
    "customer_id": "First_Customer",
    "customer": {
        "id": "First_Customer",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "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": "1091",
            "card_type": "CREDIT",
            "card_network": "Visa",
            "card_issuer": "INTL HDQTRS-CENTER OWNED",
            "card_issuing_country": "UNITEDSTATES",
            "card_isin": "400000",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "27",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": null,
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "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_J396NwTCTnQR6aNN06cj/merchant_1736237814/pay_J396NwTCTnQR6aNN06cj_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": "First_Customer",
        "created_at": 1736409750,
        "expires": 1736413350,
        "secret": "epk_2775a6f3843b44088dfd343772ec8f90"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "pr-68380c6c-fa9c-4f70-8f90-b3435d13294c",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "32864b78-b0e6-404f-91d5-3499ca43d437",
    "payment_link": null,
    "profile_id": "pro_LHUMEFyJkdZ8ZpRYaPlO",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_Z3QCs07PIgZl44iBlKr7",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-09T08:17:30.946Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-09T08:02:32.018Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Redirection Response
Screenshot 2025-01-09 at 1 33 00 PM
Screenshot 2025-01-09 at 1 34 03 PM

Mandates 3DS

Request: CIT
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tq4ULEe1sBlAVdBP2vInkkBCLMBBPimfl5cfsGZKq19Apf2XxUxxJYfYQ0iDTvkb' \
--data-raw '{
    "amount": 651200,
    "currency": "IDR",
    "confirm": true,
    "capture_method": "automatic",
    "customer_id": "First_Customer",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4000000000001091",
            "card_exp_month": "12",
            "card_exp_year": "27",
            "card_holder_name": "joseph Doe",
            "card_cvc": "124"
        }
    },
    "billing": {
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "setup_future_usage": "off_session",
    "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"
        }
    }   
}'
Response
{
    "payment_id": "pay_mFnbSGcR9kGihTbbZlk1",
    "merchant_id": "merchant_1736237814",
    "status": "requires_customer_action",
    "amount": 651200,
    "net_amount": 651200,
    "shipping_cost": null,
    "amount_capturable": 651200,
    "amount_received": null,
    "connector": "xendit",
    "client_secret": "pay_mFnbSGcR9kGihTbbZlk1_secret_WcRx43ISAJxiWd36FYwi",
    "created": "2025-01-09T08:05:08.408Z",
    "currency": "IDR",
    "customer_id": "First_Customer",
    "customer": {
        "id": "First_Customer",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1091",
            "card_type": "CREDIT",
            "card_network": "Visa",
            "card_issuer": "INTL HDQTRS-CENTER OWNED",
            "card_issuing_country": "UNITEDSTATES",
            "card_isin": "400000",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "27",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": null,
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "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_mFnbSGcR9kGihTbbZlk1/merchant_1736237814/pay_mFnbSGcR9kGihTbbZlk1_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": "First_Customer",
        "created_at": 1736409908,
        "expires": 1736413508,
        "secret": "epk_6c04b0ae18fb45c6947cb8debbd8ffb3"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "pr-daa78a5d-9c69-4d92-8333-ec358739018c",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "6e6cb3b5-00cd-43ff-8162-26cd4cbd96f8",
    "payment_link": null,
    "profile_id": "pro_LHUMEFyJkdZ8ZpRYaPlO",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_Z3QCs07PIgZl44iBlKr7",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-09T08:20:08.408Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_pC8guSouUhlruaVUnMeQ",
    "payment_method_status": "inactive",
    "updated": "2025-01-09T08:05:09.242Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm-8c1b96d1-6dbf-40f1-bf7f-02fb85b50275"
}
**Sync Response**

<img width="1064" alt="Screenshot 2025-01-09 at 1 37 00 PM" src="https://github.com/user-attachments/assets/012f527a-bef7-4886-b752-a4779a95744f" />

MIT-Payments

Request:
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tq4ULEe1sBlAVdBP2vInkkBCLMBBPimfl5cfsGZKq19Apf2XxUxxJYfYQ0iDTvkb' \
--data-raw '{
    "amount": 6500000,
    "currency": "IDR",
    "confirm": true,
    "capture_method": "automatic",
    "customer_id": "First_Customer",
    "email": "[email protected]",
    "off_session": true,
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_pC8guSouUhlruaVUnMeQ"
    },
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "[email protected]"
    }
}'
Response
{
    "payment_id": "pay_jQ9tMQek9zg1LULe6iGe",
    "merchant_id": "merchant_1736237814",
    "status": "processing",
    "amount": 6500000,
    "net_amount": 6500000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "xendit",
    "client_secret": "pay_jQ9tMQek9zg1LULe6iGe_secret_kDteLBW9dmMfCUaPJvoz",
    "created": "2025-01-09T08:08:57.890Z",
    "currency": "IDR",
    "customer_id": "First_Customer",
    "customer": {
        "id": "First_Customer",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1091",
            "card_type": "CREDIT",
            "card_network": "Visa",
            "card_issuer": "INTL HDQTRS-CENTER OWNED",
            "card_issuing_country": "UNITEDSTATES",
            "card_isin": "400000",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "27",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "[email protected]"
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "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": {
        "customer_id": "First_Customer",
        "created_at": 1736410137,
        "expires": 1736413737,
        "secret": "epk_75908c6e3a9843e7bd685f32058cd10e"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pr-ca0126e8-03de-424d-a3db-02a55c9d93c8",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "2c7ed899-7b29-4a4b-92e7-06a3d647c394",
    "payment_link": null,
    "profile_id": "pro_LHUMEFyJkdZ8ZpRYaPlO",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_Z3QCs07PIgZl44iBlKr7",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-09T08:23:57.890Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_pC8guSouUhlruaVUnMeQ",
    "payment_method_status": "active",
    "updated": "2025-01-09T08:08:58.839Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm-8c1b96d1-6dbf-40f1-bf7f-02fb85b50275"
}

Sync:

Screenshot 2025-01-13 at 4 32 16 PM

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

@awasthi21 awasthi21 added the A-connector-integration Area: Connector integration label Jan 2, 2025
@awasthi21 awasthi21 self-assigned this Jan 2, 2025
@awasthi21 awasthi21 requested review from a team as code owners January 2, 2025 09:04
Copy link

semanticdiff-com bot commented Jan 2, 2025

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 2, 2025
@awasthi21 awasthi21 force-pushed the 7964-featconnector-xendit-pr-template-code branch from 6da83bc to 0fddb93 Compare January 2, 2025 09:46
@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 Jan 2, 2025
@awasthi21 awasthi21 force-pushed the 7964-featconnector-xendit-pr-template-code branch from 7d6b3a9 to 55e01c1 Compare January 7, 2025 10:59
@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 Jan 7, 2025
@awasthi21 awasthi21 force-pushed the 7964-featconnector-xendit-pr-template-code branch from 1c9a909 to 282cf08 Compare January 9, 2025 07:55
@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 Jan 9, 2025
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Jan 9, 2025
ShankarSinghC
ShankarSinghC previously approved these changes Jan 10, 2025
customer_acceptance: null,
setup_future_usage: "on_session",
amount: 6500000,
billing: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make billing address as const and use it everywhere ?

},
currency: "IDR",
mandate_data: null,
customer_acceptance: {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also make customer_acceptance as const and use it

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check this ?

@awasthi21 awasthi21 force-pushed the 7964-featconnector-xendit-pr-template-code branch from 06210f7 to aec75ce Compare January 13, 2025 10:25
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 13, 2025
@awasthi21 awasthi21 force-pushed the 7964-featconnector-xendit-pr-template-code branch from aec75ce to dce0ac6 Compare January 13, 2025 10:48
@awasthi21 awasthi21 force-pushed the 7964-featconnector-xendit-pr-template-code branch from 0d814be to fc571f4 Compare January 15, 2025 06:11
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 15, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 15, 2025
billing: billing_details,
},
setup_future_usage: "off_session",
customer_acceptance: customer_acceptance,
Copy link
Member

Choose a reason for hiding this comment

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

can you make every variable camelCase just so that we follow a single convention rather than having a mixture of different conventions?

Comment on lines 533 to 537
status: 501,
body: {
error: {
type: "invalid_request",
message: "Cancel/Void flow is not supported",
Copy link
Member

Choose a reason for hiding this comment

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

501 is not implemented error, right? or, is this expected to be a 4xx?

if this is being thrown from backend, then, i feel, it is wrong, we're supposed to throw a 4xx if not supported.

correct me if wrong.

Comment on lines 530 to 538
VoidAfterConfirm: {
Request: {},
Response: {
status: 501,
status: 400,
body: {
error: {
type: "invalid_request",
message: "Cancel/Void flow is not supported",
code: "IR_00",
code: "IR_19",
Copy link
Member

Choose a reason for hiding this comment

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

please verify this once.

@awasthi21 awasthi21 force-pushed the 7964-featconnector-xendit-pr-template-code branch from e81c6e4 to 6a0291e Compare January 15, 2025 07:17
Comment on lines +530 to +542
VoidAfterConfirm: {
Request: {},
Response: {
status: 400,
body: {
error: {
type: "invalid_request",
message: "Cancel/Void flow is not supported",
code: "IR_19",
},
},
},
},
Copy link
Member

Choose a reason for hiding this comment

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

@likhinbopanna, we should take this up in the coming days and put this under getCustomExchange

@likhinbopanna likhinbopanna added this pull request to the merge queue Jan 15, 2025
@awasthi21 awasthi21 requested review from sai-harsha-vardhan and removed request for likhinbopanna January 15, 2025 10:08
@awasthi21 awasthi21 disabled auto-merge January 15, 2025 10:15
Merged via the queue into main with commit bbf8844 Jan 15, 2025
17 of 19 checks passed
@likhinbopanna likhinbopanna deleted the 7964-featconnector-xendit-pr-template-code branch January 15, 2025 10:51
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.

6 participants