hyperswitch
hyperswitch copied to clipboard
refactor: add payment_issuer and payment_experience in pa
Type of Change
- [x] New feature
Description
Add payment_issuer and payment_experience to payment_attempt table. The pay_later issuer will be decided based on this.
a small example of how this could and will be used.
if payment_issuer is klarna and payment_experience is redirect_to_url then klarna payment will be processed through stripe or any supported connector, but if the payment_experience is invoke_sdk_client then the payment will be processed through klarna which supports sdk.
Additional Changes
- [x] This PR modifies the database schema
Motivation and Context
#447 Not sure of how we will be handling the billing and shipping address. Currently billing details must be sent in payment_method_data the same way as stripes api.
How did you test it?
- Klarna
{
"payment_method": "pay_later",
"payment_issuer": "klarna",
"payment_experience": "redirect_to_url",
"payment_method_data": {
"pay_later": {
"klarna_redirect": {
"billing_email" : "[email protected]",
"billing_country": "US"
}
}
}
}

- Affirm
{
"payment_method": "pay_later",
"payment_issuer": "affirm",
"payment_experience": "redirect_to_url",
"payment_method_data": {
"pay_later": {
"affirm_redirect": {}
}
},
}

- AfterpayClearpay
{
"payment_issuer": "afterpay_clearpay",
"payment_experience": "redirect_to_url",
"payment_method_data": {
"pay_later": {
"afterpay_clearpay_redirect": {
"billing_email": "[email protected]",
"billing_name": "Example"
}
}
},
"shipping": {
"address": {
"first_name": "example",
"zip": "123456",
"line1": "New York",
"country": "US"
}
},
}

- Mismatched issuer, experience and payment_method_data
{
"payment_method": "pay_later",
"payment_issuer": "klarna",
"payment_experience": "redirect_to_url",
"payment_method_data": {
"pay_later": {
"affirm_redirect": {}
}
},
}

- Any missing fields, error will be thrown before being sent to the connector.
Checklist
- [x] I formatted the code
cargo +nightly fmt --all - [x] I addressed lints thrown by
cargo clippy - [x] I reviewed submitted code