-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(connector): [Prophetpay] Save card token for Refund and remove Void flow #2927
Conversation
) -> CustomResult<ErrorResponse, errors::ConnectorError> { | ||
self.build_error_response(res) | ||
} | ||
// fn get_headers( |
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 multiline comment
// Ok(Some(prophetpay_req)) | ||
// } | ||
|
||
// fn build_request( |
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.
Keep the build_request method uncommented and throw errors::ConnectorError::NotImplemented with error message as "Void flow not implemented"
let connector_metadata = serde_json::to_value(card_token_data).ok(); | ||
|
||
Ok(Self { | ||
status: enums::AttemptStatus::from(item.response.response_text), |
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.
in case of payment failure we need to capture the error message, code and reason
item: types::ResponseRouterData<F, ProphetpaySyncResponse, T, types::PaymentsResponseData>, | ||
) -> Result<Self, Self::Error> { | ||
Ok(Self { | ||
status: enums::AttemptStatus::from(item.response.response_text), |
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.
in case of payment failure we need to capture the error message, code and reason
status: enums::AttemptStatus::from(item.response.response_text), | ||
response: Ok(types::PaymentsResponseData::TransactionResponse { | ||
resource_id: types::ResponseId::ConnectorTransactionId( | ||
item.response.transaction_id, |
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.
Are we getting same transaction_id in payments and retrieve payments?
@@ -435,8 +594,8 @@ impl TryFrom<&types::PaymentsCancelRouterData> for ProphetpayVoidRequest { | |||
let transaction_id = item.request.connector_transaction_id.to_owned(); | |||
Ok(Self { | |||
transaction_id, | |||
ref_info: item.attempt_id.to_owned(), | |||
inquiry_reference: format!("inquiry_{}", item.attempt_id), | |||
ref_info: item.connector_request_reference_id.to_owned(), |
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 payments api accepts same value for ref_info and inquiry_reference, then lets pass connector_request_reference_id in both 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.
No, ref_info and inquiry_reference cant have same value
card_token: card_token_data.card_token, | ||
profile: auth_data.profile_id, | ||
ref_info: item.router_data.request.refund_id.to_owned(), | ||
inquiry_reference: format!("inquiry_{}", item.router_data.request.refund_id), |
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 refunds api accepts same value for ref_info and inquiry_reference, then lets pass refund_id in both 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.
No, ref_info and inquiry_reference cant have the same value
response: Ok(types::RefundsResponseData { | ||
// no refund id is generated, rather transaction id is used for referring to status in refund also | ||
connector_refund_id: item.data.request.connector_transaction_id.clone(), | ||
refund_status: enums::RefundStatus::from(item.response.response_text), |
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.
incase of refund failure, capture error message, reason, code
@@ -520,17 +695,75 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, ProphetpayRefundResp | |||
Ok(Self { | |||
response: Ok(types::RefundsResponseData { | |||
// no refund id is generated, rather transaction id is used for referring to status in refund also | |||
connector_refund_id: item.data.request.connector_transaction_id.clone(), | |||
connector_refund_id: item.response.tran_seq_number, | |||
refund_status: enums::RefundStatus::from(item.response.response_text), |
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.
incase of refund failure, capture error message, reason, code
Ok(Self { | ||
response: Ok(types::RefundsResponseData { | ||
// no refund id is generated, rather transaction id is used for referring to status in refund also | ||
connector_refund_id: item.data.request.connector_transaction_id.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.
This will overwrite the tran_seq_number which we are setting in the refund flow. Keep the connector_refund_id here. Take this in separate PR
Type of Change
Description
Additional Changes
Motivation and Context
How did you test it?
Refund was not working before because card token was not stored to retrieve the payemnt, now both Refund and Rsync can be tested after making the payment.
These two are the scenario for the payments:
Success Case:
{ "amount": 10000, "currency": "USD", "confirm": true, "amount_to_capture": 10000, "business_country": "US", "customer_id": "custhype1232", "return_url": "https://www.google.com", "payment_method": "card_redirect", "payment_method_type": "card_redirect", "payment_method_data": { "card_redirect": { "card_redirect": {} } }, "routing": { "type": "single", "data": "prophetpay" } }
This will have the response as this after Psync:
{ "payment_id": "pay_IcWrOgd5iKOecC4sY9bH", "merchant_id": "merchant_1700580874", "status": "succeeded", "amount": 10000, "amount_capturable": 0, "amount_received": 10000, "connector": "prophetpay", "client_secret": "pay_IcWrOgd5iKOecC4sY9bH_secret_2pVdz9TgeocWDeNbQlJP", "created": "2023-11-21T15:37:23.172Z", "currency": "USD", "customer_id": "custhype1232", "description": null, "refunds": null, "disputes": null, "mandate_id": null, "mandate_data": null, "setup_future_usage": null, "off_session": null, "capture_on": null, "capture_method": null, "payment_method": "card_redirect", "payment_method_data": "card_redirect", "payment_token": null, "shipping": null, "billing": null, "order_details": null, "email": null, "name": null, "phone": null, "return_url": "https://www.google.com/", "authentication_type": null, "statement_descriptor_name": null, "statement_descriptor_suffix": null, "next_action": null, "cancellation_reason": null, "error_code": null, "error_message": null, "payment_experience": null, "payment_method_type": "card_redirect", "connector_label": "prophetpay_US_default", "business_country": "US", "business_label": "default", "business_sub_label": null, "allowed_payment_method_types": null, "ephemeral_key": null, "manual_retry_allowed": false, "connector_transaction_id": "2226270406", "frm_message": null, "metadata": null, "connector_metadata": null, "feature_metadata": null, "reference_id": null, "payment_link": null, "profile_id": "pro_ThBc5yMoyMfNM7A5UFyk", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_3DGrmnIoL1C1sxBiwbgY" }
Failure Case:
{ "amount": 3000, "currency": "USD", "confirm": true, "amount_to_capture": 3000, "business_country": "US", "customer_id": "custhype1232", "return_url": "https://www.google.com", "payment_method": "card_redirect", "payment_method_type": "card_redirect", "payment_method_data": { "card_redirect": { "card_redirect": {} } }, "routing": { "type": "single", "data": "prophetpay" } }
This will have the response as this after Psync:
{ "payment_id": "pay_tzos8jBhICTXIg7sV0EM", "merchant_id": "merchant_1700580874", "status": "failed", "amount": 3000, "amount_capturable": 0, "amount_received": null, "connector": "prophetpay", "client_secret": "pay_tzos8jBhICTXIg7sV0EM_secret_elchmW7r3lf7900110Fi", "created": "2023-11-21T15:34:47.070Z", "currency": "USD", "customer_id": "custhype1232", "description": null, "refunds": null, "disputes": null, "mandate_id": null, "mandate_data": null, "setup_future_usage": null, "off_session": null, "capture_on": null, "capture_method": null, "payment_method": "card_redirect", "payment_method_data": "card_redirect", "payment_token": null, "shipping": null, "billing": null, "order_details": null, "email": null, "name": null, "phone": null, "return_url": "https://www.google.com/", "authentication_type": null, "statement_descriptor_name": null, "statement_descriptor_suffix": null, "next_action": null, "cancellation_reason": null, "error_code": "1025", "error_message": "Transaction declined - call issuer", "payment_experience": null, "payment_method_type": "card_redirect", "connector_label": "prophetpay_US_default", "business_country": "US", "business_label": "default", "business_sub_label": null, "allowed_payment_method_types": null, "ephemeral_key": null, "manual_retry_allowed": true, "connector_transaction_id": null, "frm_message": null, "metadata": null, "connector_metadata": null, "feature_metadata": null, "reference_id": null, "payment_link": null, "profile_id": "pro_ThBc5yMoyMfNM7A5UFyk", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_3DGrmnIoL1C1sxBiwbgY" }
Checklist
cargo +nightly fmt --all
cargo clippy