Skip to content

Commit

Permalink
Merge pull request #1 from KaveeshBaddage/master
Browse files Browse the repository at this point in the history
PDORNG - 1146 , Publish  Revenue data in Mobile Money Payments
  • Loading branch information
dsulochana authored Oct 8, 2020
2 parents 0d221de + b308d54 commit 1baafb6
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 4 deletions.
7 changes: 7 additions & 0 deletions bizao-revenue-publisher-capp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<com.apigate.bizao-revenue-publisher.template_._com.apigate.bizao.revenue.publish.call.Template>capp/EnterpriseServiceBus</com.apigate.bizao-revenue-publisher.template_._com.apigate.bizao.revenue.publish.call.Template>
<com.apigate.bizao-revenue-publisher.sequence_._com.apigate.bizao.revenue.publish.main.sequence>capp/EnterpriseServiceBus</com.apigate.bizao-revenue-publisher.sequence_._com.apigate.bizao.revenue.publish.main.sequence>
<artifact.types>jaggery/app=zip,synapse/priority-executor=xml,synapse/inbound-endpoint=xml,service/rule=aar,synapse/message-store=xml,event/stream=json,service/meta=xml,datasource/datasource=xml,synapse/proxy-service=xml,bpel/workflow=zip,synapse/sequence=xml,synapse/endpointTemplate=xml,carbon/application=car,wso2/gadget=dar,synapse/api=xml,synapse/event-source=xml,synapse/message-processors=xml,event/receiver=xml,lib/dataservice/validator=jar,synapse/template=xml,synapse/endpoint=xml,lib/carbon/ui=jar,lib/synapse/mediator=jar,event/publisher=xml,synapse/local-entry=xml,synapse/task=xml,webapp/jaxws=war,registry/resource=zip,synapse/configuration=xml,service/axis2=aar,synapse/lib=zip,synapse/sequenceTemplate=xml,event/execution-plan=siddhiql,service/dataservice=dbs,web/application=war,lib/library/bundle=jar</artifact.types>
<com.apigate.bizao-revenue-publisher.endpoint_._RevenuePublishEndpoint>capp/EnterpriseServiceBus</com.apigate.bizao-revenue-publisher.endpoint_._RevenuePublishEndpoint>
</properties>
<dependencies>
<dependency>
Expand All @@ -33,6 +34,12 @@
<version>1.0.0</version>
<type>xml</type>
</dependency>
<dependency>
<groupId>com.apigate.bizao-revenue-publisher.endpoint</groupId>
<artifactId>RevenuePublishEndpoint</artifactId>
<version>1.0.0</version>
<type>xml</type>
</dependency>
</dependencies>
<repositories>
<repository>
Expand Down
3 changes: 3 additions & 0 deletions bizao-revenue-publisher/artifact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
<artifact name="com.apigate.bizao.revenue.publish.call.Template" groupId="com.apigate.bizao-revenue-publisher.template" version="1.0.0" type="synapse/sequenceTemplate" serverRole="EnterpriseServiceBus">
<file>src/main/synapse-config/templates/com.apigate.bizao.revenue.publish.call.Template.xml</file>
</artifact>
<artifact name="RevenuePublishEndpoint" groupId="com.apigate.bizao-revenue-publisher.endpoint" version="1.0.0" type="synapse/endpoint" serverRole="EnterpriseServiceBus">
<file>src/main/synapse-config/endpoints/RevenuePublishEndpoint.xml</file>
</artifact>
</artifacts>
20 changes: 20 additions & 0 deletions bizao-revenue-publisher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@
</executions>
<configuration />
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-endpoint-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>endpoint</id>
<phase>process-resources</phase>
<goals>
<goal>pom-gen</goal>
</goals>
<configuration>
<artifactLocation>.</artifactLocation>
<typeList>${artifact.types}</typeList>
</configuration>
</execution>
</executions>
<configuration />
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-sequence-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<api context="/revenue" name="DataPublishAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence/>
<resource methods="POST" uri-template="/publish">
<inSequence>
<sequence key="com.apigate.bizao.revenue.publish.main.sequence"/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="RevenuePublishEndpoint" xmlns="http://ws.apache.org/ns/synapse">
<default>
<timeout>
<duration>30000</duration>
<responseAction>fault</responseAction>
</timeout>
<suspendOnFailure>
<errorCodes>-1</errorCodes>
<initialDuration>0</initialDuration>
<progressionFactor>1.0</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<errorCodes>-1</errorCodes>
</markForSuspension>
</default>
</endpoint>
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="com.apigate.bizao.revenue.publish.main.sequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse"/>
<sequence name="com.apigate.bizao.revenue.publish.main.sequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">

