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 #4207

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

Original PR: #4205
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": "[email protected]",
    "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": "[email protected]",
    "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 requested a review from a team as a code owner March 26, 2024 13:55
@deepanshu-iiitu deepanshu-iiitu self-assigned this Mar 26, 2024
@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
@deepanshu-iiitu deepanshu-iiitu linked an issue Mar 26, 2024 that may be closed by this pull request
2 tasks
@Gnanasundari24 Gnanasundari24 merged commit 7eaf488 into hotfix-2024.03.01.0 Mar 26, 2024
12 of 17 checks passed
@Gnanasundari24 Gnanasundari24 deleted the cryptopay-meta-hotfix branch March 26, 2024 14:41
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
4 participants