Giter Club home page Giter Club logo

tapgooglepaykit's Introduction

TapGooglePay™Kit

A standalone kit for handling Google Pay™

Platform Documentation SDK Version SDK Version

demo.mov

Table of Contents


  1. Requirements

  2. Installation

    1. Include TapGooglePayKit library as a dependency module in your project
    2. Installation with jitpack
  3. Setup

    1. TapGooglePay™Kit Class Properties
    2. TapGooglePay™Kit Button
  4. Usage

    1. Configure SDK with Required Data
    2. Configure SDK Look and Feel
  5. SDKSession Delegate

    1. OnTapToken Success Callback
    2. OnFailure Callback
    3. OnGooglePay_Token_Success Callback
  6. Additional Configuration Google Pay™

  7. Trouble Shoot_Google Pay™

  8. Documentation

Requirements


To use the SDK the following requirements must be met:

  1. Android Studio 4.2.1 or newer
  2. Android SDK Tools 33 or newer
  3. Android Platform Version: API 33: Android 11 revision 7 or later
  4. **Android targetSdkVersion: 33

Include tapgooglepay library as a dependency module in your project


  1. Clone checkoutSDK library from Tap repository
        https://github.com/Tap-Payments/TapGooglePayKit
    
  2. Add goSellSDK library to your project settings.gradle file as following
        include ':library', ':YourAppName'
  3. Setup your project to include checkout as a dependency Module.
    1. File -> Project Structure -> Modules -> << your project name >>
    2. Dependencies -> click on + icon in the screen bottom -> add Module Dependency
    3. select checkout library

Installation with JitPack


JitPack is a novel package repository for JVM and Android projects. It builds Git projects on demand and provides you with ready-to-use artifacts (jar, aar).

To integrate tapGooglePay™SDK into your project add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
	        implementation 'com.github.Tap-Payments:TapGooglePayKit:0.0.35'
	}

Setup


First of all, tapGooglePay™SDK should be set up. In this section secret key and application ID are required.

tapGooglePay™SDK Class Properties

First of all, tapGooglePay™SDK should be set up. To set it up, add the following lines of code somewhere in your project and make sure they will be called before any usage of tapGoooglePaySDK.

Below is the list of properties in tapGooglePaySDK class you can manipulate. Make sure you do the setup before any usage of the SDK.

Secret Key and Application ID

To set it up, add the following line of code somewhere in your project and make sure it will be called before any usage of checkOutSDK, otherwise an exception will be thrown. Required.

Java:

 dataConfig.initSDK(this@MainActivity as Context,"sk_test_kXXXXXXXXXXXXXXXXXXXXXXXX","app_id");

Kotlin: Here we need to make a Top level declaration

var dataConfig: DataConfiguration = DataConfiguration
dataConfig.initSDK(this@MainActivity as Context,"sk_test_kXXXXXXXXXXXXXXXXXXXXXXXX","app_id")
  1. authToken - to authorize your requests.// Secret key (format: "sk_XXXXXXXXXXXXXXXXXXXXXXXX")
  2. app_id - replace it using your application ID "Application main package".

SetUp Google Pay™ Button

Include the Google Pay™ button view inside the xml file as below

Kotlin

        <company.tap.google.pay.open.GooglePayButton
         android:id="@+id/googlePayView"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_alignParentBottom="true"
        android:enabled="true"
        android:focusable="true"
/>

Then declare it in the class as follows:

  1. In Top level add

Kotlin

lateinit var googlePayView: GooglePayButton
  1. Set the Button Type you prefer from the list of enums we have

Kotlin

 googlePayView = findViewById(R.id.googlePayView)
 googlePayView.setGooglePayButtonType(GooglePayButtonType.CHECKOUT_WITH_GOOGLE_PAY)
  1. Set The click event for the Google Pay™ view as below:

