Skip to content
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

Merged
merged 8 commits into from
Nov 21, 2023

Conversation

Sakilmostak
Copy link
Contributor

@Sakilmostak Sakilmostak commented Nov 20, 2023

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

  • Card token is being saved in metadata to later use for refund
  • Void flow have been removed with prophetpay doesn't have capture
  • Refactor of Rsync
  • Minor refactor for the comments given in previous PR for prophetpay

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

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

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

@Sakilmostak Sakilmostak added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor labels Nov 20, 2023
@Sakilmostak Sakilmostak self-assigned this Nov 20, 2023
@Sakilmostak Sakilmostak requested a review from a team as a code owner November 20, 2023 17:43
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res)
}
// fn get_headers(
Copy link
Contributor

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(
Copy link
Contributor

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),
Copy link
Contributor

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),
Copy link
Contributor

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,
Copy link
Contributor

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(),
Copy link
Contributor

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

Copy link
Contributor Author

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),
Copy link
Contributor

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

Copy link
Contributor Author

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),
Copy link
Contributor

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),
Copy link
Contributor

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

@ArjunKarthik ArjunKarthik added the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Nov 21, 2023
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(),
Copy link
Contributor

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

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 21, 2023
Merged via the queue into main with commit 15a255e Nov 21, 2023
@Gnanasundari24 Gnanasundari24 deleted the prop_pay_add branch November 21, 2023 16:11
@SanchithHegde SanchithHegde removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement C-refactor Category: Refactor
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

5 participants