4

I am trying to create a payment from a card token in my android program as shown in link below:

Sample usage of payment api

I can't create "Payment" object with Simplify Commerce Android SDK so i included java payment SDK by adding this line to my gradle build

compile 'com.simplify:payments-sdk-java:1.3.0'

After adding this line i can import "com.simplify.payments" package and create payment object,but this time my android build failed(cause i use java sdk?).

    Information:Gradle tasks [:app:assembleDebug]
Warning:Dependency org.apache.httpcomponents:httpclient:4.2.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.2.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.2.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.2.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
:app:prepareComSimplifySdkAndroid103Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/hamcrest/Description;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED

How can i use Simplify Commerce payment api in my android program?

Github Link to my project

0

1 Answer 1

3

Full disclosure: This does not answer the question of how to include the Payment API in your app, but rather point you in the right direction for using Simplify to collect payments within your app.

You should definitely not be attempting to use the payments java sdk in your Android app. Doing so requires you provide your private API key and will introduce serious security concerns. See: https://github.com/simplifycom/simplify-android-sample/wiki/Simplify-Android-SDK-Tutorial#process-a-payment

Friendly reminder: DO NOT BUNDLE YOUR PRIVATE KEY WITHIN YOUR APP!

Your private keys are considered sacred and can be used to process payments, issue refunds, and more. A common development mistake is to simply include the Java SDK in an app and use a private key to complete the transaction lifecycle without involving a server. While it may seem like an easy way to integrate payments, distributing your private key in an app leaves it vulnerable through simple reverse engineering. Once compromised, an attacker can use your key to perform almost every operation offered through our APIs. This is bad security practice. In addition, since keys can be revoked from the API Keys page, they are also considered volatile. If a private key is revoked, any app using it will be broken until an update is released with a new key. The bottom line is this: Don't do it. We will find you. :)

The good news is that Simplify provides an Android SDK that you can use to collect and tokenize card information in your app. Simply include it with the following line:

compile 'com.simplify:simplify-android:2.0.3'

And reference documentation and the sample app here: https://github.com/simplifycom/simplify-android-sample

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.