Kotlin

    googlePayView.buttonView.setOnClickListener {
   Here you choose what you prefer to call getGooglePayToken or getTapToken
            if(defaultPref.toString() == "GET GOOGLEPAY TOKEN"){
                dataConfig.getGooglePayToken(this, googlePayView)

            }else if(defaultPref.toString() == "GET TAP TOKEN"){
                dataConfig.getTapToken(this, googlePayView)
            }

        }

Mode

SDK mode defines which mode SDK is operating in, either sandbox or production.

SDK Mode is automatically identified in the backend based on the secrete key you defined earlier in setup process.

#Usage

Configure SDK With Required Data

tapGooglePay™SDK should be set up. To set it up, add the following lines of code somewhere in your project and make sure they will be called before any usage of tapGoooglePaySDK.

Kotlin:

     

        /**
         * Required step.
         * Configure SDK with your choice from the given list.
         */   
            initializeSDK()
            
         /**
         * Required step.
         * Configure SDK Session with all required data.
         */
        configureSDKData()
            

Configure SDK Secret Key and Application ID and SDK Language

To set it up, add the following line of code somewhere in your project and make sure it will be called before any usage of tapGoooglePaySDK, otherwise an exception will be thrown. Required.

Kotlin:

        /**
         * Required step.
         * Configure SDK with your Secret API key and App Bundle name registered with tap company.
         */
        private fun initializeSDK(){
           dataConfig.initSDK(this@MainActivity as Context,"sk_test_kXXXXXXXXXXXXXXXXXXXXXXXX","app_id")

        }
  1. authToken - to authorize your requests.// Secret key (format: "sk_XXXXXXXXXXXXXXXXXXXXXXXX")
  2. app_id - replace it using your application ID "Application main package".

Configure SDK Data

DATACONFIGURATION is the main interface for library from you application

Properties

Property Type Description
sdkDelegate Activity Activity. it is used to notify Merchant application with all SDK Events

Methods

Property Type
addSDKDelegate pass your activity that implements SdkDelegate interface . you have to override all methods available through this interface
setTransactionCurrency Set the transaction currency associated to your account. Transaction currency must be of type TapCurrency("currency_iso_code"). i.e new TapCurrency("KWD")
setEnvironmentMode SDK offers different environment modes such as [ TEST - PRODUCTION]
setAmount Set Total Amount. Amount value must be of type BigDecimal i.e new BigDecimal(40)
setGatewayId Gateway id required to use TAP as PSP . Here it is tappayments
setGatewayMerchantID MerchantID available with TAP
setAllowedCardAuthMethods ALLOWED CARD auth methods here it is PAN_ONLY, CRYPTOGRAM_3DS , ALL
setCountryCode Set country code.
setAllowedCardNetworks CARD networks like VISA, AMEX, JCB ,MADA.

Configure SDK DATA Example

Kotlin:

 private fun configureSDKData() {
   // pass your activity as a session delegate to listen to SDK internal payment process follow
   dataConfig.addSDKDelegate(this) //** Required **
   
   dataConfig.setEnvironmentMode(SDKMode.ENVIRONMENT_TEST) //**Required SDK MODE**/

   dataConfig.setGatewayId("tappayments")  //**Required GATEWAY ID**/

   dataConfig.setGatewayMerchantID("1124340") //**Required GATEWAY Merchant ID**/
   
    dataConfig.setAmount(BigDecimal.valueOf(23))  //**Required Amount**/

   settingsManager?.getAllowedMethods("allowed_card_auth_key")
      ?.let { dataConfig.setAllowedCardAuthMethods(it) } //**Required type of auth PAN_ONLY, CRYPTOGRAM , ALL**/


   settingsManager?.getString("key_currency_code","USD")
      ?.let { dataConfig.setTransactionCurrency(it) } //**Required Currency **/

   settingsManager?.getString("country_code_key","US")?.let { dataConfig.setCountryCode(it) } //**Required Country **/

  
   dataConfig.setAllowedCardNetworks(settingsManager?.getSet("key_payment_networks")?.toMutableList()) //**Required Payment Networks you want google to display for you **/
}

SDK Open Interfaces

SDK open Interfaces available for implementation through Merchant Project:

  1. SessionDelegate
  fun onGooglePayToken(token:String)
  fun onTapToken(token: Token)
  fun onFailed(error:String)

SDK Open ENUMs

SDK open Enums available for implementation through Merchant Project:

  1. AllowedMethods

Choose your allowed methods like PAN,CRYPTO etc

enum class AllowedMethods {
   PAN_ONLY,
   CRYPTOGRAM_3DS,ALL
}

2.SdkMode

Setup the mode you want to test in

enum class SDKMode {
   /**
    * Sandbox is for testing purposes
    */

   ENVIRONMENT_TEST,

   /**
    * Production is for live
    */

   ENVIRONMENT_PRODUCTION
}

3.GooglePayButtonType

Choose the type of button you wish to use in your app

enum class GooglePayButtonType {
   BUY_WITH_GOOGLE_PAY,

   DONATE_WITH_GOOGLE_PAY,

   NORMAL_GOOGLE_PAY,

   PAY_WITH_GOOGLE_PAY,

   SUBSCRIBE_WITH_GOOGLE_PAY,

   CHECKOUT_WITH_GOOGLE_PAY,

   ORDER_WITH_GOOGLE_PAY,

   BOOK_WITH_GOOGLE_PAY
}

SDK Delegate

SDK Delegate is an interface which you may want to implement to receive payment/authorization/card saving status updates and update your user interface accordingly when payment window closes. Below are listed down all available callbacks:

GooglePay Token Success Callback

Notifies the receiver that googlepay token has succeed.

Declaration

Kotlin:

-  fun onGooglePayToken(token:String)

Arguments

token: Successful Token object.

TAP Token Success Callback

Notifies the receiver that token generated for TAP .

Declaration

Kotlin:

-  fun onTapToken(token: Token)

Arguments

token: Token object from TAP.

<a name=failed_callback">

Failure Callback

Notifies the receiver that failed.

Declaration

Kotlin:

- fun onFailed(error:String)

Arguments

error: Failure object.

Additional Data Configuration

To use GooglePay in your app , you will be required to do additional configuration as follows:

  1. In build.gradle file add
implementation "com.google.android.gms:play-services-wallet:18.1.3"
  1. Ensure your min sdk is 21
minSdk 21
targetSdk 32
  1. In Manifest file , Inside the <application tag do the below:
<meta-data
    android:name="com.google.android.gsm.wallet.api.enabled"
    android:value="true"
    />

Trouble shoot GooglePay

You might encounter the following errors at some point in your integration. This list provides some helpful troubleshooting advice should these errors arise.

  1. This merchant is not enabled for Google Pay The Google Pay API requires a Google merchantId for sites that configure PaymentsClient for a PRODUCTION environment. A Google merchantId is associated with one or more fully qualified domains through the Google Pay and Wallet Console. Check the returned error details for more information.

  2. This merchant has not completed registration to use Google Pay API. Please go to console (https://pay.google.com/business/console) to verify. You haven't completed the process to register your apps for the Google Pay API. Review Request production access to register using the Google Pay and Wallet Console and request a review of your app's use of the Google Pay API.

  3. This merchant profile does not have access to this feature Google hasn't configured your app to use the Google Pay API. Review Request production access to request a review of your app's use of the Google Pay API via the Google Pay and Wallet Console. This Google Pay API integration is disabled. Please contact us for more information (https://developers.google.com/pay/api/faq#how-to-get-support). Contact us to learn more about the required steps to re-enable the Google Pay API for your Google Account.

Documentation

Documentation is available at [github-pages][2].
Also documented sources are attached to the library. [1]:https://www.tap.company/developers/

tapgooglepaykit's People

Contributors

ahlaamk-tap avatar aslm-android avatar osamarabie avatar

Watchers

James Cloos avatar Kalai avatar Faisal Mehmood avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.