【问题标题】:How to integrate Stripe Payment in Android Java?如何在 Android Java 中集成 Stripe Payment?
【发布时间】:2021-03-08 14:21:31
【问题描述】:

我需要一个用于我的 Java Android 应用的 Stripe 实现,但是使用 Java 中的服务器,我不知道如何使用 node 或 php 来实现该服务器端,我在他们的文档上找到了一些东西:

https://stripe.com/docs/payments/accept-a-payment?integration=elements#android-create-payment-intent

但是,服务器端的解释很差。

到目前为止我所写的只是:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="30dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".Checkout">

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"

     >

     <ImageView
         android:layout_width="100dp"
         android:layout_height="100dp"
         android:src="@drawable/logo"
         android:layout_gravity="center"
         />

     <TextView
         android:id="@+id/youhavetopay"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"

         android:textSize="22sp"
         android:textColor="@color/colorPrimary"
         android:fontFamily="@font/muli_black"
         android:layout_gravity="center"
         />
     <com.stripe.android.view.CardInputWidget
         android:id="@+id/cardInputWidget"
         android:layout_marginTop="30dp"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         />


     <Button

         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:id="@+id/payButton"
         android:layout_gravity="center"
         android:layout_marginTop="20dp"
         />
 </LinearLayout>

</ScrollView>

还有这个

public class Checkout extends AppCompatActivity {

    Button payBtn;
    String message;
    String price;
    TextView text;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        setContentView(R.layout.activity_checkout);

        payBtn = findViewById(R.id.payButton);
        text = findViewById(R.id.youhavetopay);
        Bundle extras = getIntent().getExtras();
        if(extras != null) {
            message = extras.getString("message");
            price = extras.getString("passprice");
        }
        String t = "Pay $"+price;
        payBtn.setText(t);
        text.setText(message);




    }
}

我有这些实现:

    implementation "com.stripe:stripe-java:15.1.0"
    implementation 'com.stripe:stripe-android:15.1.0'
    implementation 'com.squareup.okhttp3:okhttp:4.4.0'
    implementation 'com.google.code.gson:gson:2.8.6'

我真的不明白我必须从他们的文档中做什么。我只想要一个从该卡付款的付款按钮,如果它被接受,请在数据库上做一些事情。简单的付款。

如果您能指导我,我将不胜感激!欢迎任何教程或建议。我试图从 GitHub 复制,但我看到很多导入的红线,我迷路了。 提前谢谢!

【问题讨论】:

    标签: java android stripe-payments


    【解决方案1】:

    此示例包括示例 Android clientJava server 实现。您应该能够克隆存储库并按照适当的自述文件运行这些示例并查看其工作原理。按照指南进行操作,如果您有更具体的问题,请提出。

    当然,您需要能够安装和构建 android 和 java 才能运行它。

    【讨论】:

      猜你喜欢
      • 2017-08-04
      • 2018-06-18
      • 2019-09-01
      • 1970-01-01
      • 2018-05-25
      • 2011-07-20
      • 1970-01-01
      • 2018-02-13
      • 1970-01-01
      相关资源
      最近更新 更多