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

feat(connector): [Iatapay] add upi qr support #4728

Merged
merged 21 commits into from
May 28, 2024
Merged

feat(connector): [Iatapay] add upi qr support #4728

merged 21 commits into from
May 28, 2024

Conversation

AkshayaFoiger
Copy link
Contributor

@AkshayaFoiger AkshayaFoiger commented May 22, 2024

Type of Change

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

Description

This PR introduces a new payment_method_type: upi_intent and a new payment_method_data: upi_qr: {} along with iatapay qr code implementation.

Additional Changes

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

How did you test it?

Note:Test through stripe compatibility layer

  1. Create a upi qr payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_ZLiIlOCsh5GUTiRJCCSc6lOIXpo0tTGuROyxvZokpKSIl5Lh5mCYwBB9IZV3Jno2' \
--data-raw '{
    "amount": 5000,
    "currency": "INR",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 5000,
    "customer_id": "IatapayCustomer",
    "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": "upi",
    "payment_method_type": "upi_intent",
    "payment_method_data": {
        "upi": {
            "upi_intent": {
                
            }
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IN",
            "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"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

Response

{
    "payment_id": "pay_ZBLXkfFi0wcdBPrQkKPL",
    "merchant_id": "merchant_1716310637",
    "status": "requires_customer_action",
    "amount": 5000,
    "net_amount": 5000,
    "amount_capturable": 5000,
    "amount_received": null,
    "connector": "iatapay",
    "client_secret": "pay_ZBLXkfFi0wcdBPrQkKPL_secret_YYAnlcRyF7ZX3r82WtjL",
    "created": "2024-05-22T10:04:05.468Z",
    "currency": "INR",
    "customer_id": "IatapayCustomer",
    "customer": {
        "id": "IatapayCustomer",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "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": "upi",
    "payment_method_data": {
        "upi": {},
        "billing": null
    },
    "payment_token": null,
    "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": "IN",
            "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": "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": "fetch_qr_code_information",
        "qr_code_fetch_url": "https://sandbox.iata-pay.iata.org/api/v1/payments/PJHE6F45O1D7M/checkout/api/qr"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "upi_intent",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "IatapayCustomer",
        "created_at": 1716372245,
        "expires": 1716375845,
        "secret": "epk_41f95816c9844c2e9c8672ec5bc91d65"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "P1D74RYCPET6J",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_ZBLXkfFi0wcdBPrQkKPL_1",
    "payment_link": null,
    "profile_id": "pro_aqLkyMdeFcYrp3v3yPd8",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_nLDpyk2OF9mrlivQTJnS",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-22T10:19:05.468Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-05-22T10:04:08.642Z",
    "frm_metadata": null
}
  1. Create a upi payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:""' \
--data-raw '{
    "amount": 5000,
    "currency": "INR",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 5000,
    "customer_id": "IatapayCustomer",
    "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": "upi",
    "payment_method_type": "upi_collect",
    "payment_method_data": {
        "upi": {
            "upi_collect": {
                  "vpa_id": "successtest@ita"
            }
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IN",
            "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"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

Response

{
    "payment_id": "pay_VfMfCw7jxtbHNc5xvF4Z",
    "merchant_id": "merchant_1716310637",
    "status": "requires_customer_action",
    "amount": 5000,
    "net_amount": 5000,
    "amount_capturable": 5000,
    "amount_received": null,
    "connector": "iatapay",
    "client_secret": "pay_VfMfCw7jxtbHNc5xvF4Z_secret_lMsdWF0m50OBBvxe1fl7",
    "created": "2024-05-22T09:54:19.813Z",
    "currency": "INR",
    "customer_id": "IatapayCustomer",
    "customer": {
        "id": "IatapayCustomer",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "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": "upi",
    "payment_method_data": {
        "upi": {},
        "billing": null
    },
    "payment_token": null,
    "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": "IN",
            "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": "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_VfMfCw7jxtbHNc5xvF4Z/merchant_1716310637/pay_VfMfCw7jxtbHNc5xvF4Z_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "upi_collect",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "IatapayCustomer",
        "created_at": 1716371659,
        "expires": 1716375259,
        "secret": "epk_7bb67ee9c3304c8a9458ba6ef2488225"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "P46Y265SXCTXZ",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_VfMfCw7jxtbHNc5xvF4Z_1",
    "payment_link": null,
    "profile_id": "pro_aqLkyMdeFcYrp3v3yPd8",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_nLDpyk2OF9mrlivQTJnS",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-22T10:09:19.813Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-05-22T09:54:21.635Z",
    "frm_metadata": null
}

Stimulate Terminal status (for Failed - FAILED)

curl --location --request PUT 'https://sandbox.iata-pay.iata.org/api/v2/payments/P50G9SL4HD0A7/simulate' \
--header 'Content-Type: application/json' \
--header 'Authorization:  access_token' \
--data '{
    "status": "SETTLED"
}'

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

@AkshayaFoiger AkshayaFoiger requested review from a team as code owners May 22, 2024 10:09
@AkshayaFoiger AkshayaFoiger added A-connector-compatibility Area: Connector compatibility A-connector-integration Area: Connector integration labels May 22, 2024
@AkshayaFoiger AkshayaFoiger self-assigned this May 22, 2024
@AkshayaFoiger AkshayaFoiger linked an issue May 22, 2024 that may be closed by this pull request
2 tasks
SamraatBansal
SamraatBansal previously approved these changes May 26, 2024
Copy link
Contributor

@SamraatBansal SamraatBansal left a comment

Choose a reason for hiding this comment

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

LGTM!

Chethan-rao
Chethan-rao previously approved these changes May 27, 2024
Copy link
Contributor

@Chethan-rao Chethan-rao left a comment

Choose a reason for hiding this comment

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

Routing specific changes LGTM

sahkal
sahkal previously approved these changes May 27, 2024
SamraatBansal
SamraatBansal previously approved these changes May 27, 2024
@@ -308,6 +310,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::ApplepayConnectorMetadataRequest,
api_models::payments::SessionTokenInfo,
api_models::payments::SwishQrData,
api_models::payments::UpiData,
Copy link
Contributor

Choose a reason for hiding this comment

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

UpiData is already there

@SamraatBansal SamraatBansal dismissed stale reviews from sahkal, Chethan-rao, and themself via a81a6a3 May 27, 2024 10:49
SamraatBansal
SamraatBansal previously approved these changes May 27, 2024
sahkal
sahkal previously approved these changes May 27, 2024
@AkshayaFoiger AkshayaFoiger requested a review from Chethan-rao May 27, 2024 10:55
Chethan-rao
Chethan-rao previously approved these changes May 27, 2024
@AkshayaFoiger AkshayaFoiger dismissed stale reviews from Chethan-rao, sahkal, and SamraatBansal via 1df258f May 27, 2024 11:43
Comment on lines +292 to +299
pub enum UpiData {
UpiCollect(UpiCollectData),
UpiIntent(UpiIntentData),
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub struct UpiCollectData {
Copy link
Member

@Narayanbhat166 Narayanbhat166 May 27, 2024

Choose a reason for hiding this comment

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

we have changed a struct to enum, is this change backwards compatible? If this breaks existing api contract then this change cannot be made.

Copy link
Contributor Author

@AkshayaFoiger AkshayaFoiger May 27, 2024

Choose a reason for hiding this comment

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

@likhinbopanna likhinbopanna added this pull request to the merge queue May 28, 2024
Merged via the queue into main with commit c9fa94f May 28, 2024
10 checks passed
@likhinbopanna likhinbopanna deleted the iatapay/qr branch May 28, 2024 07:51
ghost pushed a commit that referenced this pull request May 29, 2024
…actor

* 'main' of github.com:juspay/hyperswitch: (39 commits)
  Fix(Cypress): Fixing 3DS payment failure in headless mode (#4807)
  feat(users): Add redis in Begin and Verify TOTP and create a new API that updates TOTP (#4765)
  refactor(connector): [Klarna] Refactor Authorize call and configs for prod (#4750)
  fix: implement StrongEq for Vec<u8> (#4795)
  refactor(core): move router data response and request models to hyperswitch domain models crate (#4789)
  chore(version): 2024.05.29.0
  refactor: retrieve extended card info config during business profile get call (#4784)
  refactor(payment_methods): add support for passing ttl to locker entries (#4690)
  feat(connector): [CRYPTOPAY] Pass network details in payment request (#4779)
  fix: include client columns in payment attempts response struct (#4761)
  fix(docker-compose): fix docker compose syntax (#4782)
  feat(connector): [Iatapay] add upi qr support (#4728)
  docs(analytics): Add documentation for setting up data services and enabling data features in control center (#4741)
  chore(version): 2024.05.28.0
  feat(connector): [AUTHORIZEDOTNET] Implement non-zero mandates (#4758)
  feat(core): [Paypal] Add session_token flow for Paypal sdk (#4697)
  chore(version): 2024.05.27.0
  chore: add missing migrations for recently added currencies (#4760)
  Refactor(core): Inclusion of constraint graph for merchant Payment Method list (#4626)
  chore(version): 2024.05.24.1
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-compatibility Area: Connector compatibility A-connector-integration Area: Connector integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] [Iatapay] add upi qr support
6 participants