apigee / apigee-m10n-drupal

Add monetization features to a Drupal developer portal
https://www.drupal.org/project/apigee_m10n
GNU General Public License v2.0
13 stars 13 forks source link

INTERNAL: Cost received is non positive #402

Closed cen1 closed 10 months ago

cen1 commented 1 year ago

Description

When setting 0$ setup fee for the rate plan through API, the purchase through Drupal Portal fails with INTERNAL: Cost received is non positive

Example of rate plan:

{
  "name": "...",
  "apiproduct": "Test",
  "displayName": "Test",
  "billingPeriod": "MONTHLY",
  "currencyCode": "USD",
  "description": "test",
  "setupFee": {
    "currencyCode": "USD"
  },
  "state": "PUBLISHED",
  "startTime": "1661524015832"
}

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create plan as described above
  2. Purchase the plan through the API portal

Actual Behavior

Error

Expected Behavior

Plan is free so it should succeed

divya-intelli commented 1 year ago

Hi @cen1 , Is the error coming for ApigeeX or 4g? Please provide the Drupal error log also the outputcomposer show .

cen1 commented 1 year ago

There is no error log in drupal. It seems some kind of range check either inside m10n or perhaps commerce?

drupal/core                                    9.4.8        Drupal is an open source content management platform powering millions of websites and applications.
apigee/apigee-client-php                       2.0.16       Client library for connecting to the Apigee Edge API.
apigee/apigee-mock-client-php                  1.1.1        To be used for queueing mock API responses for the `apigee/apigee-client-php` library.
apigee/apigee_devportal_kickstart              2.1.0        A fast demo and starting point for Apigee Developer Portals.
drupal/apigee_api_catalog                      3.0.2        Apigee API Catalog for Drupal
drupal/apigee_edge                             2.0.5        Apigee Edge for Drupal.
drupal/apigee_m10n                             2.0.3        Apigee Edge Monetization for Drupal
Screenshot 2022-10-26 at 14 57 28
HiddenFennec commented 1 year ago

I was also getting this error. This is occurring because you may have checked the "Charge initialization fee" and set the value to zero like so:

image

The way I fixed the error, was by simply unchecking the "Charge initialization fee". I think this is a validation bug on the UI which leads to this drupal error. That being said, I think it should be fixed on the Drupal side, as you can possibly can also replicate the error (untested) via the API (https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.apiproducts.rateplans#RatePlan), by attaching an "Money" object in the setupFee, and setting the value in the object to 0 - therefore a UI fix in Apigee won't be enough.

divya-intelli commented 1 year ago

Thank you @HiddenFennec for identifying what is causing the issue. @cen1 please try unchecking the "Charge initialization fee" as mentioned by @HiddenFennec to see if it fixes the issue for you. @HiddenFennec if you have a fix for this issue, feel free to create a PR.

divya-intelli commented 10 months ago

@HiddenFennec @cen1 , we are able to replicate this issue and get back with a fix.

divya-intelli commented 10 months ago

@HiddenFennec , @cen1

When we set the Charge initialization fee as 0 and try to buy the rateplan, INTERNAL: Cost received is non positive error is thrown.
Unchecking Charge initialization fee, resolves the error. In Drupal we use the subscription API to buy a rateplan. An exception is thrown by Apigee if Charge initialization fee is set as 0.

Screenshot 2023-08-30 at 2 20 45 PM

Please create a support ticket in Apigee for this.

Closing this issue as the error is from Apigee.