All Projects → voucherifyio → Voucherify Android Sdk

voucherifyio / Voucherify Android Sdk

Licence: mit
Android SDK for Voucherify - coupons, vouchers, promo codes

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Voucherify Android Sdk

React Native Midtrans
Midtrans Mobile SDK for React Native
Stars: ✭ 57 (+338.46%)
Mutual labels:  sdk, mobile
Uphold Sdk Android
Uphold Android SDK
Stars: ✭ 32 (+146.15%)
Mutual labels:  sdk, mobile
Clarifai Apple Sdk
Artificial Intelligence with a Vision
Stars: ✭ 46 (+253.85%)
Mutual labels:  sdk, mobile
Countly Sdk Cordova
Countly Product Analytics SDK for Cordova, Icenium and Phonegap
Stars: ✭ 69 (+430.77%)
Mutual labels:  sdk, mobile
Amplitude Ios
Native iOS/tvOS/macOS SDK
Stars: ✭ 216 (+1561.54%)
Mutual labels:  sdk, mobile
Countly Server
Countly helps you get insights from your application. Available self-hosted or on private cloud.
Stars: ✭ 4,857 (+37261.54%)
Mutual labels:  sdk, mobile
Weex
A framework for building Mobile cross-platform UI
Stars: ✭ 17,793 (+136769.23%)
Mutual labels:  sdk, mobile
Countly Sdk Ios
Countly Product Analytics iOS SDK with macOS, watchOS and tvOS support.
Stars: ✭ 585 (+4400%)
Mutual labels:  sdk, mobile
Node Sdk
An SDK implementation in JS (Node) for the v3 REST APIs.
Stars: ✭ 9 (-30.77%)
Mutual labels:  sdk
Metrica Sample Dotnet
Yandex AppMetrica SDK Sample for Windows
Stars: ✭ 11 (-15.38%)
Mutual labels:  mobile
Swipe
Swipe is the most accurate touch slider. Support both React and Angular.
Stars: ✭ 850 (+6438.46%)
Mutual labels:  mobile
T1 Node
Node SDK for MediaMath Platform APIs
Stars: ✭ 9 (-30.77%)
Mutual labels:  sdk
Flutter Tutorial
Learn how to start creating a Flutter application, first edition in the tutorial series.
Stars: ✭ 12 (-7.69%)
Mutual labels:  mobile
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+54500%)
Mutual labels:  sdk
Metrica Plugin Xamarin
Xamarin plugin for Yandex AppMetrica SDK
Stars: ✭ 12 (-7.69%)
Mutual labels:  mobile
Kudo
Kubernetes Universal Declarative Operator (KUDO)
Stars: ✭ 849 (+6430.77%)
Mutual labels:  sdk
Newbe.mahua.framework
本SDK为实现QQ机器人平台的大一统,支持多种机器人平台:酷Q、MyPCQQ、QQLight等
Stars: ✭ 849 (+6430.77%)
Mutual labels:  sdk
Streetmusicmap
StreetMusicMap is a collab line up of street music performers from all over the world.
Stars: ✭ 13 (+0%)
Mutual labels:  mobile
Worldpay Within Sdk
Worldpay Within SDK to allow payments within IoT. Written in Go.
Stars: ✭ 12 (-7.69%)
Mutual labels:  sdk
Smartystreets Go Sdk
The official client libraries for accessing SmartyStreets APIs from Go.
Stars: ✭ 11 (-15.38%)
Mutual labels:  sdk

Official Voucherify SDK for Android

Setup | Synchronous, Rx or Async? | Voucher Checkout View | Contributing | Changelog | License |

API: Validations | Redemptions | Voucher Listing | Promotions


Download Build Status

Setup

Using Gradle:
dependencies {
    compile 'io.voucherify.android.client:voucherify-android-sdk:2.2.0'
}
Using Maven:
<dependency>
    <groupId>io.voucherify.android.client</groupId>
    <artifactId>voucherify-android-sdk</artifactId>
    <version>2.2.0</version>
</dependency>
Proguard
-keepattributes Signature
-dontwarn rx.**
-dontwarn io.reactivex.**
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keep class io.voucherify.android.client.** { *; }
-keep class * extends io.voucherify.android.client.model.** { *; }
-keep class com.google.gson.** { *; }
-keep class sun.misc.Unsafe { *; }

NOTE: The SDK requires at least Java 6 or Android 4.1 (API 16)

Configuration

The VoucherifyAndroidClient manages your interaction with the Voucherify API.

VoucherifyAndroidClient client = new VoucherifyClient.Builder(YOUR-PUBLIC-CLIENT-APPLICATION-ID, YOUR-PUBLIC-CLIENT-APPLICATION-TOKEN).build();

We are tracking users which are validating vouchers with those who consume them, by a tracking_id. By that we are setting up an identity for the user. If you want to provide your custom value for tracking_id, you have to do it when creating VoucherifyAndroidClient:

androidClient = new VoucherifyAndroidClient.Builder(YOUR-PUBLIC-CLIENT-APPLICATION-ID, YOUR-PUBLIC-CLIENT-APPLICATION-TOKEN)
       .withCustomTrackingId(YOUR-CUSTOM-TRACKNG-ID)
       .build();

Other additional params which can be set:

  • origin
  • endpoint
  • log level
androidClient = new VoucherifyAndroidClient.Builder(YOUR-PUBLIC-CLIENT-APPLICATION-ID, YOUR-PUBLIC-CLIENT-APPLICATION-TOKEN)
       .withCustomTrackingId(YOUR-CUSTOM-TRACKNG-ID)
       .withOrigin("http://my-android-origin")
       .withEndpoint("10.0.3.2:8080")
       .setLogLevel(HttpLoggingInterceptor.Level.BODY)
       .build();

