Skip to content

Edorin9/BucketSDK-Android

 
 

Repository files navigation

BucketSDK-Android

This is the BucketSDK for Android. Here is where you can create transactions & other important features of the Bucket API pre-wrapped for Android.

Requirements

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.

Installation

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"

Usage

Using the BucketSDK, you will be able to use either Java or Kotlin to access the functions that you will need.

Setting the app context & app environment

// Java:
Bucket.setAppContext(BucketApp.appContext);
if (!BuildConfig.DEBUG) {
    Bucket.setEnvironment(DeploymentEnvironment.Production);
}
// Kotlin
if (!BuildConfig.DEBUG) {
    Bucket.environment = DeploymentEnvironment.Production
}
Bucket.appContext = theAppContext

Setting & retrieving your retailer id & retailer secret:

// 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()

Setting your currency code:

SGD (Singapore) & USD (USA) currencies are currently supported.

// Java:
Credentials.setCountry("USD");
Bucket.fetchBillDenominations(new BillDenomination() {
    @Override public void setBillDenoms() {
        
    }
    @Override public void didError(Error error) {
        
    }
});
// Kotlin:
Credentials.setCountry("USD")
Bucket.fetchBillDenominations(object : BillDenomination() {
    override fun setBillDenoms() {
    
    }
    override fun didError(error: Error?) {

    }
})

Getting the Bucket Amount

// Java:
long bucketAmount = Bucket.bucketAmount(789);
// Kotlin:
val bucketAmount = Bucket.bucketAmount(789)

Creating a transactionBody

You will need to use the bucketAmount function to set the transactionBody amount here.

// Java:
Transaction tr = new Transaction("XCFRTDSFGGOL", 0.60, 5.60);
tr.create(new CreateTransaction() {
    @Override public void transactionCreated() {
        // The transactionBody was successfully created!
    }
    @Override public void didError(VolleyError volleyError) {
        // There was an error.
    }
});
// Kotlin:
val transactionBody = Transaction("XCFRTDSFGGOL", 0.60, 5.60)
transactionBody.create(object : CreateTransaction() {
    override fun transactionCreated() {
        // Yay the transactionBody was successfully created.
    }
    override fun didError(error: VolleyError?) {
        // Oh no - we had an error :(
    }
})

Author

Ryan Coyne, [email protected]

License

BucketSDK is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 89.3%
  • Java 10.7%