This is the BucketSDK for Android. Here is where you can create transactions & other important features of the Bucket API pre-wrapped for Android.
You will need to be registered with Bucket & have obtained a Retailer Account. You will need to have received a clientId & clientSecret in order to access Bucket's API.
BucketSDK is available through JitPack. To install it, simply add the following line to your project-level gradle file:
repositories {
maven { url 'https://jitpack.io' }
}
And, this to your app-level gradle file:
implementation "com.github.buckettech:BucketSDK-Android:$bucketSDKVersion"
Using the BucketSDK, you will be able to use either Java or Kotlin to access the functions that you will need.
// Java:
Bucket.setAppContext(BucketApp.appContext);
if (!BuildConfig.DEBUG) {
Bucket.setEnvironment(DeploymentEnvironment.Production);
}
// Kotlin
if (!BuildConfig.DEBUG) {
Bucket.environment = DeploymentEnvironment.Production
}
Bucket.appContext = theAppContext
// Java:
// Setter:
Credentials.setRetailerCode("RetailerId");
Credentials.setTerminalSecret("TerminalSecret");
// Getter:
String retailerCode = Credentials.retailerCode();
String terminalSecret = Credentials.terminalSecret();
// Kotlin:
// Setter:
Credentials.setRetailerCode("RetailerId")
Credentials.setTerminalSecret("RetailerSecret")
// Getter:
val retailerId = Credentials.retailerCode()
val retailerSecret = Credentials.terminalSecret()
SGD (Singapore) & USD (USA) currencies are currently supported.
// Java:
Credentials.setCountryCode("USD");
Bucket.fetchBillDenominations(new BillDenomination() {
@Override public void setBillDenoms() {
}
@Override public void didError(Error error) {
}
});
// Kotlin:
Credentials.setCountryCode("USD")
Bucket.fetchBillDenominations(object : BillDenomination() {
override fun setBillDenoms() {
}
override fun didError(error: Error?) {
}
})
// Java:
long bucketAmount = Bucket.bucketAmount(789);
// Kotlin:
val bucketAmount = Bucket.bucketAmount(789)
You will need to use the bucketAmount function to set the transaction amount here.
// Java:
Transaction tr = new Transaction("XCFRTDSFGGOL", 0.60, 5.60);
tr.create(new CreateTransaction() {
@Override public void transactionCreated() {
// The transaction was successfully created!
}
@Override public void didError(VolleyError volleyError) {
// There was an error.
}
});
// Kotlin:
val transaction = Transaction("XCFRTDSFGGOL", 0.60, 5.60)
transaction.create(object : CreateTransaction() {
override fun transactionCreated() {
// Yay the transaction was successfully created.
}
override fun didError(error: VolleyError?) {
// Oh no - we had an error :(
}
})
Ryan Coyne, [email protected]
BucketSDK is available under the MIT license. See the LICENSE file for more info.