Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Android SDK for YenePay

YenePay SDK for android will let you connect your app with YenePay to start accepting payments.


Add to the end of your repositories

repositories {
    maven { url "" }

Add the SDK package to your project's build.gradle file. Make sure to use the latest version. You can find the latest version here.

dependencies {
    implementation ''

Add yenepayReturnScheme to manifestPlaceholders in build.gradle file ofyour project. This uri scheme will be used to initiate a pending activity when payment response arrived. This can be anything that is unique to your activity.

android {

    defaultConfig {
        manifestPlaceholders = [
                yenepayReturnScheme: "com.yourappname.yenepay"

Change com.yourappname.yenepay with your own scheme.

That's it your app can now start to accept payment using yenepay.

Getting started

To start accepting payment the easies way is extending your activity from YenePayPaymentActivity. See the example below

public class MainActivity extends YenePayPaymentActivity {
    private void checkout(){

        PaymentOrderManager paymentMgr = new PaymentOrderManager(
        //If you want to move to production just omit this line
        //This will disable shopping cart mode to enable set it true.
        try {
            paymentMgr.addItem(new OrderedItem("ITEM_ID", "Item Name", 2, 12.70));
         } catch (InvalidPaymentException e) {
            Log.e(TAG, "checkoutWithBrowser: ", e);
            showErrorDialog(context, e.getMessage());
    public void onPaymentResponseArrived(PaymentResponse response) {
        //Handle Payment response
            //Complete delivery

    public void onPaymentResponseError(String error) {
        //Handle payment request error.

If you want your app to handle payment responses even after it has been closed. You need to configure globally pending intents for the response.

One of a good places to put that logic can be in your Application class like this.

public class ShopApp extends Application {

    public void onCreate() {
        PendingIntent completionIntent = PendingIntent.getActivity(getApplicationContext(),
                new Intent(getApplicationContext(), PaymentResponseActivity.class), 0);
        PendingIntent cancelationIntent = PendingIntent.getActivity(getApplicationContext(),
                new Intent(getApplicationContext(), PaymentResponseActivity.class), 0);
        YenePayConfiguration.setDefaultInstance(new YenePayConfiguration.Builder(getApplicationContext())


Since version 0.0.10 payment will be validated by PaymentOrderManager when adding item and starting checkout methodsand checking out. Both will throw an InvalidPaymentException

try {
        OrderedItem orderedItem = new OrderedItem("ITEM_ID", "Item Name", 2, 12.70);
    } catch (InvalidPaymentException e) {
        Log.e(TAG, "checkoutWithBrowser: ", e);
        showErrorDialog(context, e.getMessage());

    //If you want to validate manually

    //Payment validation
    PaymentOrderManager.PaymentValidationResult result = paymentMgr.validate();

    //Or for item validation 

    PaymentOrderManager.PaymentValidationResult result = paymentMgr.validateOrderedItem(orderedItem);

    //To check result
        throw new InvalidPaymentException(result.toString());

Shopping cart mode

Shopping Cart mode is the default implementation of Ordered item list handling of the PaymentOrderManager when adding items. Basically it acts as a shopping cart and add an item only if any previous item with the same item id does not exist already. If it founds a match from previously added items it will only update the previous items quantity.

        String id = UUID.randomUUID().toString();
        OrderedItem first = new OrderedItem(id, "Test Item", 1, 15);
        OrderedItem second = new OrderedItem(id, "Test Item", 1, 15);
        int totalQty = first.getQuantity() + second.getQuantity();
        double totalPrice = first.getItemTotalPrice() + second.getItemTotalPrice();

        try {
        } catch (InvalidPaymentException e) {
            fail("Adding item failed");

        assertEquals(1, manager.getItems().size());
        assertEquals(totalQty, manager.getItems().get(0).getQuantity());
        assertEquals(totalPrice, manager.getItems().get(0).getItemTotalPrice(), 0);

Since version 0.0.10 you can disable this feature which will allow you to add items with the same id more than once.


This is all it takes to accept payment using YenePay from your android app.

The sample shop simulator app

To run the sample app download or clone the repository then build and run the project
YenePay Shop Simulator Sample App YenePay Shop Simulator sample App

Before you start checking out orders you need to provide YenePay MerchantCode on for this app. Go to YenePay Sandbox to create a testing merchant account. You can find more info here.

Set your merchant code on the setting page of the app. If you are working the sandbox you have to enable the Use Sandbox setings on also.

YenePay Shop Simulator Sample App

Note If your app targets below Android API level 21 (LOLLIPOP) or if YenePay app is not installed on the user device, then configuring YenePayConfiguration with global PendingIntents like the above example is required to function return results properly.

Please see the sample app in this repository for more on how to achieve that.


If you encounter any issues please report them here and we will try to provide a fix as soon as we can.

More information

To find more information about YenePay integration please visit YenePay Developers or visit YenePay Community Site