Hi i'm trying to log the next variables of Apigee monetization : mint.mintng_rate_before_multipliers, mint.mintng_consumption_pricing_type and mint.mintng_rate.
I'm using a Service Callout policy attached in the post client flow with the next payload:
But the policy is executed before that the variables are populated:
Anybody knows if is possible log this 3 variables, thanks in advanced!
FYI: I'm checking the documentation of the next link: https://cloud.google.com/apigee/docs/api-platform/monetization/debug-trace
Can you confirm your ServiceCallout policy is in fact in the PostClientFlow?
These monetization (mint) variables are only readable in the PostClientFlow.
Yes I confirm that the Service Callout policy is in the PostClientFlow and the variables are readable in the PostClientFlow but they are not populated until the last milestone (proxy execution phase) and AX records, where I cannot set any policy therefore I always read empty variables.
Can you share your Proxy Endpoint configuration that shows the various flows you have set up. Also, please share the ServiceCallout policy XML.
For policies execution in the PostClientFlow, the policies are shown in Trace after the
'Response Sent to Client' task (pink circle), but before the AX step.
This the proxy endpoint configuration:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>VA-VerifyApiKey</Name>
</Step>
</Request>
<Response/>
</PreFlow>
<Flows>
<Flow name="DePaga">
<Description/>
<Request>
<Step>
<Name>AM-TransactionalValue</Name>
</Step>
<Step>
<Name>FC-Mint-Rateplans-Selector</Name>
</Step>
</Request>
<Response/>
<Condition>(proxy.pathsuffix MatchesPath "/image") and (request.verb = "GET")</Condition>
</Flow>
<Flow name="Gratuito">
<Description/>
<Request/>
<Response>
<Step>
<Name>FC-Mint-Not-Monetizable</Name>
</Step>
</Response>
<Condition>(proxy.pathsuffix MatchesPath "/uuid") and (request.verb = "GET")</Condition>
</Flow>
<Flow name="NotFound">
<Request>
<Step>
<Name>RF-NotFound</Name>
</Step>
</Request>
<Response/>
</Flow>
</Flows>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<PostClientFlow>
<Request/>
<Response>
<Step>
<Name>Service-Callout-1</Name>
</Step>
</Response>
</PostClientFlow>
<HTTPProxyConnection>
<BasePath>/uuid-generator</BasePath>
</HTTPProxyConnection>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
</ProxyEndpoint>
SC configuration:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout continueOnError="false" enabled="true" name="Service-Callout-1">
<DisplayName>Service Callout-1</DisplayName>
<Properties/>
<Request clearPayload="true" variable="myRequest">
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<Set>
<Headers>
<Header name="Accept">application/json</Header>
</Headers>
<Verb>POST</Verb>
<Payload contentType="application/json">{
"Data": {
"mintng_rate": {mint.mintng_rate},
"mintng_rate_before_multipliers": {mint.mintng_rate_before_multipliers},
"mintng_consumption_pricing_type": {mint.mintng_consumption_pricing_type}
}
}</Payload>
</Set>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</Request>
<Response>calloutResponse</Response>
<LocalTargetConnection>
<Path>/report-mint-v1/records</Path>
</LocalTargetConnection>
</ServiceCallout>
Is monetization working on your API request?
In the trace, can you see the mint variables set on your VerifyAPIKey as per this page
https://cloud.google.com/apigee/docs/api-platform/monetization/debug-trace
Yes is working:
But in specific we are looking for this variables: mint.mintng_rate, mint.mintng_rate_before_multipliers, mint.mintng_consumption_pricing_type which accord with the documentation are created in the PostClientFlow.
Documentation: https://cloud.google.com/apigee/docs/api-platform/reference/variables-reference#mint
So this is useful to confirm the transaction has been monetized in the first place.
Now, how has the rate plan been configured? Different settings will lead to different variables been set as well.
This is the rate plan configuration:
The variables mint.mintng_rate, mint.mintng_rate_before_multipliers, mint.mintng_consumption_pricing_type are populated after that my service callout policy is executed(I marked in red the point where the variables are populated), so when the SC policy is executed the variables are empty:
SC execution:
This is a known issue that the Monetization team is working to fix. Here's a message I captured using a Service Callout for logging to test. The values that are empty should be populated. The prefixes reflect the scope when the variable should be available (pr = Proxy Request, pcf = PostClientFlow, dc = Data Collector).
I also think these values should be available prior to PostClientFlow.
{
"pr.mint.limitscheck.is_request_blocked": "false",
"pr.mint.limitscheck.is_subscription_found": "true",
"pr.mint.limitscheck.purchased_product_name": "test-fees-develop",
"pr.mint.limitscheck.status_message": "limits_check_success",
"pcf.mint.mintng_consumption_pricing_rates": "",
"pcf.mint.mintng_consumption_pricing_type": "",
"dc.mint.mintng_currency": "USD",
"pcf.mint.mintng_dev_share": "",
"pr.mint.mintng_is_apiproduct_monetized": "true",
"dc.pcf.mint.mintng_price": "0.1",
"dc.pcf.mint.mintng_price_multiplier": "1",
"pcf.mint.mintng_rate": "",
"pcf.mint.mintng_rate_before_multipliers": "",
"pr.mint.mintng_rate_plan_id": "7d8ded22-2752-44b2-89ed-0b7e233dff79",
"pcf.mint.mintng_revenue_share_rates": "",
"pcf.mint.mintng_revenue_share_type": "",
"dc.mint.mintng_tx_success": "true",
"pr.mint.prepaid_developer_balance": "",
"pcf.mint.prepaid_developer_currency": "",
"pcf.mint.prepaid_updated_developer_usage": "",
"pr.mint.rateplan_end_time_ms": "",
"pcf.mint.status": "",
"pcf.mint.status_code": "",
"pr.mint.subscription_start_time_ms": "1674253744902",
"pr.mint.subscription_end_time_ms": "",
"pcf.mint.tx_success_result": ""
}