Skip to content

Commit 988cbb5

Browse files
authored
Develop (#47)
1 parent 5a89079 commit 988cbb5

54 files changed

Lines changed: 943 additions & 250 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ target/
44
!**/src/test/**/target/
55

66
### IntelliJ IDEA ###
7-
.idea/modules.xml
8-
.idea/jarRepositories.xml
9-
.idea/compiler.xml
10-
.idea/libraries/
7+
.idea/
118
*.iws
129
*.iml
1310
*.ipr
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.chrisworks.paystackclient</groupId>
7+
<artifactId>paystack-clients-spring-boot-starter</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<name>paystack-clients-spring-boot-starter</name>
10+
<description>paystack-clients-spring-boot-starter</description>
11+
12+
<properties>
13+
<maven.compiler.source>17</maven.compiler.source>
14+
<maven.compiler.target>17</maven.compiler.target>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<spring-boot-http-clients.version>0.1.1</spring-boot-http-clients.version>
17+
<distribution-repo.url>https://maven.pkg.github.com/chriseteka/paystackjavaclient</distribution-repo.url>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>com.maciejwalkowiak.spring</groupId>
23+
<artifactId>spring-boot-http-clients</artifactId>
24+
<version>${spring-boot-http-clients.version}</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>com.chrisworks.paystackclient</groupId>
28+
<artifactId>paystack-domain</artifactId>
29+
<version>${project.version}</version>
30+
</dependency>
31+
</dependencies>
32+
33+
<repositories>
34+
<repository>
35+
<id>github</id>
36+
<url>${distribution-repo.url}</url>
37+
</repository>
38+
</repositories>
39+
40+
<distributionManagement>
41+
<repository>
42+
<id>github</id>
43+
<name>GitHub Packages</name>
44+
<url>${distribution-repo.url}</url>
45+
</repository>
46+
</distributionManagement>
47+
48+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.chrisworks.paystackclients;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
5+
@ConfigurationProperties("paystack-client")
6+
public class PaystackClientsProperties {
7+
8+
private String secretKey;
9+
10+
public String getSecretKey() {
11+
return secretKey;
12+
}
13+
14+
public void setSecretKey(String secretKey) {
15+
this.secretKey = secretKey;
16+
}
17+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.chrisworks.paystackclients.definitions;
2+
3+
import com.chrisworks.paystackclient.domain.applepay.ApplePayRequest;
4+
import com.chrisworks.paystackclient.domain.applepay.ApplePayResponse;
5+
import com.chrisworks.paystackclient.domain.request.QueryParamConstants;
6+
import com.chrisworks.paystackclient.domain.response.EmptyDataResponse;
7+
import com.maciejwalkowiak.spring.http.annotation.HttpClient;
8+
import org.springframework.web.bind.annotation.RequestBody;
9+
import org.springframework.web.bind.annotation.RequestParam;
10+
import org.springframework.web.service.annotation.DeleteExchange;
11+
import org.springframework.web.service.annotation.GetExchange;
12+
import org.springframework.web.service.annotation.PostExchange;
13+
14+
@HttpClient(Constants.APPLE_PAY_CLIENT)
15+
public interface ApplePayClient {
16+
17+
@PostExchange
18+
EmptyDataResponse register(@RequestBody ApplePayRequest request);
19+
20+
@DeleteExchange
21+
EmptyDataResponse unregister(@RequestBody ApplePayRequest request);
22+
23+
@GetExchange
24+
ApplePayResponse.Multiple list(
25+
@RequestParam(name = QueryParamConstants.NEXT, required = false) String next,
26+
@RequestParam(name = QueryParamConstants.PREVIOUS, required = false) String previous,
27+
@RequestParam(name = QueryParamConstants.USE_CURSOR, required = false) Boolean useCursor
28+
);
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.chrisworks.paystackclients.definitions;
2+
3+
final class Constants {
4+
5+
private Constants() {}
6+
7+
static final String PLAN_CLIENT = "plan-client";
8+
static final String APPLE_PAY_CLIENT = "apple-pay-client";
9+
static final String TRANSACTION_CLIENT = "transaction-client";
10+
static final String PRODUCT_CLIENT = "product-client";
11+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.chrisworks.paystackclients.definitions;
2+
3+
import com.chrisworks.paystackclient.domain.plan.CreatePlanRequest;
4+
import com.chrisworks.paystackclient.domain.plan.PlanResponse;
5+
import com.chrisworks.paystackclient.domain.plan.UpdatePlanRequest;
6+
import com.chrisworks.paystackclient.domain.request.QueryParamConstants;
7+
import com.maciejwalkowiak.spring.http.annotation.HttpClient;
8+
import org.springframework.lang.NonNull;
9+
import org.springframework.web.bind.annotation.PathVariable;
10+
import org.springframework.web.bind.annotation.RequestBody;
11+
import org.springframework.web.bind.annotation.RequestParam;
12+
import org.springframework.web.service.annotation.GetExchange;
13+
import org.springframework.web.service.annotation.PostExchange;
14+
import org.springframework.web.service.annotation.PutExchange;
15+
16+
import java.math.BigInteger;
17+
18+
@HttpClient(Constants.PLAN_CLIENT)
19+
public interface PlanClient {
20+
21+
@PostExchange
22+
PlanResponse.Single createPlan(@RequestBody CreatePlanRequest body);
23+
24+
@GetExchange
25+
PlanResponse.Multiple listPlans(
26+
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
27+
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
28+
@RequestParam(name = QueryParamConstants.STATUS, required = false) String status,
29+
@RequestParam(name = QueryParamConstants.INTERVAL, required = false) String interval,
30+
@RequestParam(name = QueryParamConstants.AMOUNT, required = false) String amount
31+
);
32+
33+
@GetExchange("/{idOrCode}")
34+
PlanResponse.Single fetchPlan(@PathVariable String idOrCode);
35+
36+
@PutExchange("/{idOrCode}")
37+
PlanResponse.Single updatePlan(@PathVariable String idOrCode, @RequestBody UpdatePlanRequest body);
38+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.chrisworks.paystackclients.definitions;
2+
3+
import com.chrisworks.paystackclient.domain.product.CreateOrUpdateProductRequest;
4+
import com.chrisworks.paystackclient.domain.product.ProductResponse;
5+
import com.chrisworks.paystackclient.domain.request.QueryParamConstants;
6+
import com.maciejwalkowiak.spring.http.annotation.HttpClient;
7+
import org.springframework.lang.NonNull;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RequestBody;
10+
import org.springframework.web.bind.annotation.RequestParam;
11+
import org.springframework.web.service.annotation.GetExchange;
12+
import org.springframework.web.service.annotation.PostExchange;
13+
import org.springframework.web.service.annotation.PutExchange;
14+
15+
import java.math.BigInteger;
16+
import java.time.ZonedDateTime;
17+
18+
@HttpClient(Constants.PRODUCT_CLIENT)
19+
public interface ProductClient {
20+
21+
@PostExchange
22+
ProductResponse.Single createProduct(@RequestBody CreateOrUpdateProductRequest body);
23+
24+
@GetExchange
25+
ProductResponse.Multiple listProducts(
26+
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
27+
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
28+
@RequestParam(name = QueryParamConstants.FROM, required = false)ZonedDateTime from,
29+
@RequestParam(name = QueryParamConstants.TO, required = false)ZonedDateTime to
30+
);
31+
32+
@GetExchange("/{id}")
33+
ProductResponse.Single fetchProduct(@PathVariable String id);
34+
35+
@PutExchange("/{id}")
36+
ProductResponse.Multiple updateProduct(@PathVariable String id);
37+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.chrisworks.paystackclients.definitions;
2+
3+
import com.chrisworks.paystackclient.domain.request.QueryParamConstants;
4+
import com.chrisworks.paystackclient.domain.transaction.*;
5+
import com.maciejwalkowiak.spring.http.annotation.HttpClient;
6+
import org.springframework.lang.NonNull;
7+
import org.springframework.web.bind.annotation.PathVariable;
8+
import org.springframework.web.bind.annotation.RequestBody;
9+
import org.springframework.web.bind.annotation.RequestParam;
10+
import org.springframework.web.service.annotation.GetExchange;
11+
import org.springframework.web.service.annotation.PostExchange;
12+
13+
import java.math.BigInteger;
14+
import java.time.ZonedDateTime;
15+
16+
@HttpClient(Constants.TRANSACTION_CLIENT)
17+
public interface TransactionClient {
18+
19+
@PostExchange("/initialize")
20+
InitTransactionResponse.Single initializeTransaction(@RequestBody InitTransactionRequest body);
21+
@GetExchange("/verify/{reference}")
22+
TransactionResponse.Single verifyTransaction(@PathVariable String reference);
23+
@GetExchange
24+
TransactionResponse.Multiple listTransaction(
25+
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
26+
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
27+
@RequestParam(name = QueryParamConstants.CUSTOMER, required = false) BigInteger customer,
28+
@RequestParam(name = QueryParamConstants.TERMINAL_ID, required = false) String terminalId,
29+
@RequestParam(name = QueryParamConstants.STATUS, required = false) String status,
30+
@RequestParam(name = QueryParamConstants.FROM, required = false) ZonedDateTime from,
31+
@RequestParam(name = QueryParamConstants.TO, required = false) ZonedDateTime to,
32+
@RequestParam(name = QueryParamConstants.AMOUNT, required = false) String amount
33+
34+
);
35+
@GetExchange("/{id}")
36+
TransactionResponse.Single fetchTransaction(@PathVariable BigInteger id);
37+
@PostExchange("/charge_authorization")
38+
TransactionTotalResponse.Single chargeAuthorization(@RequestBody ChargeAuthorizationRequest body);
39+
@GetExchange("/timeline/{idOrReference}")
40+
TimeLineResponse.Single viewTransactionTimeLine(@PathVariable String idOrReference);
41+
@GetExchange("/totals")
42+
TransactionTotalResponse.Single transactionTotals(
43+
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
44+
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
45+
@RequestParam(name = QueryParamConstants.FROM, required = false) ZonedDateTime from,
46+
@RequestParam(name = QueryParamConstants.TO, required = false) ZonedDateTime to
47+
);
48+
@GetExchange("/export")
49+
ExportTransactionResponse.Single exportTransactions(
50+
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
51+
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
52+
@RequestParam(name = QueryParamConstants.FROM, required = false) ZonedDateTime from,
53+
@RequestParam(name = QueryParamConstants.TO, required = false) ZonedDateTime to,
54+
@RequestParam(name = QueryParamConstants.CUSTOMER, required = false) BigInteger customer,
55+
@RequestParam(name = QueryParamConstants.STATUS, required = false) String status,
56+
@RequestParam(name = QueryParamConstants.CURRENCY, required = false) String currency,
57+
@RequestParam(name = QueryParamConstants.AMOUNT, required = false) String amount,
58+
@RequestParam(name = QueryParamConstants.SETTLED, required = false) Boolean settled,
59+
@RequestParam(name = QueryParamConstants.SETTLEMENT, required = false) BigInteger settlement,
60+
@RequestParam(name = QueryParamConstants.PAYMENT_PAGE, required = false) BigInteger paymentPage
61+
62+
);
63+
@PostExchange("/partial_debit")
64+
TransactionTotalResponse.Single partialDebit(@RequestBody PartialDebitRequest body);
65+
}

paystack-clients-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
base-url: "https://api.paystack.co"
2+
3+
#TODO: How do I declare header once and re-use, to avoid repetition, like in my case below:
4+
http:
5+
clients:
6+
7+
plan-client:
8+
url: "${base-url}/plan"
9+
headers:
10+
Content-Type: "application/json"
11+
Authorization: "Bearer ${paystack-client.secret-key}"
12+
13+
apple-pay-client:
14+
url: "${base-url}/apple-pay"
15+
headers:
16+
Content-Type: "application/json"
17+
Authorization: "Bearer ${paystack-client.secret-key}"
18+
19+
transaction-client:
20+
url: "${base-url}/transaction"
21+
headers:
22+
Content-Type: "application/json"
23+
Authorization: "Bearer ${paystack-client.secret-key}"
24+
25+
product-client:
26+
url: "${base-url}/product"
27+
headers:
28+
Content-Type: "application/json"
29+
Authorization: "Bearer ${paystack-client.secret-key}"

0 commit comments

Comments
 (0)