Skip to content

Conversation

Anurag-05-prog
Copy link
Contributor

@Anurag-05-prog Anurag-05-prog commented Oct 10, 2025

Type of Change

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

Closes this issue

Description

Added Webhook Flow and Support for merchant_order_reference_id for Peachpayments

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?

  1. Set verify_webhook_source to true
async fn verify_webhook_source(
    &self,
    _request: &webhooks::IncomingWebhookRequestDetails<'_>,
    _merchant_id: &id_type::MerchantId,
    _connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,
    _connector_account_details: common_utils::crypto::Encryptable<Secret<serde_json::Value>>,
    _connector_name: &str,
) -> CustomResult<bool, errors::ConnectorError> {
    Ok(true)
}
  1. Host localhost in ngork and run this curl:
curl --location '{{ngrokUrl}}/webhooks/:mid/:mca' \
--header 'Content-Type: application/json' \
--data-raw '{
  "rule": {},
  "webhookId": "000a262d-6eb9-425e-8f58-a659a771f11a",
  "transaction": {
    "referenceId": "pay_CyHp5Gty8N6y7bGBtznE_1",
    "responseCode": {
      "value": "00",
      "description": "Approved or completed successfully",
      "explanation": "Transaction approved by acquirer or issuer. Other factors may impact the final outcome of the transaction.",
      "receiptString": "Approved",
      "isoCodeDescription": "Approved or completed successfully",
      "terminalOutcomeString": "Approved"
    },
    "paymentMethod": "ecommerce_card_payment_only",
    "transactionId": "b5438722-06c9-4f44-b8d7-9d3d5768098f",
    "transactionTime": "2025-10-10T02:16:15.562551Z",
    "transactionType": {
      "value": 0,
      "description": "Goods and Services"
    },
    "transactionResult": "approved_confirmed",
    "voidableUntilTime": "2025-10-10T22:00:00Z",
    "cardNotPresentRefundableStatus": "not_refundable",
    "ecommerceCardPaymentOnlyTransactionData": {
      "rrn": "711184317168",
      "card": {
        "scheme": "Visa",
        "binNumber": "400000",
        "maskedPan": "400000******0446",
        "expiryYear": "26",
        "expiryMonth": "12",
        "cardholderName": "joseph Doe"
      },
      "stan": "573152",
      "amount": {
        "amount": 200,
        "currencyCode": "ZAR",
        "displayValue": "R2.00"
      },
      "traceId": "001760062576462",
      "approvalCode": "863244",
      "settlementDate": "2025-10-10"
    }
  },
  "webhookTime": "2025-10-10T02:16:30.882493869Z",
  "webhookType": "transaction"
}'

Response:

200 OK Status

Incoming Webhook Screenshot:

Screenshot 2025-10-13 at 1 13 33 PM

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

@Anurag-05-prog Anurag-05-prog self-assigned this Oct 10, 2025
@Anurag-05-prog Anurag-05-prog requested a review from a team as a code owner October 10, 2025 03:49
Copy link

semanticdiff-com bot commented Oct 10, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/peachpayments.rs  6% smaller
  crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs  0% smaller

routing,
card,
amount,
rrn: item.router_data.request.merchant_order_reference_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.

Why are we not using connector_request_reference_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have confirmed with Peach team that rrn is a field which merchant will send per transaction.

pub error_message: Option<String>,
pub response_code: Option<ResponseCode>,
pub ecommerce_card_payment_only_transaction_data: Option<EcommerceCardPaymentOnlyResponseData>,
pub payment_method: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be secret?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it a secret field.

Ok(api_models::webhooks::IncomingWebhookEvent::PaymentIntentSuccess)
}
peachpayments::PeachpaymentsPaymentStatus::Pending
| peachpayments::PeachpaymentsPaymentStatus::Authorized
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is authorized marked as processing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it.

request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
let webhook_body: peachpayments::PeachpaymentsIncomingWebhook = request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modify psync response so that it can handle webhook response as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Peachpayments: Add Webhook Flow and Support For Merchant_Order_Reference_Id

2 participants