/campay-android-sdk

Official android sdk for CamPay payment platform

Primary LanguageJava

CamPay Android SDK

Campay Art

Android CI Security Rating Reliability Rating Maintainability Rating Bugs Quality Gate Status Vulnerabilities Lines of Code Duplicated Lines (%) Coverage Code Smells

Summary

Getting Started

These instructions will get you started with the CamPay SDK for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

What things you need to install the software and how to install them

  • An account on CamPay platform
  • An application on the CamPay platform.
  • Credentials for connecting to the CamPay platform

Installing

A step by step series of examples that tell you how to get a development env running

  • Check out the available versions on Jitpack

  • Add the JitPack repository to your build file

        allprojects {
         repositories {
           ...
           maven { url 'https://jitpack.io' }
         }
       }
  • Add the dependency

    implementation 'com.github.CamPay.android-sdk:android-sdk:latest.release'
    // Peer dependency
    implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
  • Add the internet permission to your application
    <uses-permission android:name="android.permission.INTERNET" />

Running the samples

To view an extensive list of samples, clone this project and run the app module.

  • Initialize the library with credentials.
      CamPay.init(
          "<username>",
          "<password>",
          CamPay.Environment.DEV // environment
      )
  • Get an instance of the library from anywhere in your application and run the various operations.
     val camPay = CamPay.getInstance()

      camPay.collect(
          CollectionRequest.CollectionRequestBuilder
              .aCollectionRequest()
              .withAmount("amount")
              .withFrom("237XXXXXXXXX")
              .withDescription("some reason")
              .withExternalReference(UUID.randomUUID().toString())
              .withCurrency("XAF")
              .build()
      ).delay(1, TimeUnit.MINUTES) // delay for a minute before checking the transaction status
          .switchMap { collectResponse ->
              println(collectResponse)
              return@switchMap camPay.transactionStatus(collectResponse.reference) //  check the transaction status
          }.subscribe { transactionStatusResponse ->
              println(transactionStatusResponse)
          }
  • Get application balance.
      val camPay = CamPay.getInstance()

      camPay.applicationBalance()
          .subscribe { applicationBalanceResponse ->
              println(applicationBalanceResponse)
          }
  • Place a withdrawal request

Please enable API withdrawal under app settings before trying this request

      val camPay = CamPay.getInstance()

      camPay.withdraw(
          WithdrawRequest.WithdrawRequestBuilder
              .aWithdrawRequest()
              .withTo("237XXXXXXXXX")
              .withExternalReference(UUID.randomUUID().toString())
              .withDescription("some reason")
              .withAmount("100")
              .build()
      )
          .subscribe { withdrawalResponse ->
              println(withdrawalResponse)
          }

Deployment

Add additional notes about how to deploy this on a live system Change the environment of the library introduction to PROD

      CamPay.init(
          "<username>",
          "<password>",
          CamPay.Environment.PROD // environment
      )

Built With

  • Retrofit - A type-safe HTTP client for Android and Java.
  • RxJava3 - Reactive Extensions for the JVM