【问题标题】:How to use Simplify Commerce Payment API in Android?如何在 Android 中使用 Simplify Commerce Payment API?
【发布时间】:2015-09-24 21:10:49
【问题描述】:

我正在尝试从卡令牌创建付款 在我的android程序中,如下链接所示:

Sample usage of payment api

我无法使用 Simplify Commerce Android SDK 创建“支付”对象,所以我通过将此行添加到我的 gradle 构建中来包含 java 支付 SDK

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

如何在我的安卓程序中使用 Simplify Commerce 支付 API?

Github Link to my project

【问题讨论】:

  • 嗯,我试过但失败了 +1

标签: android payment


【解决方案1】:

完全披露:这并没有回答如何在您的应用中包含 Payment API 的问题,而是为您指明了使用 Simplify 在您的应用中收取付款的正确方向。

您绝对不应该尝试在您的 Android 应用中使用支付 java sdk。这样做需要您提供您的私有 API 密钥,并且会引入严重的安全问题。见:https://github.com/simplifycom/simplify-android-sample/wiki/Simplify-Android-SDK-Tutorial#process-a-payment

友情提示:不要将你的私钥捆绑在你的应用中!

您的私钥被认为是神圣的,可用于处理付款、发放退款等。一个常见的开发错误是在应用程序中简单地包含 Java SDK 并使用私钥来完成交易生命周期而不涉及服务器。虽然这似乎是一种集成支付的简单方法,但在应用程序中分发您的私钥会通过简单的逆向工程使其容易受到攻击。一旦受到攻击,攻击者就可以使用您的密钥来执行通过我们的 API 提供的几乎所有操作。这是不好的安全做法。此外,由于可以从 API 密钥页面撤销密钥,因此它们也被视为易失性。如果私钥被撤销,任何使用它的应用程序都将被破坏,直到使用新密钥发布更新。底线是:不要这样做。我们会找到你的。 :)

好消息是,Simplify 提供了一个 Android SDK,您可以使用它来收集和标记应用中的卡信息。只需将其包含在以下行中:

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

并在此处参考文档和示例应用程序: https://github.com/simplifycom/simplify-android-sample

【讨论】:

    猜你喜欢
    • 2014-03-21
    • 2021-03-08
    • 1970-01-01
    • 1970-01-01
    • 2018-06-02
    • 1970-01-01
    • 2019-01-15
    • 2013-07-17
    • 2018-04-20
    相关资源
    最近更新 更多