Skip to content

Commit d59c2fa

Browse files
refactor(connector): [BRAINTREE] Pass email in payment requests (#7591)
1 parent 4d57f5e commit d59c2fa

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs

+31
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,20 @@ impl TryFrom<&Option<pii::SecretSerdeValue>> for BraintreeMeta {
204204
}
205205
}
206206

207+
#[derive(Debug, Serialize)]
208+
#[serde(rename_all = "camelCase")]
209+
pub struct CustomerBody {
210+
email: pii::Email,
211+
}
212+
207213
#[derive(Debug, Serialize)]
208214
#[serde(rename_all = "camelCase")]
209215
pub struct RegularTransactionBody {
210216
amount: StringMajorUnit,
211217
merchant_account_id: Secret<String>,
212218
channel: String,
219+
#[serde(skip_serializing_if = "Option::is_none")]
220+
customer_details: Option<CustomerBody>,
213221
}
214222

215223
#[derive(Debug, Serialize)]
@@ -218,6 +226,8 @@ pub struct VaultTransactionBody {
218226
amount: StringMajorUnit,
219227
merchant_account_id: Secret<String>,
220228
vault_payment_method_after_transacting: TransactionTiming,
229+
#[serde(skip_serializing_if = "Option::is_none")]
230+
customer_details: Option<CustomerBody>,
221231
}
222232

223233
#[derive(Debug, Serialize)]
@@ -257,6 +267,7 @@ impl
257267
amount: item.amount.to_owned(),
258268
merchant_account_id: metadata.merchant_account_id,
259269
channel: CHANNEL_CODE.to_string(),
270+
customer_details: None,
260271
}),
261272
);
262273
Ok(Self {
@@ -1745,6 +1756,11 @@ impl
17451756
vault_payment_method_after_transacting: TransactionTiming {
17461757
when: "ALWAYS".to_string(),
17471758
},
1759+
customer_details: item
1760+
.router_data
1761+
.get_billing_email()
1762+
.ok()
1763+
.map(|email| CustomerBody { email }),
17481764
}),
17491765
)
17501766
} else {
@@ -1757,6 +1773,11 @@ impl
17571773
amount: item.amount.to_owned(),
17581774
merchant_account_id: metadata.merchant_account_id,
17591775
channel: CHANNEL_CODE.to_string(),
1776+
customer_details: item
1777+
.router_data
1778+
.get_billing_email()
1779+
.ok()
1780+
.map(|email| CustomerBody { email }),
17601781
}),
17611782
)
17621783
};
@@ -1844,6 +1865,11 @@ impl TryFrom<&BraintreeRouterData<&types::PaymentsCompleteAuthorizeRouterData>>
18441865
vault_payment_method_after_transacting: TransactionTiming {
18451866
when: "ALWAYS".to_string(),
18461867
},
1868+
customer_details: item
1869+
.router_data
1870+
.get_billing_email()
1871+
.ok()
1872+
.map(|email| CustomerBody { email }),
18471873
}),
18481874
)
18491875
} else {
@@ -1856,6 +1882,11 @@ impl TryFrom<&BraintreeRouterData<&types::PaymentsCompleteAuthorizeRouterData>>
18561882
amount: item.amount.to_owned(),
18571883
merchant_account_id: metadata.merchant_account_id,
18581884
channel: CHANNEL_CODE.to_string(),
1885+
customer_details: item
1886+
.router_data
1887+
.get_billing_email()
1888+
.ok()
1889+
.map(|email| CustomerBody { email }),
18591890
}),
18601891
)
18611892
};

0 commit comments

Comments
 (0)