microsoft / azure-api-management-monetization Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Following errors when running npm run build
:
#10 7.556 src/services/apimService.ts(133,34): error TS2339: Property 'id' does not exist on type 'unknown'.
#10 7.557 src/services/monetizationService.ts(14,54): error TS2339: Property 'find' does not exist on type 'unknown'.
In README :
deploy.ps1 -TenantId "" -SubscriptionId "" -ResourceGroupName "apimmonetization" -ResourceGroupLocation "uksouth" --ArtifactStorageAccountName "" => single dash, not double dash like this : -ArtifactStorageAccountName
In appservice.bicep and main.bicep :
Default App Service Plan SKU is put to F1 which doesn’t allow “Always on” hosting. Had to change to P1V3 to deploy the Web App.
For some reason the deployment only works if parameters appServiceName and apimServiceName have the same value. Otherwise it fails. Didn’t have the time to investigate why.
I'm not able to initialize the Stripe part with the stripeInitialisation.ps1 script
Output is the following:
Stripe CLI already installed.
{
"error": {
"code": "parameter_invalid_empty",
"doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-empty",
"message": "You passed an empty string for 'id'. We assume empty values are an attempt to unset a parameter; however 'id' cannot be unset. You should remove 'id' from your request or supply a non-empty value.",
"param": "id",
"type": "invalid_request_error"
}
}
Hi,
There's no validation on the form when creating a subscription and allows an empty subscription name. However, this creates an issue and does not allow the successful subscription creation on the APIM. Can this be rectified, please?
Thanks for the recent updates.
However the Billing app can't be deployed on my App Service:
Got this from the Docker logs
2021-06-30T08:45:48.068Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://ghcr.io/v2/microsoft/azure-api-management-monetization/app/manifests/latest: unauthorized"}
I followed all the instructions to deploy this demo, and everything ran successfully. I can see the products information both in APIM and Stripe. When I try to sign up to Developer Portal, I get redirected to the Web App and after entering any type of credentials and hitting the Sign-up button, I always get the "Invalid Credentials" error message
Looking at the Web App logs, I can see a 302 http code when the POST /signUp request is triggered. And this is the response url I get after hitting the Sign-up button:
https://app-apim-monetization.azurewebsites.net/apim-delegation?errorMessage=Invalid%20credentials&returnUrl=%2F&operation=SignUp&salt=DubYQ0sJC%2F8K3sAIc6TBw2PvW%2Bn4Uk4qD9TnZepMikM%3D&sig=0bkL1gQtCrJzqcC5Z7h1Ja1meewi9M%2Bl4ReSkqJhXdb3btZ1%2Bo0EpammjcyhqDiGuPMEvWELhhuX%2F2l0FFF7Sg%3D%3D
Can you please help me get this issue fixed?
I know it is because the resource group is under a specific subscription. I tried switching to that by saying "Select-AzSubscription -SubscriptionName '' but I still get the same error.
Here is the error:
Error:
(ResourceGroupNotFound) Resource group '[REDACTED RESOURCE GROUP NAME]' could not be found.
Code: ResourceGroupNotFound
Message: Resource group '[REDACTED RESOURCE GROUP NAME]' could not be found.
Could we instead have the subscription key also be added as a parameter for the script? This would make sure the resource group can be found. Just an idea, but would love any help.
A few thing I think we should fix/add:
--ArtifactStorageAccountName
"" (should be one dash).// The client secret for the service principal"
: rename "secret" to "password" (the idea is to match wording to avoid unnecessary confusion):{
"appId": "…",
"displayName": "alzaslon-sp",
"name": http://alzaslon-sp,
"password": "…",
"tenant": "…"
}
"checkoutSuccessfulUrl": {
"value": ""
},
"checkoutCancelledUrl": {
"value": ""
}
I am looking into integrating Azure API management with Stripe for Monetizing API's in our Organization. Is there any plans to update the billing web app code with latest Azure REST API's and libraries. Like I stumbled into @azure/ms-rest-nodeauth is deprecated and should be replaced with @azure/identity
I do not have developers who can take this up.
It will be really helpful if this code is updated with instructions to use it with existing Azure APIM which has Azure AD and B2C users and not use the Authentication (Sign-in & Sign-up) delegation but only use the product subscription delegation.
Hello, Looks like there's a bug in the stripeBillingService where the startingAfter = stripeSubscription.id never runs if usageUnits is 0 in the lines preceding. That line is critical to retrieve the next page of subscriptions from Stripe
This then a never ending loop. I think the startingAfter = stripeSubscription.id should be right at the beginning of the stripeSubscriptionListResponse.data.forEach function
Getting error when applying this:
$monetizationModels = Invoke-WebRequest -Uri $ApimGatewayUrl/billing/monetizationModels -Headers @{"Ocp-Apim-Subscription-Key"=$ApimSubscriptionKey} | ConvertFrom-Json
-or-
$apimProducts = Invoke-WebRequest -Uri $ApimGatewayUrl/billing/products -Headers @{"Ocp-Apim-Subscription-Key"=$ApimSubscriptionKey} | ConvertFrom-Json
Response status code does not indicate success: 301 (Moved Permanently)
I followed the stripe-deploy.md step by step, but I see the above error in the product page in stripe. Seems like an obvious typo somewhere. I'm wondering if anyone else has come across this bug and if there is a known fix for it?
some more details:
this seems to be the post body for this endpoint (POST /v1/prices)
{
""recurring": {
"interval": {
""": "month"
},
"usage_type": {
""": "licensed"
},
"interval_count": {
""": "1"
}
},
"product": ["basic"](https://dashboard.stripe.com/test/products/basic),
"currency": "usd",
"unit_amount_decimal": "1495"
}
Thanks
Documentation for creating a strip account references plans permissions when setting up an initialization key. In stripe-deploy.md
That setting is no longer available. Per stripes documentation; https://stripe.com/docs/api/plans. It has been replaced by the Prices API and "Should" be backwards compatible.
Unfortunately, I'm unable to deploy the solution, stuck with the following error:
{
"error":{
"code":"InvalidTemplate",
"message":"Deployment template validation failed: 'The template parameters 'checkoutSuccessfulUrl, checkoutCancelledUrl' in the parameters file are not valid; they are not present in the original template and can therefore not be provided at deployment time. The only supported parameters for this template are 'apimServiceName, apimPublisherEmail, apimPublisherName, apimSku, apimSkuCount, appServiceHostingPlanName, appServiceName, appServiceSkuName, appServiceSkuCapacity, paymentProvider, stripeApiKey, stripePublicKey, adyenApiKey, adyenClientKey, adyenMerchantAccount, appServiceContainerImage, appServiceContainerPort, servicePrincipalClientId, servicePrincipalObjectId, servicePrincipalClientSecret, servicePrincipalTenantId, location, artifactsBaseUrl'. Please see https://aka.ms/arm-deploy/#parameter-file for usage details.'.",
"additionalInfo":[
{
"type":"TemplateViolation",
"info":{
"lineNumber":0,
"linePosition":0,
"path":""
}
}
]
}
}
My parameters in the template:
"checkoutSuccessfulUrl": {
"value": https://localhost:3000/checkout/success
},
"checkoutCancelledUrl": {
"value": https://localhost:3000/checkout/cancelled
}
I assume these are webhooks in Stripe, so it would be awesome to provide information (in README file) on them, i.e. where to get those values for local and production environments.
Thanks for this demo app.
However the Billing app can't be deployed on my App Service:
Got this from the Docker logs
2021-11-14T16:52:54.689Z INFO - Pulling image: ghcr.io/microsoft/azure-api-management-monetization/app:latest
2021-11-14T16:52:56.888Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://ghcr.io/v2/microsoft/azure-api-management-monetization/app/manifests/latest: unauthorized"}
2021-11-14T16:52:56.890Z ERROR - Pull image threw Exception: Input string was not in a correct format.
2021-11-14T16:52:56.892Z INFO - Pulling image from Docker hub: ghcr.io/microsoft/azure-api-management-monetization/app:latest
2021-11-14T16:52:57.608Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://ghcr.io/v2/microsoft/azure-api-management-monetization/app/manifests/latest: unauthorized"}
2021-11-14T16:52:57.614Z WARN - Image pull failed. Defaulting to local copy if present.
2021-11-14T16:52:57.617Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2021-11-14T16:52:57.624Z INFO - Stopping site yukiapimpaymentproviderdemo because it failed during startup.
In strip-deploy.md, after creating a service principle, you are instructed to use the ```az ad sp show --id "" to get the object id. I was unable to find an object id in the response, went to the portal instead.
Hi!
What's the recommended workflow if one wants to modify a monetization model after the deployment?
E.g. for the Pro
product in Stripe, if I go to my Stripe console and modify the quota from 5000
to 10000
, do I have to redeploy or will things "just work"?
It seems much more intuitive that the APIM polls Stripe for latest monetization models of the products as opposed to looking into internally cached version of the monetizationModels.json
file that was used during the deployment?
The only piece of code that seems to rely on this file is here in stripe.ts:
const pricingModelType = monetizationModel.pricingModelType;
and it looks like the model type is thus the only bit that can't be modified post-hoc?
Or am I misunderstanding something here?
Would be good to have a README that discusses how to modify stuff after the deployment happened which I assume is a very common workflow.
I'm looking to use Stripe and APIM together, but would like to be able to offer a free trial prior to payment. Is there a recommended pattern for setting this up with APIM/Stripe?
Invoke-WebRequest: /home/sohrab/stripeInitialisation.ps1:76
Line |
76 | … ionModels = Invoke-WebRequest -Uri $ApimGatewayUrl/billing/monetizati …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Invalid URI: The hostname could not be parsed.
Hello, are there any plans to upgrade the Billing Portal App?
Using the current version seems is now broken and does not work. I am able to get the products registered but upon trying to Subscribe, users get a white screen like if its having issues with the Stripe checkout sessions, packages seem to be outdated, typscript errors.
Has anyone been able to get this workin recently?
The API Management is given Reader Role. What is the purpose of this role and where it is used.
resource apimManagedIdentityReaderRole 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
scope: resourceGroup()
name: guid(apiManagementService.id, readerRoleId)
properties: {
roleDefinitionId: readerRoleId
principalId: apiManagementService.identity.principalId
}
}
Asking this question because there is already a Service Principal which is given Contributor Role. The Billing web app authenticates to the API Management management API using this service principal to create/update the API Management subscription after checkout using APIM API's
resource servicePrincipalContributorRole 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
name: guid(resourceGroup().id, servicePrincipalObjectId, contributorRoleId)
scope: resourceGroup()
properties: {
roleDefinitionId: contributorRoleId
principalId: servicePrincipalObjectId
}
}
Hi,
It seems like the Azure Javascript SDK version (7.0.0) being used in this app for ARM API management has been retired.
https://learn.microsoft.com/en-us/azure/api-management/breaking-changes/api-version-retirement-sep-2023?WT.mc_id=Portal-Microsoft_Azure_Expert
I'm getting errors that look like this:
2023-10-23T23:41:17.533579576Z: [ERROR] (node:1) UnhandledPromiseRejectionWarning: Error: Failed to connect to Management endpoint Port 3443 at endpoint <app_name>.management.azure-api.net for the service.
2023-10-23T23:41:17.533596418Z: [ERROR] at new RestError (/usr/app/node_modules/@azure/ms-rest-js/dist/msRest.node.js:2469:28)
2023-10-23T23:41:17.533614762Z: [ERROR] at /usr/app/node_modules/@azure/ms-rest-js/dist/msRest.node.js:3671:37
2023-10-23T23:41:17.533621214Z: [ERROR] at runMicrotasks (<anonymous>)
2023-10-23T23:41:17.533625974Z: [ERROR] at processTicksAndRejections (internal/process/task_queues.js:95:5)
2023-10-23T23:41:17.533630712Z: [ERROR] (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 455236)
which causes an infinite loop every midnight when attempting to report Stripe billing.
Any assistance would be greatly appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.