Skip to content

Commit

Permalink
Merge pull request #21 from renuka-fernando/1.0.x-monitization
Browse files Browse the repository at this point in the history
[APIM 3.0.0] Fix invoice date issue
  • Loading branch information
dushaniw authored Sep 7, 2020
2 parents 8a6e2c9 + 9549381 commit c8d721c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is a sample implementation to support usage based billing for a API subscri

| Stripe Extension Version | Supported WSO2 APIM Version |
| :-------------: | :---------------:|
| [1.0.0](https://github.com/wso2-extensions/wso2-am-stripe-plugin/tree/v1.0.0) | API Manager 3.0.0
| [1.0.1](https://github.com/wso2-extensions/wso2-am-stripe-plugin/tree/v1.0.1) | API Manager 3.0.0


## Getting Started
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.wso2.apim.monetization</groupId>
<artifactId>org.wso2.apim.monetization.impl</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,8 @@ public Map<String, String> getCurrentUsageForSubscription(String subscriptionUUI
//throw MonetizationException as it will be logged and handled by the caller
throw new MonetizationException(errorMessage);
}
SimpleDateFormat dateFormatter = new SimpleDateFormat("EEEE, MMMM d");
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
//the below parameters are billing engine specific
billingEngineUsageData.put("Description", invoice.getDescription());
billingEngineUsageData.put("Paid", invoice.getPaid() != null ? invoice.getPaid().toString() : null);
Expand All @@ -877,14 +878,14 @@ public Map<String, String> getCurrentUsageForSubscription(String subscriptionUUI
billingEngineUsageData.put("Invoice ID", invoice.getId());
billingEngineUsageData.put("Account Name", invoice.getAccountName());
billingEngineUsageData.put("Next Payment Attempt", invoice.getNextPaymentAttempt() != null ?
dateFormatter.format(new Date(invoice.getNextPaymentAttempt())) : null);
dateFormatter.format(new Date(invoice.getNextPaymentAttempt() * 1000)) : null);
billingEngineUsageData.put("Customer Email", invoice.getCustomerEmail());
billingEngineUsageData.put("Currency", invoice.getCurrency());
billingEngineUsageData.put("Account Country", invoice.getAccountCountry());
billingEngineUsageData.put("Amount Remaining", invoice.getAmountRemaining() != null ?
Long.toString(invoice.getAmountRemaining() / 100L) : null);
billingEngineUsageData.put("Period End", invoice.getPeriodEnd() != null ?
dateFormatter.format(new Date(invoice.getPeriodEnd())) : null);
dateFormatter.format(new Date(invoice.getPeriodEnd() * 1000)) : null);
billingEngineUsageData.put("Due Date", invoice.getDueDate() != null ?
dateFormatter.format(new Date(invoice.getDueDate())) : null);
billingEngineUsageData.put("Amount Due", invoice.getAmountDue() != null ?
Expand All @@ -898,7 +899,7 @@ public Map<String, String> getCurrentUsageForSubscription(String subscriptionUUI
billingEngineUsageData.put("Total", invoice.getTotal() != null ?
Long.toString(invoice.getTotal() / 100L) : null);
billingEngineUsageData.put("Period Start", invoice.getPeriodStart() != null ?
dateFormatter.format(new Date(invoice.getPeriodStart())) : null);
dateFormatter.format(new Date(invoice.getPeriodStart() * 1000)) : null);

//the below parameters are also returned from stripe, but commented for simplicity of the invoice
/*billingEngineUsageData.put("object", "invoice");
Expand Down

0 comments on commit c8d721c

Please sign in to comment.