我用Razorpay来实现PaymentResultWithDataListener。实际上我需要order_idsignature所以我使用PaymentResultWithDataListener而不是使用PaymentResultListener,因为没有获得order_idsignature的选项。我已经跟踪了这些链接
https://docs.razorpay.com/v1/page/orders#verifying-the-signature
https://razorpay.com/mobile/
https://github.com/razorpay/razorpay-android-sample-app
但没有任何解决办法。
梅尼菲斯特锉刀

<meta-data
    android:name="com.razorpay.ApiKey"
    android:value="rzp_test_PLbERPkkqGZkOF" />

平地
api 'com.razorpay:checkout:1.5.4'

我搞错了
{"code":"BAD_REQUEST_ERROR","description":"ay_order_id is not a valid id"}

我在尝试这个密码
public class CheckoutActivity extends AppCompatActivity implements View.OnClickListener, PaymentResultWithDataListener {
    private static final String TAG = CheckoutActivity.class.getSimpleName();

    Button mCheckOutView;

    String OrderId = "";
    String signature = "";
    String order_id = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_payment_method);

        Checkout.preload(getApplicationContext());

        mCheckOutView = findViewById(R.id.check_out);

        mCheckOutView.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v == mCheckOutView) {
            startPayment();
        }
    }

    public void startPayment() {
        /*
          You need to pass current activity in order to let Razorpay create CheckoutActivity
         */
        final Activity activity = this;

        final Checkout co = new Checkout();

        try {
            JSONObject options = new JSONObject();
            options.put("name","Test");
            options.put("description", getString(R.string.app_name));
            options.put("key", getString(R.string.api_key));
            options.put("order_id","razorpay_order_id");
            options.put("signature","razorpay_signature");

            options.put("currency", "INR");
            options.put("amount", 100);

            JSONObject preFill = new JSONObject();
            preFill.put("email", "[email protected]");
            preFill.put("contact", "9999999999");

            options.put("prefill", preFill);

            JSONObject notesData=new JSONObject();
            notesData.put("Order Id","order123");
            notesData.put("address","Test Address");

            options.put("notes", notesData);

            JSONObject theme=new JSONObject();
            theme.put("color","#738598");
            theme.put("emi_mode",true);

            options.put("theme", theme);

            co.open(activity, options);
        } catch (Exception e) {
            Toast.makeText(activity, "Error in payment: " + e.getMessage(), Toast.LENGTH_SHORT).show();
            e.printStackTrace();
        }
    }

    @Override
    public void onPaymentSuccess(String s, PaymentData paymentData) {
        String paymentId = paymentData.getPaymentId();
        String signature = paymentData.getSignature();  // got null
        String orderId = paymentData.getOrderId();      // got null
    }

    @Override
    public void onPaymentError(int i, String s, PaymentData paymentData) {
        Log.e(TAG,s);  //error {"code":"BAD_REQUEST_ERROR","description":"ay_order_id is not a valid id"}
    }
}

如果删除这两行,则不会出现此错误。
options.put("order_id","razorpay_order_id");
options.put("signature","razorpay_signature");

但是paymentData.getSignature()paymentData.getOrderId()null
任何帮助都将不胜感激。

最佳答案

根据官方文档,当你开始结帐时,当商家的后端开始使用razorpay后端下订单时,你就会得到order_id
见图表。
至于签名,根据文档,不是你放的东西,而是来自服务器响应的东西,你必须在你的终端验证。检查here

09-04 13:50