我将 PayPal 移动支付集成到我的应用程序中。那没什么大不了的。我设置了当客户从我的应用程序购买时,详细信息会发布到我的服务器。也没什么大不了的。但是,对于我的生活,我无法获得 PayPal 交易详情。我在 LogCat 中看到了详细信息,但无论我尝试什么,我都无法抓住任何东西。我知道它必须简单,但我一直坐在这里,每一次尝试都是徒劳的。我可以得到一些细节,但不是全部。任何帮助,将不胜感激。在我完全掌握他们的 SDK 之前,我还没有对 PayPal 开发人员网站上发布的代码做任何戏剧性的事情,但它就在这里。
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
Log.i("paymentExample", confirm.toJSONObject().toString(4));
// TODO: send 'confirm' to your server for verification.
// see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
// for more details.
//String PAYMENT_CONFIRMATION = confirm.toJSONObject().getJSONObject("pay_key").toString();
// Log.d("PAYMENT CONFIRMATION KEY::", PAYMENT_CONFIRMATION) ;
new Update_CloseLines().execute();
} catch (JSONException e) {
Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
}
}
}
else if (resultCode == Activity.RESULT_CANCELED) {
Log.i("paymentExample", "The user canceled.");
}
else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
}
}
这是日志猫。
08-26 13:04:01.780: I/paymentExample(830): {
08-26 13:04:01.780: I/paymentExample(830): "payment": {
08-26 13:04:01.780: I/paymentExample(830): "short_description": "Nite Rider Hollow",
08-26 13:04:01.780: I/paymentExample(830): "amount": "1.01",
08-26 13:04:01.780: I/paymentExample(830): "currency_code": "USD"
08-26 13:04:01.780: I/paymentExample(830): },
08-26 13:04:01.780: I/paymentExample(830): "client": {
08-26 13:04:01.780: I/paymentExample(830): "platform": "Android",
08-26 13:04:01.780: I/paymentExample(830): "paypal_sdk_version": "1.0.3",
08-26 13:04:01.780: I/paymentExample(830): "product_name": "PayPal Android SDK; ",
08-26 13:04:01.780: I/paymentExample(830): "environment": "live"
08-26 13:04:01.780: I/paymentExample(830): },
08-26 13:04:01.780: I/paymentExample(830): "proof_of_payment": {
08-26 13:04:01.780: I/paymentExample(830): "adaptive_payment": {
08-26 13:04:01.780: I/paymentExample(830): "timestamp": "2013-08-26T18:03:55+0000",
08-26 13:04:01.780: I/paymentExample(830): "payment_exec_status": "COMPLETED",
08-26 13:04:01.780: I/paymentExample(830): "app_id": "APP-XXXXXXXXXXXXXXXX",
08-26 13:04:01.780: I/paymentExample(830): "pay_key": "AP-XXXXXXXXXXXXXXXXXX"
08-26 13:04:01.780: I/paymentExample(830): }
08-26 13:04:01.780: I/paymentExample(830): }
08-26 13:04:01.780: I/paymentExample(830): }
08-26 13:04:01.780: E/paymentExample(830): an extremely unlikely failure occurred:
08-26 13:04:01.780: E/paymentExample(830): org.json.JSONException: No value for pay_key
08-26 13:04:01.780: E/paymentExample(830): at org.json.JSONObject.get(JSONObject.java:354)
08-26 13:04:01.780: E/paymentExample(830): at org.json.JSONObject.getJSONObject(JSONObject.java:569)
08-26 13:04:01.780: E/paymentExample(830): at com.example.shopper.ConfirmCheckOut.onActivityResult(ConfirmCheckOut.java:480)
08-26 13:04:01.780: E/paymentExample(830): at android.app.Activity.dispatchActivityResult(Activity.java:5390)
08-26 13:04:01.780: E/paymentExample(830): at android.app.ActivityThread.deliverResults(ActivityThread.java:3178)
08-26 13:04:01.780: E/paymentExample(830): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3225)
08-26 13:04:01.780: E/paymentExample(830): at android.app.ActivityThread.access$1100(ActivityThread.java:140)
08-26 13:04:01.780: E/paymentExample(830): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1275)
08-26 13:04:01.780: E/paymentExample(830): at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 13:04:01.780: E/paymentExample(830): at android.os.Looper.loop(Looper.java:137)
08-26 13:04:01.780: E/paymentExample(830): at android.app.ActivityThread.main(ActivityThread.java:4898)
08-26 13:04:01.780: E/paymentExample(830): at java.lang.reflect.Method.invokeNative(Native Method)
08-26 13:04:01.780: E/paymentExample(830): at java.lang.reflect.Method.invoke(Method.java:511)
08-26 13:04:01.780: E/paymentExample(830): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
08-26 13:04:01.780: E/paymentExample(830): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
08-26 13:04:01.780: E/paymentExample(830): at dalvik.system.NativeStart.main(Native Method)
08-26 13:04:01.850: E/SpannableStringBuilder(830): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
08-26 13:04:01.850: E/SpannableStringBuilder(830): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
如果可以的话,我想抓住pay_key。
不太可能的错误:
08-26 14:13:27.115: E/paymentExample(13971): an extremely unlikely failure occurred:
08-26 14:13:27.115: E/paymentExample(13971): org.json.JSONException: Value AP-6S9448074V032801M at pay_key of type java.lang.String cannot be converted to JSONObject
08-26 14:13:27.115: E/paymentExample(13971): at org.json.JSON.typeMismatch(JSON.java:100)
08-26 14:13:27.115: E/paymentExample(13971): at org.json.JSONObject.getJSONObject(JSONObject.java:573)
08-26 14:13:27.115: E/paymentExample(13971): at com.example.shopper.ConfirmCheckOut.onActivityResult(ConfirmCheckOut.java:480)
08-26 14:13:27.115: E/paymentExample(13971): at android.app.Activity.dispatchActivityResult(Activity.java:5390)
08-26 14:13:27.115: E/paymentExample(13971): at android.app.ActivityThread.deliverResults(ActivityThread.java:3178)
08-26 14:13:27.115: E/paymentExample(13971): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3225)
08-26 14:13:27.115: E/paymentExample(13971): at android.app.ActivityThread.access$1100(ActivityThread.java:140)
08-26 14:13:27.115: E/paymentExample(13971): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1275)
08-26 14:13:27.115: E/paymentExample(13971): at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 14:13:27.115: E/paymentExample(13971): at android.os.Looper.loop(Looper.java:137)
08-26 14:13:27.115: E/paymentExample(13971): at android.app.ActivityThread.main(ActivityThread.java:4898)
08-26 14:13:27.115: E/paymentExample(13971): at java.lang.reflect.Method.invokeNative(Native Method)
08-26 14:13:27.115: E/paymentExample(13971): at java.lang.reflect.Method.invoke(Method.java:511)
08-26 14:13:27.115: E/paymentExample(13971): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
08-26 14:13:27.115: E/paymentExample(13971): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
08-26 14:13:27.115: E/paymentExample(13971): at dalvik.system.NativeStart.main(Native Method)