Skip to content

Conversation

Aprabhat19
Copy link
Contributor

Type of Change

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

Description

add support to enable pm_data and pm_id in payments response

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?

  • Create a MA and a MCA
  • Create a Off session payment with Customer Acceptance
Create

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Mg6I2ovVxNBp6ZJmf84J2CPS3aDBtKeara9bYS08ep8h8PknW2S8yiprQGwmc4lQ' \
--data-raw '{
    "amount": 6777,
    "currency": "USD",
    "confirm": false,
    
    "customer_id": "new-c777",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
     "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
"setup_future_usage":"off_session",
    "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"
        }
    },

    "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": "8056594427",
            "country_code": "+91"
        }
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    }
}'
Confirm
curl --location 'http://localhost:8080/payments/pay_2iVBNXi0blHcB0tyjeMW/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Mg6I2ovVxNBp6ZJmf84J2CPS3aDBtKeara9bYS08ep8h8PknW2S8yiprQGwmc4lQ' \
--data '{
    "confirm": true,
    

        
          "payment_method": "card",
    "payment_method_type": "credit",




    "payment_method_data": {
        "card": {
            
            "card_number": "4111111111111111",
            
            
            "card_exp_month": "12",
            "card_exp_year": "2043",
            "card_holder_name": "Cy1",
            "card_cvc": "123"
        }
    },

        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "in sit",
                "user_agent": "amet irure esse"
            }
        }
  
}'
  • Create a off session payment with payment token
Create
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Mg6I2ovVxNBp6ZJmf84J2CPS3aDBtKeara9bYS08ep8h8PknW2S8yiprQGwmc4lQ' \
--data-raw '{
    "amount": 6777,
    "currency": "USD",
    "confirm": false,
    
    "customer_id": "new-c777",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
     "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    
"setup_future_usage":"off_session",
    "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"
        }
    },

    "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": "8056594427",
            "country_code": "+91"
        }
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    }
}'
Confirm

curl --location 'http://localhost:8080/payments/pay_2iVBNXi0blHcB0tyjeMW/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Mg6I2ovVxNBp6ZJmf84J2CPS3aDBtKeara9bYS08ep8h8PknW2S8yiprQGwmc4lQ' \
--data '{
    "confirm": true,     
          "payment_method": "card",
    "payment_method_type": "credit",
     "payment_token": "{{payment_token}}"

}'

  • Retrieve the Payment, the card details will be shown in the response
 Response
 
 {
    "payment_id": "pay_2iVBNXi0blHcB0tyjeMW",
    "merchant_id": "merchant_1716278979",
    "status": "succeeded",
    "amount": 6777,
    "net_amount": 6777,
    "amount_capturable": 0,
    "amount_received": 6777,
    "connector": "cybersource",
    "client_secret": "pay_2iVBNXi0blHcB0tyjeMW_secret_Chc0A7EDkeiAoqfbuFKU",
    "created": "2024-05-21T08:10:04.739Z",
    "currency": "USD",
    "customer_id": "new-c777",
    "customer": {
        "id": "new-c777",
        "name": "Joseph Doe",
        "email": "[email protected]",
        "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": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "2043",
            "card_holder_name": "Cy1",
            "payment_checks": {
                "avs_response": {
                    "code": "Y",
                    "codeRaw": "Y"
                },
                "card_verification": null
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_JHzGpIqfTEJ0zm0QNE8T",
    "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": "8056594427",
            "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": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "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": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "7162790289656608304951",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        }
    },
    "feature_metadata": null,
    "reference_id": "pay_2iVBNXi0blHcB0tyjeMW_1",
    "payment_link": null,
    "profile_id": "pro_3sd18D4q96QhAGUAI7K7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_tSrvrQbl3NvDlS9GkQdd",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-21T08:25:04.739Z",
    "fingerprint": null,
    "browser_info": {
        "language": null,
        "time_zone": null,
        "ip_address": "::1",
        "user_agent": null,
        "color_depth": null,
        "java_enabled": null,
        "screen_width": null,
        "accept_header": null,
        "screen_height": null,
        "java_script_enabled": null
    },
    "payment_method_id": "pm_UnNkHBpGbeX6pSecvsCt",
    "payment_method_status": "active",
    "updated": "2024-05-21T08:10:29.812Z",
    "frm_metadata": 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

@Aprabhat19 Aprabhat19 added A-core Area: Core flows C-refactor Category: Refactor labels May 21, 2024
@Aprabhat19 Aprabhat19 self-assigned this May 21, 2024
@Aprabhat19 Aprabhat19 requested a review from a team as a code owner May 21, 2024 08:22
@Aprabhat19 Aprabhat19 linked an issue May 21, 2024 that may be closed by this pull request
2 tasks
@Aprabhat19 Aprabhat19 changed the title reafactor(core): add support to enable pm_data and pm_id in payments response refactor(core): add support to enable pm_data and pm_id in payments response May 21, 2024
@Aprabhat19 Aprabhat19 requested a review from vspecky May 21, 2024 09:03
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 21, 2024
Merged via the queue into main with commit 2cd360e May 21, 2024
@Gnanasundari24 Gnanasundari24 deleted the show-pm_data_in_response branch May 21, 2024 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refcator] Refactor Payment Response to show the Payment Method Data
4 participants