Skip to content

feat(connector): [Peachpayments] Add Webhook Flow and Support For merchant_order_reference_id#9781

Merged
likhinbopanna merged 6 commits intomainfrom
peachpayments-webhook
Oct 15, 2025
Merged

feat(connector): [Peachpayments] Add Webhook Flow and Support For merchant_order_reference_id#9781
likhinbopanna merged 6 commits intomainfrom
peachpayments-webhook

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
@semanticdiff-com
Copy link

semanticdiff-com bot commented Oct 10, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs  28% smaller
  crates/hyperswitch_connectors/src/connectors/peachpayments.rs  7% smaller

AkshayaFoiger
AkshayaFoiger previously approved these changes Oct 14, 2025
Comment on lines +622 to +632
let payments_response = peachpayments::PeachpaymentsPaymentsResponse {
transaction_id: transaction.transaction_id.clone(),
response_code: transaction.response_code,
transaction_result: transaction.transaction_result,
ecommerce_card_payment_only_transaction_data: transaction
.ecommerce_card_payment_only_transaction_data,
original_transaction_id: transaction.original_transaction_id,
reference_id: Some(transaction.reference_id),
error_message: transaction.error_message,
payment_method: Some(transaction.payment_method),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of creating a new struct PeachpaymentsIncomingWebhook and then parsing it to PeachpaymentsPaymentsResponse

Make PeachpaymentsPaymentsResponse an enum with 2 structs 1 for payments and 1 for webhooks

Refere Adyen

Ok(Box::new(payments_response))
}

async fn verify_webhook_source(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have information on source_verification_algorithm for this connector?
If so, can we add implementations for get_webhook_source_verification_algorithm, get_webhook_source_verification_signature, and get_webhook_source_verification_message as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Peach doesn't support any algorithm as of now.

Comment on lines +672 to +675
pub original_transaction_id: Option<String>,
pub reference_id: Option<String>,
pub error_message: Option<String>,
pub payment_method: Option<Secret<String>>,
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 modifying the existing PeachpaymentsPaymentsData?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed, removing it

@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit 6394c89 Oct 15, 2025
24 of 30 checks passed
@likhinbopanna likhinbopanna deleted the peachpayments-webhook branch October 15, 2025 16:01
chaitak-gorai pushed a commit that referenced this pull request Oct 16, 2025
…chant_order_reference_id (#9781)

Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local>
Anurag-05-prog added a commit that referenced this pull request Oct 16, 2025
…chant_order_reference_id (#9781)

Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local>
drdholu pushed a commit to drdholu/hyperswitch that referenced this pull request Oct 30, 2025
…chant_order_reference_id (juspay#9781)

Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local>
aadityaguptaa pushed a commit that referenced this pull request Nov 10, 2025
…chant_order_reference_id (#9781)

Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local>
dipanshuhappy pushed a commit to dipanshuhappy/hyperswitch that referenced this pull request Dec 8, 2025
…chant_order_reference_id (juspay#9781)

Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local>
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

5 participants