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): [CRYPTOPAY] Skip metadata serialization if none #4205

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

deepanshu-iiitu
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu commented Mar 26, 2024

Type of Change

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

Description

Serialization of the metadata field in the payments request for cryptopay is skipped if the metadata is set to none.

Additional Changes

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

Motivation and Context

#4206

How did you test it?

Testing can be done by creating a payment on cryptopay without passing metadata.
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": 120,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "customer_id": "custo",
    "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://google.com",
    "payment_method": "crypto",
    "payment_method_type": "crypto_currency",
    "payment_experience": "redirect_to_url",
    "payment_method_data": {
        "crypto": {
            "pay_currency": "XRP"
        }
    },
    "billing": {
        "address": {
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "order_details": [
        {
            "product_name": "test",
            "quantity": 1,
            "amount": 10
        }
    ],
    "business_label": "food",
    "business_country": "US"
}'

Response:

{
    "payment_id": "pay_CGNbknmiHZpwFIpXxYEP",
    "merchant_id": "merchant_1711445841",
    "status": "requires_customer_action",
    "amount": 120,
    "net_amount": 120,
    "amount_capturable": 120,
    "amount_received": null,
    "connector": "cryptopay",
    "client_secret": "pay_CGNbknmiHZpwFIpXxYEP_secret_CHuPxEbvvxOHqZR4MffY",
    "created": "2024-03-26T13:10:16.409Z",
    "currency": "USD",
    "customer_id": "custo",
    "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": "crypto",
    "payment_method_data": {
        "crypto": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": null,
            "country": "US",
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": null,
            "state": null,
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "order_details": [
        {
            "brand": null,
            "amount": 10,
            "category": null,
            "quantity": 1,
            "product_id": null,
            "product_name": "test",
            "product_type": null,
            "product_img_link": null,
            "requires_shipping": null
        }
    ],
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_CGNbknmiHZpwFIpXxYEP/merchant_1711445841/pay_CGNbknmiHZpwFIpXxYEP_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": "redirect_to_url",
    "payment_method_type": "crypto_currency",
    "connector_label": "cryptopay_US_food",
    "business_country": "US",
    "business_label": "food",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "custo",
        "created_at": ******,
        "expires": ******,
        "secret": "******"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "******",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_CGNbknmiHZpwFIpXxYEP_1",
    "payment_link": null,
    "profile_id": "pro_lCUrUVlcPzzcxNNyiMyg",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_B5Na72Sn8INfhxPv1FIz",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-03-26T13:25:16.409Z",
    "fingerprint": null,
    "payment_method_id": null,
    "payment_method_status": 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
  • I added a CHANGELOG entry if applicable

@deepanshu-iiitu deepanshu-iiitu self-assigned this Mar 26, 2024
@deepanshu-iiitu deepanshu-iiitu requested a review from a team as a code owner March 26, 2024 13:36
@deepanshu-iiitu deepanshu-iiitu added A-connector-integration Area: Connector integration C-bug Category: Bug labels Mar 26, 2024
@deepanshu-iiitu deepanshu-iiitu linked an issue Mar 26, 2024 that may be closed by this pull request
2 tasks
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Mar 26, 2024
Merged via the queue into main with commit 0429399 Mar 26, 2024
15 of 18 checks passed
@Gnanasundari24 Gnanasundari24 deleted the cryptopay-meta-fix branch March 26, 2024 14:34
pixincreate added a commit that referenced this pull request Apr 1, 2024
* 'main' of github.com:juspay/hyperswitch:
  refactor(core): removed the processing status for payment_method_status (#4213)
  docs(README): remove link to outdated early access form
  build(deps): bump `error-stack` from version `0.3.1` to `0.4.1` (#4188)
  chore(version): 2024.04.01.0
  feat(mandates): allow off-session payments using `payment_method_id` (#4132)
  ci(CI-pr): determine modified crates more deterministically (#4233)
  chore(config): add billwerk base URL in deployment configs (#4243)
  feat(payment_method): API to list countries and currencies supported by a country and payment method type (#4126)
  chore(version): 2024.03.28.0
  refactor(config): allow wildcard origin for development and Docker Compose setups (#4231)
  fix(core): Amount capturable remain same for `processing` status in capture (#4229)
  fix(euclid_wasm): checkout wasm metadata issue (#4198)
  fix(trustpay): [Trustpay] Add error code mapping '800.100.100'  (#4224)
  feat(connector): [billwerk] add connector template code (#4123)
  fix(connectors): fix wallet token deserialization error  (#4133)
  fix(log): adding span metadata to `tokio` spawned futures (#4118)
  chore(version): 2024.03.27.0
  fix(connector): [CRYPTOPAY] Skip metadata serialization if none (#4205)
  fix(connector): [Trustpay] fix deserialization error for incoming webhook response for trustpay and add error code mapping '800.100.203' (#4199)
  fix(core): make eci in AuthenticationData optional (#4187)
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] [CRYPTOPAY] Payments failing due to missing metadata
5 participants