hyperswitch
hyperswitch copied to clipboard
feat(connector): add support for affirm and afterpay/clearpay through stripe
Feature Description
Add support for creating payments through affirm and afterpay/clearpay through stripe. The api contract changes will be as follows
- afterpay/clearpay
{
"payment_method": "pay_later",
"payment_method_data": {
"issuer_name": "afterpay_clearpay",
"afterpay_clearpay_redirect": {
"billing_email_address": "[email protected]"
}
}
}
- affirm
{
"payment_method": "pay_later",
"payment_method_data": {
"issuer_name": "affirm",
"affirm_redirect": {
"billing_email_address": "[email protected]"
}
}
}
Possible Implementation
Modify the payments request of stripe to include affirm and afterpay
Have you spent some time to check if this feature request has been raised before?
- [X] I checked and didn't find similar issue
Have you read the Contributing Guidelines?
- [X] I have read the Contributing Guidelines
Are you willing to submit a PR?
Yes I am willing to submit a PR!
- [X] Support for affirm #355
- [ ] Support for afterpay_clearpay
@Narayanbhat166 We can standardize the payment request body for redirection flows of applicable pay_later like affirm, afterpay and klarna:
- Include
email
as a field inside the address struct. Thus,billing_email
will be a field under billing field in Payments request. - Use the billing details required for pay_later redirection flow from the
billing_details
field passed outside thepayment_method_data
field in payments request body. Thus, we will avoid repetition of same fields in multiple places and also, this helps us avoid unnecessary usage of locker due to passing data in thepayment_method_data
field. - Use
payment_experience
field in payment request to indicate whether it is redirection or SDK flow.
Sample Payment Request with necessary fields for pay_later redirect experience:
{
"amount": 123,
"currency": "USD",
"payment_method": "pay_later",
"payment_method_issuer": "klarna",
"payment_experience": "redirect_to_url",
"billing": {
"name": "...",
"email": "...",
"address": "...",
"phone": "..."
},
"shipping": {
"name": "...",
"email": "...",
"address": "...",
"phone": "..."
}
}
There is an email
field in the payments request struct which was added by @zereraz when adding cybersource
connector. The same field can be used for email. But if a separate billing and shipping email is needed then it has to be added to the address struct.
Will take this up in a separate PR since it requires changes to all pay_later payments which go through stripe. Currently merging #441 will close this issue.