diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..0f7f78f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +Have you read our [Code of Conduct](https://github.com/Flutterwave/Java/blob/master/CONTRIBUTING.md)? By filing an Issue, you are expected to comply with it, including treating everyone with respect. + +# Description + + +# Steps to Reproduce + +1. +2. +3. + +## Expected behaviour + + +## Actual behaviour + + +## Reproduces how often + + +# Configuration +- API Version: +- Environment: +- Browser: +- Language: + +# Additional Information + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..c72eb33 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Developer Support Forum + url: https://forum.flutterwave.com + about: If you're having general trouble with your integration, Kindly contact our support team. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e0fe6a0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,95 @@ +

+ +

+ +Thank you for taking the time to contribute to our library🙌🏾. + +In this section, we detail everything you need to know about contributing to this library. + + +**[Code of Conduct](https://github.com/probot/template/blob/master/CODE_OF_CONDUCT.md)** + +## **I don't want to contribute, I have a question** + +Please don't raise an issue to ask a question. You can ask questions on our [forum](http://forum.flutterwave.com) or developer [slack](https://bit.ly/34Vkzcg). We have an army of Engineers on hand to answer your questions there. + +## How can I contribute? + +### Reporting a bug + +Have you spotted a bug? Fantastic! Before raising an issue, here are some things to do: + +1. Search to see if another user has reported the bug. For existing issues that are still open, add a comment instead of creating a new one. +2. Check our forum and developer slack to confirm that we did not address it there. + +When you report an issue, it is important to: + +1. Explain the problem + - Use a clear and descriptive title to help us to identify the problem. + - Describe steps we can use to replicate the bug and be as precise as possible. + - Include screenshots of the error messages. +2. Include details about your configuration and setup + - What version of the library are you using? + - Did you experience the bug on test mode or live? + - Do you have the recommended versions of the library dependencies? + + + +### Requesting a feature + +If you need an additional feature added to the library, kindly send us an email at developers@flutterwavego.com. Be sure to include the following in your request: + +1. A clear title that helps us to identify the requested feature. +2. A brief description of the use case for that feature. +3. Explain how this feature would be helpful to your integration. +4. Library name and version. + +### Submitting changes (PR) + +Generally, you can make any of the following changes to the library: + +1. Bug fixes +2. Performance improvement +3. Documentation update +4. Functionality change (usually new features) + + + +Follow these steps when making a pull request to the library: + +1. Fork the repository and create your branch from master. +2. For all types of changes (excluding documentation updates), add tests for the changes. +3. If you are making a functionality change, update the docs to show how to use the new feature. +4. Ensure all your tests pass. +5. Make sure your code lints. +6. Write clear log messages for your commits. one-liners are fine for small changes, but bigger changes should have a more descriptive commit message (see sample below). +7. Use present tense for commit messages, "Add feature" not "Added feature”. +8. Ensure that you fill out all sections of the PR template. +9. Raise the PR against the `staging` branch. +10. After you submit the PR, verify that all [status checks](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks) are passing + +```markdown +$ git commit -m "A brief summary of the commit +> +> A paragraph describing what changed and its impact." +``` + + + +We encourage you to contribute and help make the library better for the community. Got questions? send us a [message](https://bit.ly/34Vkzcg). + +Thank you. + +The Flutterwave team 🦋 diff --git a/README.md b/README.md index 2569309..532ad1a 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ compile("com.flutterwave:f4b-java:3.0") ## Environment Variables -The foloowing environment variables need to be set before calling any method +The following environment variables need to be set before executing any test classes: ```java Environment.setSecretKey("FLWSECK_TEST-92e*******-X"); diff --git a/src/main/java/com/flutterwave/bean/BillRequest.java b/src/main/java/com/flutterwave/bean/BillRequest.java index 1e34da9..4f08c11 100644 --- a/src/main/java/com/flutterwave/bean/BillRequest.java +++ b/src/main/java/com/flutterwave/bean/BillRequest.java @@ -16,12 +16,16 @@ public class BillRequest extends Shared { private String recurrence; private String country; private String customer; + private String type; + private String reference; - public BillRequest(String country, String customer, BigDecimal amount, + public BillRequest(String country, String customer, BigDecimal amount, String type, String reference, Optional recurrence, Optional ghanaAirtimeBills) { this.country = country; + this.type = type; + this.reference = reference; this.customer = customer; this.setAmount(amount); recurrence.ifPresent(value -> this.recurrence = String.valueOf(value)); diff --git a/src/main/java/com/flutterwave/bean/Data.java b/src/main/java/com/flutterwave/bean/Data.java index 9cb0166..5e2f1c1 100644 --- a/src/main/java/com/flutterwave/bean/Data.java +++ b/src/main/java/com/flutterwave/bean/Data.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -104,6 +105,11 @@ public class Data { private String response_message; private String product_code; private String email; + private String account_number; + private String expiry_date; + private String note; + private String active; + private String frequency; private Customer getCustomer(){ try { @@ -139,4 +145,20 @@ public String getCustomerString(){ } return null; } + + @Override + public String toString() { + + String value = null; + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + try { + value = objectMapper.writeValueAsString(this); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + return value; + + } } diff --git a/src/main/java/com/flutterwave/bean/ListResponse.java b/src/main/java/com/flutterwave/bean/ListResponse.java index e866970..78dcb79 100644 --- a/src/main/java/com/flutterwave/bean/ListResponse.java +++ b/src/main/java/com/flutterwave/bean/ListResponse.java @@ -24,7 +24,6 @@ public class ListResponse { private String code; public static ListResponse toListResponse(String value){ - System.out.println(value); return new GsonBuilder().create(). fromJson(value, ListResponse.class); } diff --git a/src/main/java/com/flutterwave/services/Transactions.java b/src/main/java/com/flutterwave/services/Transactions.java index 6544773..b386038 100644 --- a/src/main/java/com/flutterwave/services/Transactions.java +++ b/src/main/java/com/flutterwave/services/Transactions.java @@ -39,9 +39,22 @@ public Response runVerifyTransaction(int id) { * Query previously initiated transactions. You can do a single or bulk query with the endpoint depending on your use case. * @return ListResponse */ - public ListResponse runGetTransactions() { + public ListResponse runGetTransactions(Optional from, Optional to, Optional page, + Optional customer_email,Optional status,Optional tx_ref, + Optional customer_fullname, Optional currency) { + + List nameValuePairs = new ArrayList<>(); + from.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("from", from.get()))); + to.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("to", to.get()))); + page.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("page", page.get()))); + customer_email.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("customer_email", customer_email.get()))); + status.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("status", status.get()))); + tx_ref.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("tx_ref", tx_ref.get()))); + customer_fullname.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("customer_fullname", customer_fullname.get()))); + currency.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("currency", currency.get()))); + return Optional.of(get(getProperty("VERIFY_TRANSACTION_ENDPOINT"), - GET_TRANSACTION, null)) + GET_TRANSACTION, nameValuePairs)) .map(ListResponse::toListResponse).orElseThrow(() -> new RuntimeException(ERROR)); } @@ -91,9 +104,18 @@ public ListResponse runViewTimeline(int id) { } public class Refunds { - public ListResponse runGet() { + public ListResponse runGet(Optional from, Optional to, Optional status, + Optional currency,Optional id) { + + List nameValuePairs = new ArrayList<>(); + from.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("from", from.get()))); + to.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("to", to.get()))); + currency.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("currency", currency.get()))); + id.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("id", id.get()))); + status.ifPresent(String -> nameValuePairs.add(new BasicNameValuePair("status", status.get()))); + return Optional.of(get(getProperty("REFUND_ENDPOINT"), - REFUND, null)) + REFUND, nameValuePairs)) .map(ListResponse::toListResponse).orElseThrow(() -> new RuntimeException(ERROR)); } diff --git a/src/test/java/com/flutterwave/services/BillsTest.java b/src/test/java/com/flutterwave/services/BillsTest.java index f9d752a..cfdc041 100644 --- a/src/test/java/com/flutterwave/services/BillsTest.java +++ b/src/test/java/com/flutterwave/services/BillsTest.java @@ -32,6 +32,8 @@ void setUp() { billRequest = new BillRequest("NG", "+23490803840303", new BigDecimal("500"), + "AIRTIME", + "14rdxs", Optional.of(ONCE), Optional.empty()); } diff --git a/src/test/java/com/flutterwave/services/TransactionsTest.java b/src/test/java/com/flutterwave/services/TransactionsTest.java index 824c97f..69cfcb3 100644 --- a/src/test/java/com/flutterwave/services/TransactionsTest.java +++ b/src/test/java/com/flutterwave/services/TransactionsTest.java @@ -30,7 +30,9 @@ void runVerifyTransaction() { @Test void runGetTransactions() { - Assertions.assertEquals("success", new Transactions().runGetTransactions().getStatus()); + Assertions.assertEquals("success", new Transactions().runGetTransactions(Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()).getStatus()); } @Test @@ -52,7 +54,13 @@ void runViewTimeline() { @Test void rungetRefunds() { - Assertions.assertEquals("success", new Transactions().new Refunds().runGet().getStatus()); + Assertions.assertEquals("success", new Transactions().new Refunds().runGet( + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty() + ).getStatus()); } @Test