PayPal Android SDK继续检查我的设备"

时间:2014-02-19 20:10:38

标签: android paypal sdk


我正在尝试在我的应用中使用PayPal Android SDK(https://github.com/paypal/PayPal-Android-SDK)。我使用了与他们的例子相同的方法。所有参数如ClientID都是来自我的PayPal沙箱的正确参数。当我按下调用PayPal活动的按钮时,屏幕上标题为“正在检查此设备...”,屏幕上会出现旋转的ProgressBar和PayPal徽标。我让这个屏幕好几个小时,但没有任何事情发生。

感谢您的帮助,请原谅我的英语不好,这是我的第一个问题,我来自德国......


LogCat中的输出现在来自PayPal或其活动。这是我的代码:

  package de.jimpachnet.xaver;






import java.math.BigDecimal;

import org.json.JSONException;

import com.paypal.android.sdk.payments.PayPalPayment;
import com.paypal.android.sdk.payments.PayPalService;
import com.paypal.android.sdk.payments.PaymentActivity;
import com.paypal.android.sdk.payments.PaymentConfirmation;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;

public class Premium extends Activity {


private static final String CONFIG_ENVIRONMENT = PaymentActivity.ENVIRONMENT_NO_NETWORK;

// note that these credentials will differ between live & sandbox environments.
private static final String CONFIG_CLIENT_ID = "XXXXXXXXXXXX";
// when testing in sandbox, this is likely the -facilitator email address. 
private static final String CONFIG_RECEIVER_EMAIL = "XXXXXXXXX-facilitator@t-online.de"; 


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_premium);

    Intent intent = new Intent(this, PayPalService.class);

    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

    startService(intent);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.premium, menu);
    return true;
}

public void onButtonPayPal (View view) {
    onBuyPressed();
}


public void onBuyPressed() {
    PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal("2.11"), "USD", "StXaverAppPremiumAccount");

    Intent intent = new Intent(this, PaymentActivity.class);

    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);


    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "test");
    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

    startActivityForResult(intent, 0);
}


@Override
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));



            } catch (JSONException e) {
                Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
            }
        }
    }
    else if (resultCode == Activity.RESULT_CANCELED) {
        Log.i("paymentExample", "Nope");
    }
    else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
        Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
    }
}



@Override
public void onDestroy() {
    stopService(new Intent(this, PayPalService.class));
    super.onDestroy();
}

}

0 个答案:

没有答案