-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(connector): [AFFIRM] BNPL flow added (Alpha) #8795
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
Conversation
47866b1 to
21aa4e2
Compare
| fn extract_metadata(raw: &Value) -> Option<Metadata> { | ||
| Some(Metadata { | ||
| shipping_type: get_str("shipping_type", raw), | ||
| entity_name: get_str("entity_name", raw), | ||
| platform_type: get_str("platform_type", raw), | ||
| platform_version: get_str("platform_version", raw), | ||
| platform_affirm: get_str("platform_affirm", raw), | ||
| webhook_session_id: get_str("webhook_session_id", raw), | ||
| mode: get_str("mode", raw), | ||
| customer: raw.get("customer").cloned(), | ||
| itinerary: raw.get("itinerary").and_then(|v| v.as_array().cloned()), | ||
| checkout_channel_type: get_str("checkout_channel_type", raw), | ||
| bopis: get_bool("BOPIS", raw), | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need all these values in metadata?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metadata is an optional field in connector's API contract, I used HS metadata to populate these values. Should I remove this field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the optional fields
| let billing = item | ||
| .router_data | ||
| .get_optional_billing() | ||
| .and_then(|billing_address| { | ||
| billing_address.address.as_ref().map(|address| Billing { | ||
| name: Name { | ||
| first: address.first_name.clone(), | ||
| last: address.last_name.clone(), | ||
| full: address.get_optional_full_name(), | ||
| }, | ||
| address: Address { | ||
| line1: address.line1.clone(), | ||
| line2: address.line2.clone(), | ||
| city: address.city.clone(), | ||
| state: address.state.clone(), | ||
| zipcode: address.zip.clone(), | ||
| country: address.country, | ||
| }, | ||
| phone_number: billing_address | ||
| .phone | ||
| .as_ref() | ||
| .and_then(|phone| phone.number.as_ref().cloned()), | ||
| email: billing_address.email.clone(), | ||
| }) | ||
| }); | ||
|
|
||
| let shipping = item | ||
| .router_data | ||
| .get_optional_shipping() | ||
| .and_then(|shipping_address| { | ||
| shipping_address.address.as_ref().map(|address| Shipping { | ||
| name: Name { | ||
| first: address.first_name.clone(), | ||
| last: address.last_name.clone(), | ||
| full: address.get_optional_full_name(), | ||
| }, | ||
| address: Address { | ||
| line1: address.line1.clone(), | ||
| line2: address.line2.clone(), | ||
| city: address.city.clone(), | ||
| state: address.state.clone(), | ||
| zipcode: address.zip.clone(), | ||
| country: address.country, | ||
| }, | ||
| phone_number: shipping_address | ||
| .phone | ||
| .as_ref() | ||
| .and_then(|phone| phone.number.as_ref().cloned()), | ||
| email: shipping_address.email.clone(), | ||
| }) | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any of these fields is mandatory please add them in crates/payment_methods/src/configs/payment_connector_required_fields.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the fields are optional https://docs.affirm.com/developers/reference/shipping-billing-object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use utils here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. get_optional_billing_line1
crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
Outdated
Show resolved
Hide resolved
crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
Outdated
Show resolved
Hide resolved
crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
Outdated
Show resolved
Hide resolved
crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
Outdated
Show resolved
Hide resolved
crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
Outdated
Show resolved
Hide resolved
| AffirmEventType::ExpireAuthorization | AffirmEventType::ExpireConfirmation => { | ||
| Self::AuthorizationFailed | ||
| } | ||
| AffirmEventType::Refund | AffirmEventType::RefundVoided => Self::AutoRefunded, |
Type of Change
Description
BNPL flow added for affirm connector.
Only added mock server for affirm and not cypress because BNPL is currently not supported in cypress.
Additional Changes
Motivation and Context
How did you test it?
This is an alpha connector, also cypress doen't support pay_later PMs as of now.
Checklist
cargo +nightly fmt --allcargo clippy