【问题标题】:Android integration with StripeAndroid 与 Stripe 的集成
【发布时间】:2019-11-06 20:28:20
【问题描述】:

我正在尝试将我的 Android 应用与 Stripe 集成。我创建了一家商店,我想管理结帐。 所以,我正在尝试使用 Android Studio、VS Code 和 Heroku 来实现。在后端,我正在尝试创建用于准备付款的后端。

这是我在 Vs Code 中的 gradle 文件。我加了

implementation 'com.stripe:stripe-android:11.1.4' 

这是我的 heroku.java 应用程序

import java.sql.Statement;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import com.stripe.android.Stripe;

@Controller
@SpringBootApplication
public class HerokuApplication {

  @Value("${spring.datasource.url}")
  private String dbUrl;

  @Autowired
  private DataSource dataSource;

  public static void main(String[] args) throws Exception {
    SpringApplication.run(HerokuApplication.class, args);
  }

  @RequestMapping("/")
  String index() {
    return "index";
  }

  @RequestMapping("/fusion")
  String fusion(Map<String, Object> carro){
    // Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.apiKey = "sk_test_9Y7kTvkOhZEcT8HnkHhkQuOC00krpQNDQR";

Map<String, Object> params = new HashMap<String, Object>();

ArrayList<String> paymentMethodTypes = new ArrayList<>();
paymentMethodTypes.add("card");
params.put("payment_method_types", paymentMethodTypes);

ArrayList<HashMap<String, Object>> lineItems = new ArrayList<>();
HashMap<String, Object> lineItem = new HashMap<String, Object>();
lineItem.put("name", "T-shirt");
lineItem.put("description", "Comfortable cotton t-shirt");
lineItem.put("amount", 500);
lineItem.put("currency", "eur");
lineItem.put("quantity", 1);
lineItems.add(lineItem);
params.put("line_items", lineItems);

params.put("success_url", "https://example.com/success?session_id={CHECKOUT_SESSION_ID}");
params.put("cancel_url", "https://example.com/cancel");

Session session = Session.create(params);
return "carro";

  }

我正在尝试构建带有此错误的 gradle...您可以看到对 Heroku 和 Stripe 的了解不多,所以我不知道如何修复此错误。

  • 出了什么问题: 任务 ':compileJava' 执行失败。

    无法解析配置“:compileClasspath”的所有文件。 找不到 com.google.android.material:material:1.0.0。 要求: 项目:> com.stripe:stripe-android:11.1.4 找不到 androidx.annotation:annotation:1.1.0。 要求: 项目:> com.stripe:stripe-android:11.1.4 找不到 androidx.appcompat:appcompat:1.1.0。 要求: 项目:> com.stripe:stripe-android:11.1.4 找不到 androidx.recyclerview:recyclerview:1.0.0。 要求: 项目:> com.stripe:stripe-android:11.1.4

有什么帮助吗?

【问题讨论】:

    标签: android heroku stripe-payments


    【解决方案1】:

    看起来您正在尝试在后端使用 stripe-android。您应该使用stripe-java。此外,stripe-android 的 v11.x 需要 AndroidX。

    【讨论】:

      猜你喜欢
      • 2021-01-03
      • 2015-02-07
      • 1970-01-01
      • 2018-02-13
      • 2015-01-05
      • 2017-02-16
      • 2014-11-28
      • 2021-08-31
      • 1970-01-01
      相关资源
      最近更新 更多