Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PaymentRequest - Custom Validation #175

Open
agendad opened this issue Oct 21, 2024 · 1 comment
Open

PaymentRequest - Custom Validation #175

agendad opened this issue Oct 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@agendad
Copy link

agendad commented Oct 21, 2024

Is your feature request related to a problem? Please describe.

We ran into an issue where successful PaymentRequests contained items with invalid vatPrecentage values that are not supported by the merchant of the WooCommerce site.

This was due to how we were handling negative fees in order to be compatible with Paytrail API. Apparently negative fees are now supported so this is no longer an issue.

We understand that Paytrail API validates vatPercentages between 0-100 and obviously has no idea what the merchant would like the vatPercentage to be.

Describe the solution you'd like

In order to avoid similar issues in future it would be helpful if it were possible to have a filter that allows the developer to validate the Paytrail\SDK\Request\PaymentRequest before it is sent to the Paytrail API.

In this instance, we would like to go through the items array and look for any vatPercentage values that do not align with WooCommerce settings. If there are any items with invalid vatPercentage, return false and display an error message at checkout without ever sending the PaymentRequest to the Paytrail API.

Additional context

Example Paytrail\SDK\Request\PaymentRequest JSON that has items containing invalid vatPercentage values.

{
  "stamp": "1-198100-1729244314",
  "reference": "198100",
  "amount": 2447,
  "currency": "EUR",
  "language": "EN",
  "items": [
    {
      "unitPrice": 2418,
      "units": 1,
      "vatPercentage": 34,
      "productCode": "1001",
      "description": "Test product 1",
      "stamp": "108"
    },
    {
      "unitPrice": 29,
      "units": 1,
      "vatPercentage": 0,
      "productCode": "rounding-row",
      "description": "Rounding"
    }
  ],
  "customer": {
    "email": "email@customer.com",
    "firstName": "Testiasiakas",
    "lastName": "Testaaja",
    "phone": "+35812345678",
    "companyName": "Test Company"
  },
  "invoicingAddress": {
    "streetAddress": "T\u00c4M\u00c4 ON TESTI TILAUS. EI TOIMITUSTA",
    "postalCode": "12600",
    "city": "Helsinki",
    "county": "",
    "country": "FI"
  },
  "redirectUrls": {
    "success": "https://staging.shop.fi/en/checkout/order-received/198100/?key=wc_order_hnxiUmOGq1mtp",
    "cancel": "https://staging.shop.fi/en/checkout/order-pay/198100/?pay_for_order=true&key=wc_order_hnxiUmOGq1mtp"
  },
  "callbackUrls": {
    "success": "https://staging.shop.fi/paytrail/callback/index",
    "cancel": "https://staging.shop.fi/paytrail/callback/index"
  },
  "callbackDelay": 3
}

@agendad agendad added the enhancement New feature or request label Oct 21, 2024
@kotivuori
Copy link
Collaborator

Thanks for reporting @agendad, we will look into this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants