【发布时间】:2016-02-19 08:43:21
【问题描述】:
我正在使用以下 SDK:https://github.com/paypal/PayPal-Android-SDK
我的 AndroidManifext.xml 中有这个:
<!-- PayPal Android SDK start -->
<service android:name="com.paypal.android.sdk.payments.PayPalService"
android:exported="false" />
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
<activity android:name="io.card.payment.CardIOActivity"
android:configChanges="keyboardHidden|orientation" />
<activity android:name="io.card.payment.DataEntryActivity" />
<!-- PayPal Android SDK end -->
在我开始购买的片段中,我有以下代码(取自 SDK 教程):
private static PayPalConfiguration paypal_config = new PayPalConfiguration()
// Start with mock environment. When ready, switch to sandbox (ENVIRONMENT_SANDBOX)
// or live (ENVIRONMENT_PRODUCTION)
.environment(PayPalConfiguration.ENVIRONMENT_SANDBOX)
.clientId("<--ID-->");
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
...
Intent intent = new Intent(getActivity(), PayPalService.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, paypal_config);
getActivity().startService(intent);
...
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme);
LayoutInflater inflater = LayoutInflater.from(getActivity());
View prompt = inflater.inflate(R.layout.purchase, null);
Button cancel_btn = (Button) prompt.findViewById(R.id.cancel);
Button purchase_btn = (Button) prompt.findViewById(R.id.purchase_button);
PayPalPayment payment = new PayPalPayment(new BigDecimal("1.75"), "USD", "sample item",
PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent = new Intent(getActivity(), PaymentActivity.class);
// send the same configuration for restart resiliency
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, paypal_config);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);
startActivityForResult(intent, 0);
}
});
这对昨天和今天的大部分时间都有效,但今天我得到了标题中所述的错误。我访问了开发者门户的 paypal,我的帐户没有任何通知,并且我的应用程序/帐户/用户设置正确(在它工作之前没有任何变化。它只是在测试期间停止工作)。
有人遇到过这个问题并成功解决了吗?
编辑: 更多信息:当贝宝视图弹出时,它给我一个错误弹出窗口标题:“重试”消息:“与贝宝服务器通信时出现问题。请重试。”如果点击取消,它会返回到我的应用程序视图。有时,当我点击“再试一次”时,它会让我进入付款和登录按钮,但当我尝试登录时,它会给我一个类似的错误,只有“确定”作为选项。
编辑 2:多次点击“再试一次”后,我也收到此错误:
"E/paypal.sdk: request failed with server response:Socket is closed"
编辑 3:另外,在这些错误之前,我总是收到此错误:
"E/ViewRootImpl: sendUserActionEvent() mView == null"
有人知道这是否是问题的原因吗?不太确定这意味着什么,因为视图实际上加载正常,但之后服务器调用似乎存在问题。
编辑 4:似乎可以与带有生产客户端 ID 的 ENVIRONMENT_PRODUCTION 集一起正常工作。我尝试删除该应用程序,为该应用程序使用不同的帐户,甚至尝试使用另一个贝宝帐户无济于事。除非我遗漏了什么或 PayPal 限制了我的测试帐户,否则 PayPal 的服务器有问题。希望有更多知识的人能进来并阐明这个问题,这样其他人就不必在这上面浪费时间了。
编辑 5:从头开始。我现在在生产环境中遇到错误...给出了什么?
【问题讨论】: