Mobile
Mobile SDKs
Android
integrating android with judopay prerequisites you have set up your judopay account sign up for your sandbox account , to receive access to your judopay dashboard and the sandbox environment your judoids and tokens are configured and enabled as appropriate for more information on permissions, see introduction docid\ s 8hoamytkgy13t0p657 you have the latest version of the android sdk for mobile apps, we recommend using payment session authentication integration requirements android studio and build tools (we recommend you use the latest stable version) your app targets api 32 or higher always consider google's play store requirements minimum android sdk version 21 (android 5 0 ) the mobile sdk is available for android as a gradle dependency no need to clone a repository to add judopay as a dependency to your current project navigate to your build gradle file in the dependencies section add the latest com judopay\ judokit android {version} for the latest version, see android releases an example of how your build gradle might look android { } dependencies { implementation 'com judopay\ judokit android 4 0 1' } 3\ ensure the maven central repository has been added allprojects { repositories { mavencentral() } } see judopay's judokit for android on github initialising the judo builder the judo builder is at the heart of the android mobile sdk this class is responsible for setting all the required parameters customising the payment flow import some of the classes and properties from the com judopay judokit android package as detailed below import com judopay judokit android judo import com judopay judokit android model amount import com judopay judokit android model reference import com judopay judokit android model paymentwidgettype import com judopay judokit android payment cancelled import com judopay judokit android payment error import com judopay judokit android payment success import com judopay judokit android judoactivity judo is the class used to build the payment flow amount and reference classes used to set the amount and reference properties paymentwidgettype allows for multiple payment types card google pay™ identifies the transaction result payment success payment error payment cancelled the judoactivity class is used to start a payment intent building the judo object set up the transaction amount in the amount object provide the amount value and currency type val amount = amount builder() setamount("150 50") setcurrency(currency gbp) build() set up the transaction reference in the reference object provide the consumerreference string val reference = reference builder() setconsumerreference('my consumer reference') build() set up the judo configuration set the following required parameters the token and secret values, or create the authorisation object (step 3 below) set the sdk to run in sandbox mode set the following objects judo id judoid format = 100100100 authorisation object (if using this method) amount reference create the authorisation object val authorization = paymentsessionauthorization builder() setpaymentsession(paymentsession) setapitoken(token) build() 4\ set the authorisation object when invoking judo builder val builder = judo builder(widgettype) setauthorization(authorization) field description card payment card payment token payment starts a token payment with optionally asking the user to enter their csc and / or cardholder name pre auth card preauth token pre auth starts a pre auth token payment with optionally asking the user to enter their csc and / or cardholder name create card token save card check card check card payment methods payment method selection pre auth payment methods preauth method selection google pay google pay (payment) pre auth google pay google pay (preauth) server to server payment methods server to server the judo object is now configured and you are ready to make a transaction making a transaction each transaction operation is represented as an activity to make a transaction create an intent to pass the judoactivity class add the judo object to the intent call putextra assign it to the judo options key the judo object holds all the payment configurations previously set up 3\ pass the intent and a request code to allow judopay to handle the onactivityresult and the transaction response val intent = intent(this, judoactivity class java); intent putextra(judo options, judo); startactivityforresult(intent, judo payment widget request code); 4\ implement the onactivityresult method and handle the transaction response override fun onactivityresult(requestcode int, resultcode int, data intent?) { super onactivityresult(requestcode, resultcode, data) if (requestcode == judo payment widget request code) { when (resultcode) { payment cancelled > toast("user cancelled the payment ") payment success > { val result = data? getparcelableextra\<judoresult>(judo result) // handle response } payment error > { val error = data? getparcelableextra\<judoerror>(judo error) // handle error } } } } check the request code from the onactivityresult and see if it matches with judo payment widget request code if it does, the result is called from the judoactivity this means the imported response codes can be used to check the following possible response type and handle each case respectively success cancel error android server to server transactions to set a server to server transaction on the judo builder set the paymentwidgettype to val judo = judo builder(paymentwidgettype server to server payment methods) setapitoken("my token") setapisecret("my secret") setissandboxed(true) setjudoid("my judo id") setamount(amount) setreference(reference) build() token payments if you are building your own card wallet, and not using a ui you can make a preauth or payment using a stored card token follow the steps for android docid\ it3yrnihegsketqtsxgi3 and replace the paymentwidgettype with paymentwidgettype token pre auth or paymentwidgettype token payment for more information on token payments, see the android sample app 3d secure 2 for android judokit android is enabled for 3d secure 2 (emv 3ds) 3d secure 2 is available on judokit android version 3 0 0 or higher, and is available on github using the pre built ui card entry component the easiest way to integrate 3d secure is to use the pre built ui component within judokit, as this handles the 3d secure flow for you using a 3d secure enabled credential , follow the steps for android docid\ it3yrnihegsketqtsxgi3 we recommend using billingaddress and emailaddress fields for 3d secure 2 transactions you can provide billingaddress and emailaddress in two ways add and populate billingaddress and emailaddress to the payment configuration object card entry example val uiconfiguration = uiconfiguration builder() // // sets whether 3ds 2 0 ui billing information screen should be presented to the user setshouldaskforbillinginformation(false) build() // in case you don't want to present billing info screen to the user, you can set the address instead val address = address builder() setline1("my house") setline2("my street") settown("my town") setpostcode("tr14 8pa") setcountrycode("826") setbillingcountry("826") build() val judo = judo builder(paymentwidgettype card payment) // setuiconfiguration(uiconfiguration) // sets the value for challenge request indicator, // possible values // challengerequestindicator no preference // challengerequestindicator no challenge // challengerequestindicator challenge preferred // challengerequestindicator challenge as mandate setchallengerequestindicator(challengerequestindicator no preference) // sets the value for sca exemption, // possible values // scaexemption low value // scaexemption secure corporate // scaexemption trusted beneficiary // scaexemption transaction risk analysis setscaexemption(scaexemption low value) // email address setemailaddress("email\@me com") // sets the maximum timeout for 3ds 2 0 transactions in minutes, // always use 2 characters when setting the timeout setthreedstwomaxtimeout(30) // sets phone number country code setphonecountrycode("44") // phone number setmobilenumber("11223344556677") // setaddress(address) // build() or, to request this information from your customer enable the billingaddress and emailaddress fields to appear in the ui setshouldaskforbillinginformation(true) using token payments with 3d secure 2 using a 3d secure enabled credential , follow the steps for android docid\ it3yrnihegsketqtsxgi3 make sure your account has 3d secure 2 api credentials enabled contact customer support to set this up adding payment methods integrating google pay for android configuring google pay™ for android prerequisites you have set up your google pay™ payments profile for more details, see create a payments profile you have imported the following models import com judopay judokit android model googlepay googlepayaddressformat import com judopay judokit android model googlepay googlepaybillingaddressparameters import com judopay judokit android model googlepayconfiguration import com judopay judokit android model googlepay googlepayenvironment import com judopay judokit android model googlepay googlepayshippingaddressparameters creating the google pay™ configuration to create the google pay™ configuration set the required properties using the prerequisite imported models set some additional optional properties to customise google pay™ val billingaddressparams = googlepaybillingaddressparameters( format = googlepayaddressformat min, phonenumberrequired = true ) val shippingaddressparams = googlepayshippingaddressparameters( phonenumberrequired = true ) val googlepayconfiguration = googlepayconfiguration builder() settransactioncountrycode("gb") setenvironment(googlepayenvironment test) setisemailrequired(true) setisbillingaddressrequired(true) setbillingaddressparameters(billingaddressparams) setisshippingaddressrequired(true) setshippingaddressparameters(shippingaddressparams) build() field description settransactioncountrycode required required sets the transaction iso 3166 country code setenvironment required required sets the google pay™ environment to either test production in order to go live you will need to have set up your google pay™ api merchant live account setisemailrequired optional optional sets the option for the consumer to provide their email address setisbillingaddressrequired optional optional sets the option for the consumer to provide their billing address setbillingaddressparameters optional optional sets the billing address format setisshippingaddressrequired optional optional sets the option for the consumer to provide their shipping information setshippingaddressparameters optional optional sets the shipping address format although setting the billing and shipping parameters is optional, they must be provided if the billing and shipping requirements are set to true making a google pay™ transaction prerequisite you have set up the googlepayconfiguration to make a google pay™ transaction add the setgooglepayconfiguration method to the judo builder set the paymentwidgettype to google pay start the judo activity val judo = judo builder(paymentwidgettype google pay) setgooglepayconfiguration(googlepayconfiguration) build() val intent = intent(this, judoactivity class java); intent putextra(judo options, judo); startactivityforresult(intent, judo payment widget request code); to make a google pay™ pre auth request add the setgooglepayconfiguration method to the judo builder set the paymentwidgettype to pre auth google pay start the judo activity val judo = judo builder(paymentwidgettype pre auth google pay) setgooglepayconfiguration(googlepayconfiguration) build() val intent = intent(this, judoactivity class java); intent putextra(judo options, judo); startactivityforresult(intent, judo payment widget request code); testing android mobile card transactions follow our suggested guidelines to simulate both positive / happy path scenarios, and negative scenarios in the sandbox environment to test your integration is working correctly this will give you confidence for when your integration goes live see, testing android sdk card payments docid\ vzb3q7wp2hf0ljgdo8vnd and generate successful payments declined payments unexpected errors enable google pay™ on your mobile app you will need to have your app approved by google prior to using google pay™ in production ensure you have tested google pay™ on your mobile app see, testing google pay™ wallet via mobile sdk docid\ pdwr34avmt3iws1j8xtsq ensure your android application package is enabled for sandbox testing this is to permit the google pay™ support team to run their review tests send your android application package to the google pay™ support team so they can review your app and assist you with any of the terms and conditions that need to be agreed the google pay™ support team will enable your app with production access to google pay™, once their review has been successfully completed you will then be able to accept google pay™ transactions from your mobile app