Synchronous, Rx or Async?

All the methods in SDK are provided directly or in asynchronous or rx (RxJava2) version:

Every method has a corresponding asynchronous extension which can be accessed through the async() or rx() method of the vouchers module.

If used directly, methods must be run in separate thread to avoid NetworkOnMainThreadException

try {
    VoucherResponse voucher = client.validations().validateVoucher(VOUCHER_CODE);
} catch (IOExceptions e) {
    // error
}

or asynchronously:

client.validations().async().validateVoucher("VOUCHER_CODE", new VoucherifyCallback<VoucherResponse>() {
    @Override
    public void onSuccess(VoucherResponse result) {
    }

    @Override
    public void onFailure(IOExceptions error) {
    // error
  }
});

or using RxJava (RxJava2):

client.validations()
        .rx()
        .validateVoucher("VOUCHER_CODE")
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new Consumer<VoucherResponse>() {
            @Override
            public void accept(VoucherResponse voucher) {

            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) {
            }
        });

API

Validations API

Validate Voucher

    client.validations().validate(String code)
    client.validations().validate(String code, ValidationContext context)

Validate Promotions

    client.validations().validate(ValidationContext context)

Redemptions API

Redeem Voucher

    client.redemptions().redeem(String code)
    client.redemptions().redeem(String code, RedemptionContext context)

Redeem Promotions

    client.redemptions().redeem(PromotionTier promotionTier, RedemptionContext context)

Listing vouchers API

List Vouchers

    client.listing().list()
    client.listing().list(String customer)

Promotions

List Promotion Tiers

    client.promotions().list(Boolean isAvailable, int limit, int page)

Voucher Checkout View

You can use VoucherCheckoutView to quickly add a UI for discount codes validation.

In your layout XML file add:

<io.voucherify.android.view.VoucherCheckoutView
    android:id="@+id/voucher_checkout"/>

Then in your activity init the VoucherCheckoutView with the VoucherifyAndroidClient.

VoucherifyAndroidClient voucherifyClient = new VoucherifyAndroidClient.Builder(
            YOUR-PUBLIC-CLIENT-APPLICATION-ID,
            YOUR-PUBLIC-CLIENT-APPLICATION-TOKEN)
       .withCustomTrackingId(YOUR-CUSTOM-TRACKNG-ID)
       .build();

VoucherCheckoutView voucherCheckout = (VoucherCheckoutView) findViewById(R.id.voucher_checkout);

You will also likely want to get validation results. You can achieve that by adding OnValidatedListener:

voucherCheckout.setOnValidatedListener(new OnValidatedListener() {
    @Override
    public void onValid(final VoucherResponse result) {
    }

    @Override
    public void onInvalid(final VoucherResponse result) {
    }

    @Override
    public void onError(VoucherifyError error) {
    }
});

Customization

The component is highly customizable. You can set following attributes:

  • validateButtonText - text displayed on the button
  • voucherCodeHint - label attached to the voucher code input
  • voucherIcon - icon appearing on the right
  • validVoucherIcon - icon appearing on the right after validation when provided code was valid
  • invalidVoucherIcon - icon appearing on the right after validation when provided code was invalid

You can disable any of the 3 icons by specifying them as @android:color/transparent.

Example:

<io.voucherify.android.view.VoucherCheckoutView
    android:id="@+id/voucher_checkout"/>
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:validateButtonText="Apply"
    app:voucherCodeHint="Coupon Code"
    app:voucherIcon="@android:color/transparent"
    app:validVoucherIcon="@android:color/transparent"
    app:invalidVoucherIcon="@android:color/transparent"/>

You can override animations by placing valid.xml and invalid.xml in res/anim.

You can also set your own colors and other visual properties by defining styles (in res\values\styles.xml):

  • VoucherCodeLabel
  • VoucherCodeEditText
  • VoucherValidateButton

For example to set the button background color to light green:

    <style name="VoucherValidateButton">
        <item name="android:background">#8BC34A</item>
    </style>

Contributing

Bug reports and pull requests are welcome through GitHub Issues.

Changelog

  • 2019-02-26 - 2.2.0 - Add method to list promotion tiers
  • 2018-11-17 - 2.1.0 - Increased minSdkVersion to 16 and updated external dependencies
  • 2018-04-16 - 2.0.0 - Adjusted API for Validation and Redemption
  • 2018-04-05 - 1.1.0 - Added API for Promotions and Vouchers Listing
  • 2017-01-02 - 1.0.0 - Unify API with other voucherify SDKs.
  • 2016-09-20 - 0.6.0 - Redeem a voucher.
  • 2016-09-06 - 0.5.0 - Added order items.
  • 2016-06-23 - 0.4.0 - Added support for gift vouchers.
  • 2016-05-30 - 0.3.1 - Enabled to show an error message below the code input.
  • 2016-05-20 - 0.3.0 - Voucher checkout view.
  • 2016-05-19 - 0.2.0 - Custom error handling.
  • 2016-04-04 - 0.1.3 - Updated API URL, HTTPS enabled by default.
  • 2016-01-14 - 0.1.2 - Default value for origin header.
  • 2015-12-14 - 0.1.0 - New discount model, new discount type: UNIT.
  • 2015-11-23 - 0.0.9 - added X-Voucherify-Channel header.
  • 2015-11-09 - 0.0.6 - Changed discount type from double to integer.
  • 2015-11-05 - 0.0.5 - Renamed trackingId to tracking_id.
  • 2015-10-22 - 0.0.4 - New backend URL.
  • 2015-09-01 - 0.0.3 - Updated backend URL.
  • 2015-08-15 - 0.0.2 - Added tracking id functionality.
  • 2015-08-11 - 0.0.1 - Initial version of the SDK.

License

MIT. See the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].