hyperswitch
hyperswitch copied to clipboard
feat(router): add `merchant_business_country` field in apple pay `session_token_data`
Type of Change
- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
Merchant business country is mandatory field for confirming a apple pay payment. Till date we were expecting the billing country to be passed in the apple pay payment create call. Instead of collecting it is every payment create call this can be collected in the apple pay metadata while enabling apple pay for a specific connector (merchant connector account).
This pr also makes the billing country for apple pay as mandatory field (reverting the changes of https://github.com/juspay/hyperswitch/pull/3188). As merchant_business_country
is a mandatory field for confirming an apple pay payment.
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 MCA with apple pay metadata as shown below
{
"connector_type": "fiz_operations",
"connector_name": "stripe",
"business_country": "US",
"business_label": "default",
"connector_account_details": {
"auth_type": "HeaderKey",
"api_key": "api_key"
},
"test_mode": true,
"disabled": false,
"payment_methods_enabled": [
{
"payment_method": "wallet",
"payment_method_types": [
{
"payment_method_type": "apple_pay",
"payment_experience": "invoke_sdk_client",
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
},
{
"payment_method_type": "google_pay",
"payment_experience": "invoke_sdk_client",
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
}
],
"metadata": {
"apple_pay_combined": {
"manual": {
"session_token_data": {
"initiative": "web",
"certificate": "certificate",
"display_name": "applepay",
"certificate_keys": "certificate_keys",
"initiative_context": "initiative_context",
"merchant_identifier": "merchant_identifier",
"merchant_business_country": "merchant_business_country"
},
"payment_request_data": {
"label": "applepay",
"supported_networks": [
"visa",
"masterCard",
"amex",
"discover"
],
"merchant_capabilities": [
"supports3DS"
]
}
}
},
"google_pay": {
"merchant_info": {
"merchant_name": "Stripe"
},
"allowed_payment_methods": [
{
"type": "CARD",
"parameters": {
"allowed_auth_methods": [
"PAN_ONLY",
"CRYPTOGRAM_3DS"
],
"allowed_card_networks": [
"AMEX",
"DISCOVER",
"INTERAC",
"JCB",
"MASTERCARD",
"VISA"
]
},
"tokenization_specification": {
"type": "PAYMENT_GATEWAY",
"parameters": {
"gateway": "stripe",
"stripe:version": "2018-10-31",
"stripe:publishableKey": ""
}
}
}
]
}
}
}
Create a payment with confirm = false and without passing billing country
{
"amount": 650,
"currency": "USD",
"confirm": false,
"business_country": "US",
"business_label": "default",
"amount_to_capture": 650,
"customer_id": "custhype1232",
"capture_method": "automatic",
"capture_on": "2022-09-10T10:11:12Z",
"authentication_type": "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",
"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",
"first_name": "joseph",
"last_name": "Doe"
},
"phone": {
"number": "8056594427",
"country_code": "+91"
}
},
"payment_method_data": {
"wallet": {
"apple_pay": {
"payment_data":"payment_data",
"payment_method": {
"display_name": "Visa 0326",
"network": "Mastercard",
"type": "debit"
},
"transaction_identifier": "transaction_identifier"
}
}
}
}
Make a session token call with the payment_id and the client_secret in the above payment create response
{
"payment_id": "{{payment_id}}",
"wallets": [],
"client_secret": "{{client_secret}}"
}
Checklist
- [x] I formatted the code
cargo +nightly fmt --all
- [x] I addressed lints thrown by
cargo clippy
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a CHANGELOG entry if applicable