android - 如何在 Android 中使用 Simplify Commerce Payment API?

标签 android payment

我正在尝试从卡 token 创建付款 在我的 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

如何在我的 android 程序中使用 Simplify Commerce 支付 api?

Github Link to my project

最佳答案

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

您绝对不应该尝试在您的 Android 应用程序中使用 payments java sdk。这样做需要您提供您的私有(private) API key ,并且会带来严重的安全问题。请参阅: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. :)

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

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

引用文档和示例应用程序位于: https://github.com/simplifycom/simplify-android-sample

关于android - 如何在 Android 中使用 Simplify Commerce Payment API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32770983/

相关文章:

presenter 执行 retrofit 调用后调用的 Android 测试方法

ruby-on-rails - Paypal 支付是靠其他用户分摊全部金额吗?

android - 为 Netbeans 设置 Android-Facebook sdk

paypal - 如果我们的服务器出现故障,如何处理来自支付网关的响应

payment - 如何将成员(member)关联到 BuyNow 购买

paypal - PayPal 中账单地址的最低必填字段?

php - Magento 订单被收取两次费用

java - Android - 将 XML 架构发布到 PHP 服务器 API

机器人 onStatusChanged 不工作

android - 创建具有全圆边的 9patch