PayPal Mobile Payments をアプリケーションに統合しました。それは大したことではありませんでした。顧客がアプリから購入すると、詳細がサーバーに投稿されるように設定しました。大したこともありません。しかし、私の人生では、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)