<log level="custom">
<property name="DIRECTION" value="REQUEST-IN"/>
<property name="APP" value="REVENUE-PUBLISH"/>
<property name="TRACE_ID" expression="$ctx:TRANSACTION_ID" scope="default" type="STRING"/>
<property name="COUNTRY_CODE" expression="json-eval($.county_code)" type="STRING" scope="default"/>
<property name="MNO_NAME" expression="json-eval($.mno_name)" type="STRING" scope="default"/>
<property name="ORDER_ID" expression="json-eval($.order_id)" type="STRING" scope="default"/>
<property name="AMOUNT" expression="json-eval($.amount)" type="STRING" scope="default"/>
<property name="PAYMENT_STATUS" expression="json-eval($.status)" type="STRING" scope="default"/>
</log>

<payloadFactory media-type="json">
<format>
{
"status":"published"
}
</format>
</payloadFactory>

<property name="HTTP_SC" value="201" scope="axis2" type="STRING"/>

<log level="custom">
<property name="DIRECTION" value="RESPONSE-OUT"/>
<property name="APP" value="REVENUE-PUBLISH"/>
<property name="TRACE_ID" expression="$ctx:TRANSACTION_ID" scope="default" type="STRING"/>
</log>

<respond/>

</sequence>
Original file line number Diff line number Diff line change
@@ -1,4 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<template name="com.apigate.bizao.revenue.publish.call.Template" xmlns="http://ws.apache.org/ns/synapse">
<sequence/>
<sequence>

<log level="custom">
<property name="DIRECTION" value="REQUEST-IN"/>
<property name="APP" value="REVENUE-CALL"/>
<property name="TRACE_ID" expression="$ctx:TRANSACTION_ID" scope="default" type="STRING"/>
<property name="COUNTRY_CODE" expression="$ctx:COUNTRY"/>
<property name="MNO_NAME" expression="$ctx:MNO"/>
<property name="ORDER_ID" expression="$ctx:ORDER_ID"/>
<property name="AMOUNT" expression="$ctx:AMOUNT"/>
<property name="PAYMENT_STATUS" expression="$ctx:PAYMENT_STATUS"/>
</log>

<payloadFactory media-type="json">
<format>
{
"type": "$1",
"county_code": "$2",
"mno_name": "$3",
"status": "$4",
"amount": "$5",
"order_id": "$6",
"currency": "$7",
"reference": "$8",
"date": "$9",
"state": "$10",
"intTransaction-id": "$11",
"extTransaction-id ": "$12",
"channel": "$13",
"service_provider": "$14"
}
</format>
<args>
<arg evaluator="xml" expression="$ctx:TYPE"/>
<arg evaluator="xml" expression="$ctx:COUNTRY"/>
<arg evaluator="xml" expression="$ctx:MNO"/>
<arg evaluator="xml" expression="$ctx:PAYMENT_STATUS"/>
<arg evaluator="xml" expression="$ctx:AMOUNT"/>
<arg evaluator="xml" expression="$ctx:ORDER_ID"/>
<arg evaluator="xml" expression="$ctx:CURRENCY"/>
<arg evaluator="xml" expression="$ctx:REFERENCE"/>
<arg evaluator="xml" expression="$ctx:DATE"/>
<arg evaluator="xml" expression="$ctx:STATE"/>
<arg evaluator="xml" expression="$ctx:INTERNAL_TRANSACTION_ID"/>
<arg evaluator="xml" expression="$ctx:OPERATOR_TRANSACTION_ID"/>
<arg evaluator="xml" expression="$ctx:CHANNEL"/>
<arg evaluator="xml" expression="$ctx:SERVICE_PROVIDER"/>
</args>
</payloadFactory>

<!--Get revenue publish URL-->
<dblookup>
<connection>
<pool>
<dsName>jdbc/MOBILE_MONEY_DB</dsName>
</pool>
</connection>
<statement>
<sql>
<![CDATA[ SELECT revenue_publish_api_url,revenue_publish_api_bearer_token FROM global_settings WHERE id = 1 ]]></sql>
<result column="revenue_publish_api_url" name="REVENUE_PUBLISH_API_URL"/>
<result column="revenue_publish_api_bearer_token" name="REVENUE_PUBLISH_API_BEARER_TOKEN"/>
</statement>
</dblookup>

<!-- Call revenue publish endpoint-->
<property name="Authorization" expression="fn:concat('Basic ', $ctx:REVENUE_PUBLISH_API_BEARER_TOKEN)" scope="transport" type="STRING"/>
<property name="Content-Type" value="application/json" scope="transport" type="STRING"/>
<header name="To" expression="$ctx:REVENUE_PUBLISH_API_URL" scope="default"/>
<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="POST"/>

<call>
<endpoint key="RevenuePublishEndpoint"/>
</call>

<log level="custom">
<property name="DIRECTION" value="RESPONSE-IN"/>
<property name="APP" value="REVENUE-CALL"/>
<property name="TRACE_ID" expression="$ctx:TRANSACTION_ID" scope="default" type="STRING"/>
<property expression="$axis2:HTTP_SC" name="HTTP_STATUS"/>
</log>

</sequence>
</template>

0 comments on commit 1baafb6

Please sign in to comment.