2015-09-24 59 views
4

我試圖創建一個從卡在我的Android程序令牌 支付如下圖所示鏈接:如何在Android中使用簡化Commerce付款API?

Sample usage of payment api

我無法創建「付款」對象,具有簡化商務的Android SDK,所以我包括java的支付SDK中加入此行到我的gradle這個構建

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

加入這一行我可以導入「com.simplify.payments」包後並創建付款對象,但這次我的android編譯失敗(因爲我使用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 

如何在我的android程序中使用簡化Commerce付款API?

Github Link to my project

+0

嗯,我嘗試和失敗+1 – Elltz

回答

2

披露:這並沒有回答如何在應用程式的支付API的問題,而是你指出正確的方向使用簡化領取您的應用程序內支付。

你絕對不應該試圖在你的Android應用程序中使用付款java sdk。這樣做需要您提供您的私有API密鑰,並會引起嚴重的安全問題。請參閱:https://github.com/simplifycom/simplify-android-sample/wiki/Simplify-Android-SDK-Tutorial#process-a-payment

友情提醒:不捆綁你的私鑰在您的應用!

您的私鑰被認爲是神聖的,可用於處理付款,退款等事宜。一個常見的開發錯誤是簡單地將Java SDK包含在應用程序中,並使用私鑰完成事務生命週期而不涉及服務器。雖然看起來像是一種簡單的集成支付方式,但將私鑰分發到應用程序中可能會通過簡單的逆向工程使其易受攻擊。一旦泄露,攻擊者可以使用您的密鑰執行幾乎所有通過我們的API提供的操作。這是不好的安全措施。另外,由於密鑰可以從API密鑰頁面撤銷,因此它們也被認爲是不穩定的。如果私鑰被撤銷,則使用該私鑰的任何應用都將被破壞,直到用新密鑰釋放更新爲止。底線是這樣的:不要這樣做。我們會找到你。 :)

的好消息是,簡化提供了一個Android SDK中,您可以使用收集和您的應用程序令牌化卡信息。

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

和參考文檔和示例應用程序在這裏:簡單地用下面一行包括它 https://github.com/simplifycom/simplify-android-sample