java - 找不到符号 stripe.createPaymentMethod
问题描述
当我尝试运行该应用程序时,我停留在这一点并在 Android Studio 中遇到了下一个错误。
找不到符号 stripe.createPaymentMethod()
所以,我想在我的应用程序中集成这个https://github.com/baranyildirim/google_pay/blob/master/android/src/main/java/com/googlepay/googlepay/GooglePayPlugin.java。
但是发现这部分大部分已被弃用并且无法正常工作
case Activity.RESULT_OK:
PaymentData paymentData = PaymentData.getFromIntent(data);
CardInfo info = paymentData.getCardInfo();
UserAddress address = paymentData.getShippingAddress();
String rawToken = paymentData.getPaymentMethodToken().getToken();
Token stripeToken = Token.fromString(rawToken);
Map<String, Object> arguments = new LinkedHashMap<>();
arguments.put("token", stripeToken.getId());
if (stripeToken != null) {
channel.invokeMethod("onGooglePaySuccess", arguments);
}
else {
channel.invokeMethod("onGooglePayFailed", null);
}
休息;
然后我决定将其替换为下一个
case Activity.RESULT_OK:
final PaymentData paymentData = PaymentData.getFromIntent(data);
if (paymentData == null) {
channel.invokeMethod("onGooglePayFailed", null);
} else {
final PaymentMethodCreateParams paymentMethodCreateParams =
PaymentMethodCreateParams.createFromGooglePay(
new JSONObject(paymentData.toJson()));
stripe.createPaymentMethod(
paymentMethodCreateParams,
new ApiResultCallback<PaymentMethod>() {
@Override
public void onSuccess(@NonNull PaymentMethod result) {
channel.invokeMethod("onGooglePaySuccess", result.id);
}
@Override
public void onError(@NonNull Exception e) {
channel.invokeMethod("onGooglePayFailed", null);
}
}
);
}
break;
当然,我还导入了一些其他的东西,比如:
import com.stripe.android.Stripe;
import com.stripe.android.ApiResultCallback;
import com.stripe.android.GooglePayJsonFactory;
import com.stripe.android.model.PaymentMethod;
import com.stripe.android.model.PaymentMethodCreateParams;
import com.stripe.android.PaymentConfiguration;
import com.stripe.android.PaymentIntentResult;
import com.stripe.android.model.PaymentIntent;
import com.stripe.android.view.CardInputWidget;
import androidx.annotation.NonNull;
然后我得到了上面提到的错误。AndroidManifest.xml、依赖项...等根据需要设置。
解决方案
推荐阅读
- javascript - 使用 jQuery 3.2.1 动态创建输入的自动完成
- python - 如何摆脱python中的for循环?
- android - 在反应本机屏幕中膨胀 android 本机 UI
- java - 在前台服务中获取当前位置
- android - 响应式图像尺寸约束布局
- excel - 将功能保存到我的用户表单后出现运行时错误 1004
- php - Symfony 4 - 两个目录中的控制器
- wpf - 如何将 WPF TabControl 标题对齐到右侧?
- docker - Docker Windows 容器因 Azure Service Fabric 崩溃
- kotlin - 从方法访问委托对象