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

fix(connector): [CYBERSOURCE] Handle HTML Error Response and add Descriptor field in ApplePay payments request #4451

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

deepanshu-iiitu
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu commented Apr 24, 2024

Type of Change

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

Description

Following connector audit changes are done for wallets for connector Cybersource:

  • paymentInformation.fluidData.descriptor is passed in apple pay payments request
  • HTML Error Response from connector is handled

Additional Changes

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

Motivation and Context

#4450

How did you test it?

Manual flow apple payments need to be tested via cybersource.
Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY_HERE' \
--data-raw '{
    "amount": 1900,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "food",
    
    "customer_id": "custhype1232",
    "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",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "apple_pay",
    "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"
        }
    },
    "payment_method_data": {
      "wallet": {
         "apple_pay": {
            "payment_data": "APPLE_PAY_TOKEN_HERE",
            "payment_method": {
               "display_name": "MasterCard 0839",
               "network": "MasterCard",
               "type": "credit"
            },
            "transaction_identifier": "47417dd24e81e22af0521800f4be217ee1d2424b513d39c10d3351dc849363a5"
         }
      }
   }
}
'

Response:

{
    "payment_id": "pay_blKSyuvXMdhAE8Sd2Kz3",
    "merchant_id": "merchant_1709635075",
    "status": "succeeded",
    "amount": 1900,
    "net_amount": 1900,
    "amount_capturable": 0,
    "amount_received": 1900,
    "connector": "cybersource",
    "client_secret": "pay_blKSyuvXMdhAE8Sd2Kz3_secret_VZtPAKUjXzo5wrZqGKuR",
    "created": "2024-04-24T10:57:50.791Z",
    "currency": "USD",
    "customer_id": "custhype1232",
    "customer": {
        "id": "custhype1232",
        "name": "Joseph Doe",
        "email": "something@gmail.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "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": "wallet",
    "payment_method_data": {
        "wallet": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": 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": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "apple_pay",
    "connector_label": "cybersource_US_food_default",
    "business_country": "US",
    "business_label": "food",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "custhype1232",
        "created_at": 1713956270,
        "expires": 1713959870,
        "secret": "epk_8a87d76cbb3c4958950df7a299f11102"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7139562721516032004951",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_blKSyuvXMdhAE8Sd2Kz3_1",
    "payment_link": null,
    "profile_id": "pro_dMJfhV51DYUbzCBKrQDw",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_IPBbnit5cjRQ3IpvfJ6o",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-04-24T11:12:50.790Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-04-24T10:57:54.088Z"
}
Screenshot 2024-04-24 at 4 34 45 PM

Bad Request Error(this cannot be tested on sbx):
Screenshot 2024-04-24 at 5 01 41 PM
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
  • I added a CHANGELOG entry if applicable

@deepanshu-iiitu deepanshu-iiitu added A-connector-integration Area: Connector integration C-bug Category: Bug labels Apr 24, 2024
@deepanshu-iiitu deepanshu-iiitu self-assigned this Apr 24, 2024
@deepanshu-iiitu deepanshu-iiitu requested a review from a team as a code owner April 24, 2024 10:50
@deepanshu-iiitu deepanshu-iiitu linked an issue Apr 24, 2024 that may be closed by this pull request
2 tasks
@deepanshu-iiitu deepanshu-iiitu changed the title fix(connector): [CYBERSOURCE] Audit wallets fix(connector): [CYBERSOURCE] Handle HTML Error Response and add descriptor field in apple pay payments request Apr 24, 2024
@deepanshu-iiitu deepanshu-iiitu changed the title fix(connector): [CYBERSOURCE] Handle HTML Error Response and add descriptor field in apple pay payments request fix(connector): [CYBERSOURCE] Handle HTML Error Response and add Descriptor field in ApplePay payments request Apr 24, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Apr 25, 2024
Merged via the queue into main with commit dbd3160 Apr 25, 2024
43 of 45 checks passed
@likhinbopanna likhinbopanna deleted the cyb-wallet-audit branch April 25, 2024 06:21
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 C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Audit Wallets for Cybersource
4 participants