-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(core): add ephemeral key to payment_create response when customer_id is mentioned #1133
Conversation
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, Eq, PartialEq)] | ||
pub struct EphemeralKeyCreateResponse { | ||
pub created_at: i64, | ||
pub expires: i64, | ||
pub secret: String, | ||
} |
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.
Ephemeral key is specific to one customer not I feel it's better to have it in the response json.
cc: @bernard-eugine
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.
You mean, we should only send EphemeralKey as a string in the response? without created_at and expires fields.
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.
@hrithikesh026 I meant we should add customerid in the response since it's only specific to that customer.
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.
EphemeralKeyCreateResponse
is a field in PaymentsResponse
, customer_id will be available in PaymentsResponse
.
Will it be okay to provide customer id at two different places ?
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.
Yeah @hrithikesh026 since it's specific to one customer I think it must be in that block of response itself
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.
I have made the above mentioned change.
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.
LGTM
@@ -0,0 +1,9 @@ | |||
use serde; | |||
|
|||
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, Eq, PartialEq)] |
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.
Add Toschema and comments explain the fields.
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.
@jarnura made the above mentioned changes
let ephemeral_key = match request.customer_id.clone() { | ||
Some(customer_id) => helpers::make_ephemeral_key( | ||
state, | ||
customer_id, | ||
merchant_account.merchant_id.clone(), | ||
) | ||
.await | ||
.ok() | ||
.and_then(|ek| { | ||
if let services::ApplicationResponse::Json(ek) = ek { | ||
Some(ek) | ||
} else { | ||
None | ||
} | ||
}), | ||
None => None, | ||
}; |
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.
We can use a separate function as get_ephemeral_key
and inside the function also use and_then
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.
@jarnura made the above mentioned changes
…eral_key function in PaymentCreate
Type of Change
Description
Added
ephemeral_key
field topayment_create
response(only payment create).Additional Changes
Motivation and Context
Through this change, merchant need not do a separate api call for ephemeral key after payment creation.
How did you test it?
manual
This is how payment create response would look after this change is merged.
Note
ephemeral_field
at the end.Checklist
cargo +nightly fmt --all
cargo clippy