Skip to content
PAYTPV SDK for App's in Android
Branch: master
Clone or download
Andrei Zamfir
Latest commit 52a9ab2 Oct 17, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app-java
app-kotlin
gradle/wrapper
ptpv-sdk
.gitignore
.reviewboardrc
LICENSE
README.md
build.gradle
gradle.properties
settings.gradle

README.md

ANDROID-SDK

PAYTPV SDK for Apps in Android

The PAYTPV SDK provides easy to use methods for connecting to the PAYTPV API.

Requirements

The SDK is compatible with Android apps supporting API 15 and later.


Installation

To integrate PAYTPV into your project, add the following dependency to the module build.gradle:

dependencies {
    compile 'com.paytpv.androidsdk:paytpv-android-sdk:1.0'
}

The project is found on jcenter, so you need to add the following lines to the project build.gradle:

repositories {
    jcenter()
}

Usage

After you're done installing the SDK, you need to get the shared client and set up its configuration with your terminal details:

Java:

PTPVApiClient client = PTPVApiClient.getInstance(this.getApplicationContext());
PTPVConfiguration configuration = new PTPVConfiguration.PTPVConfigurationBuilder(CONFIG_CODE, CONFIG_TERMINAL, CONFIG_PASSWORD)
        .setJetId(CONFIG_JET)
        .build();
client.setConfiguration(configuration);

Kotlin:

val client = PTPVApiClient.getInstance(applicationContext)
val configuration = PTPVConfiguration.PTPVConfigurationBuilder(CONFIG_CODE, CONFIG_TERMINAL, CONFIG_PASSWORD)
        .setJetId(CONFIG_JET)
        .build()
client.setConfiguration(configuration)

After you created the configuration, you can start making requests:

Java:

// Create a PTPVCard object to store the user's card details
PTPVCard card = new PTPVCard("4111111111111111", "0518", "123");

client.addUser(card, new PTPVCallbacks.AddUserResponse() {

    @Override
    public void returnAddUserError(PTPVError error) {
        // Handle errors here
    }

    @Override
    public void returnAddUserResponse(PTPVAddUser addUserResponse) {

        // Define payment details
        PTPVMerchant merchant = new PTPVMerchant("199", "android_1234", PTPVCurrency.EUR);
        PTPVProduct product = new PTPVProduct("PAYTPV", "Android SDK", "100");

        // Make the payment
        client.executePurchase(addUserResponse, merchant, product, new PTPVCallbacks.PurchaseDetailsResponse() {

            @Override
            public void returnPurchaseDetailsError(PTPVError error) {
                // Handle errors here
            }

            @Override
            public void returnPurchaseDetailsResponse(PTPVPurchaseDetails executePurchaseResponse) {
                // Handle successful payment here
            }
        });
    }
});

Kotlin:

// Create a PTPVCard object to store the user's card details
val card = PTPVCard("4111111111111111", "0518", "123")

client.addUser(card, object: PTPVCallbacks.AddUserResponse {

    override fun returnAddUserError(error: PTPVError?) {
        // Handle errors here
    }

    override fun returnAddUserResponse(addUserResponse: PTPVAddUser?) {

        // Define payment details
        val merchant = PTPVMerchant("199", "android_1234", PTPVCurrency.EUR)
        val product = PTPVProduct("PAYTPV", "Android SDK", "100")

        // Make the payment
        client.executePurchase(addUserResponse, merchant, product, object : PTPVCallbacks.PurchaseDetailsResponse {

            override fun returnPurchaseDetailsError(error: PTPVError?) {
                // Handle errors here
            }

            override fun returnPurchaseDetailsResponse(executePurchaseResponse: PTPVPurchaseDetails?) {
                // Handle successful payment here
            }
        });
    }
});

Examples

There are Java and Kotlin example applications included in the repository. They show how to use the SDK to: add and remove a card, add/get info/remove a user, make a payment and make a refund. Check the app-java and app-kotlin folders.

You can’t perform that action at this time.