从 Stripe 中删除用户卡 Android
delete user card from Stripe Android
我正在尝试使用以下代码从条带中删除卡片:
第一次尝试:
com.stripe.Stripe.apiKey = getString(R.string.stripe_test_secret_key);
com.stripe.model.Token token = com.stripe.model.Token.retrieve(CardId);
String cardId = token.getCard().getId();
customer = Customer.retrieve(payments.appPreference.getStripeCustomerId());
DeletedExternalAccount delete = customer.getSources().retrieve(cardId).delete();
错误:
我得到 com.stripe.exception.InvalidRequestException:没有这样的来源:card_xxxxxxxxxxxxxxxxxxxxxx;请求 ID:req_xxxxxxxxxxxx
第二次尝试:
com.stripe.Stripe.apiKey = getString(R.string.stripe_test_secret_key);
com.stripe.model.Token token = com.stripe.model.Token.retrieve(CardId);
DeletedCard delete = token.getCard().delete();
错误:
com.stripe.exception.APIConnectionException:在 API 请求 Stripe 期间发生 IOException(https://api.stripe.com): null Please check your internet connection and try again. If this problem persists,you should check Stripe's service status at https://twitter.com/stripestatus,或通过 support@stripe.com.
告诉我们
原因:java.net.MalformedURLException
谁能帮我解决这个问题?
无法在您的 Android 应用程序中执行任何此操作,因为这些调用需要您的 API 密钥。您永远不应该在 Android 应用程序中拥有秘密 API 密钥,否则攻击者可能会得到它,然后以您的名义创建费用、退款或转账。
您在这里需要做的是在服务器端处理这段代码。您将调用删除卡 [API][1] 并确保您在代码中传递了正确的客户和卡 ID。在 Java 中,但在服务器端,你会这样做:
Customer customer = Customer.retrieve("cus_XXXXXXX");
customer.getSources().retrieve("card_YYYYYY").delete();
@koopajah 是对的。它在移动端不安全。
发生这种情况是因为我创建了 Token 但没有调用 api 创建卡片。
Token 有 Card 对象,但它没有分配给任何客户端。所以,我收到了这个错误。
我正在尝试使用以下代码从条带中删除卡片:
第一次尝试:
com.stripe.Stripe.apiKey = getString(R.string.stripe_test_secret_key);
com.stripe.model.Token token = com.stripe.model.Token.retrieve(CardId);
String cardId = token.getCard().getId();
customer = Customer.retrieve(payments.appPreference.getStripeCustomerId());
DeletedExternalAccount delete = customer.getSources().retrieve(cardId).delete();
错误: 我得到 com.stripe.exception.InvalidRequestException:没有这样的来源:card_xxxxxxxxxxxxxxxxxxxxxx;请求 ID:req_xxxxxxxxxxxx
第二次尝试:
com.stripe.Stripe.apiKey = getString(R.string.stripe_test_secret_key);
com.stripe.model.Token token = com.stripe.model.Token.retrieve(CardId);
DeletedCard delete = token.getCard().delete();
错误: com.stripe.exception.APIConnectionException:在 API 请求 Stripe 期间发生 IOException(https://api.stripe.com): null Please check your internet connection and try again. If this problem persists,you should check Stripe's service status at https://twitter.com/stripestatus,或通过 support@stripe.com.
告诉我们原因:java.net.MalformedURLException
谁能帮我解决这个问题?
无法在您的 Android 应用程序中执行任何此操作,因为这些调用需要您的 API 密钥。您永远不应该在 Android 应用程序中拥有秘密 API 密钥,否则攻击者可能会得到它,然后以您的名义创建费用、退款或转账。
您在这里需要做的是在服务器端处理这段代码。您将调用删除卡 [API][1] 并确保您在代码中传递了正确的客户和卡 ID。在 Java 中,但在服务器端,你会这样做:
Customer customer = Customer.retrieve("cus_XXXXXXX");
customer.getSources().retrieve("card_YYYYYY").delete();
@koopajah 是对的。它在移动端不安全。
发生这种情况是因为我创建了 Token 但没有调用 api 创建卡片。 Token 有 Card 对象,但它没有分配给任何客户端。所以,我收到了这个错误。