| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
AppleTransactionClient is a Java library designed to interact with Apple's App Store subscription APIs. It allows you to generate JSON Web Tokens (JWT) for authentication and retrieve subscription status responses seamlessly.
Clone the Repository:
git clone https://github.com/condo97/AppleTransactionClient.git
cd AppleTransactionClientBuild the Project:
./gradlew buildPublish to Local Maven Repository (Optional):
./gradlew publishToMavenLocalUpdate build.gradle:
Ensure all dependencies are correctly specified. The provided build.gradle is pre-configured with necessary dependencies and plugins.
Set Up JWT Signing:
To interact with Apple’s App Store APIs, you need to generate a JWT. Use the JWTSigner class for this purpose.
import appletransactionclient.JWTSigner;
// Initialize JWTSigner with the path to your private key and your key ID
JWTSigner signer = new JWTSigner("path/to/AuthKey.p8", "YOUR_KEY_ID");
// Generate JWT with required payload
String jwt = signer.signJWT(Map.of(
"iss", "YOUR_ISSUER_ID",
"iat", System.currentTimeMillis() / 1000L,
"exp", (System.currentTimeMillis() / 1000L) + 80,
"aud", "appstoreconnect-v1",
"bid", "com.your.bundleid"
));Once you have the JWT, you can retrieve the subscription status using SubscriptionAppleHttpClient.
import appletransactionclient.SubscriptionAppleHttpClient;
import appletransactionclient.exception.AppStoreErrorResponseException;
import appletransactionclient.http.response.status.AppStoreStatusResponse;
// Initialize the client with base URLs and path
SubscriptionAppleHttpClient client = new SubscriptionAppleHttpClient(
"https://api.storekit.itunes.apple.com/",
"https://api.storekit-sandbox.itunes.apple.com/",
"/inApps/subscriptions/"
);
// Fetch subscription status
try {
AppStoreStatusResponse response = client.getStatusResponseV1(transactionID, jwt);
// Process the response
} catch (AppStoreErrorResponseException | IOException | InterruptedException | URISyntaxException e) {
e.printStackTrace();
// Handle exceptions
}import appletransactionclient.JWTSigner;
import appletransactionclient.SubscriptionAppleHttpClient;
import appletransactionclient.http.response.status.AppStoreStatusResponse;
import appletransactionclient.exception.AppStoreErrorResponseException;
import java.util.Map;
public class ExampleUsage {
public static void main(String[] args) {
try {
// Initialize JWTSigner
JWTSigner signer = new JWTSigner("path/to/AuthKey.p8", "YOUR_KEY_ID");
// Generate JWT
String jwt = signer.signJWT(Map.of(
"iss", "YOUR_ISSUER_ID",
"iat", System.currentTimeMillis() / 1000L,
"exp", (System.currentTimeMillis() / 1000L) + 80,
"aud", "appstoreconnect-v1",
"bid", "com.your.bundleid"
));
// Initialize HTTP Client
SubscriptionAppleHttpClient client = new SubscriptionAppleHttpClient(
"https://api.storekit.itunes.apple.com/",
"https://api.storekit-sandbox.itunes.apple.com/",
"/inApps/subscriptions/"
);
// Retrieve subscription status
Long transactionID = 1234567890L;
AppStoreStatusResponse response = client.getStatusResponseV1(transactionID, jwt);
// Handle the response
System.out.println("Environment: " + response.getEnvironment());
System.out.println("Bundle ID: " + response.getBundleId());
// Further processing...
} catch (Exception e) {
e.printStackTrace();
// Handle exceptions appropriately
}
}
}The project includes unit tests using JUnit Jupiter. To run the tests:
./gradlew testTest classes are located in the src/test/java/appletransactionclient directory.
This library uses Gradle's maven-publish plugin. To publish the library to a Maven repository:
Configure Publishing Details in build.gradle:
Ensure the publishing section is correctly set up with your repository details.
Publish the Library:
./gradlew publishFor publishing to a local Maven repository:
./gradlew publishToMavenLocalContributions are welcome! Please follow these steps:
Fork the Repository
Create a Feature Branch:
git checkout -b feature/YourFeatureCommit Your Changes
Push to the Branch:
git push origin feature/YourFeatureCreate a Pull Request
Please ensure your code adheres to the project's coding standards and all tests pass.
This project is licensed under the MIT License.
| Back | FazBrowse Home | New Git URL |