Razorpay的Payment对象没有任何字段

时间:2019-01-12 13:12:17

标签: java razorpay

我刚刚开始阅读Razorpay文档。根据他们的文档,他们的Payment对象具有结构

{
  "id": "pay_29QQoUBi66xm2f",
  "entity": "payment",
  "amount": 5000,
  "currency": "INR",
  "status": "captured",
  "method": "card",
  "description": "Payment for adidas shoes",
  "amount_refunded": 0,
  "refund_status": null,
  "email": "test@razorpay.com",
  "contact": "9364591752",
  "notes": {},
  "fee": 1145,
  "tax": 145,
  "error_code": null,
  "error_description": null,
  "created_at": 1400826750
}

但是,当我导入他们的对象import com.razorpay.Payment并在代码编辑器中单击该类时,我没有找到任何字段。

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.razorpay;

import org.json.JSONObject;

public class Payment extends Entity {
    public Payment(JSONObject jsonObject) {
        super(jsonObject);
    }
}

没有字段和获取方法。那么如何将Payment对象的内容映射到我的自定义类?我的理解错了吗?

谢谢。

1 个答案:

答案 0 :(得分:1)

您使用get()类中定义的Entity方法来获取所需的值。参见documentation of Razorpay Java SDK

Payment payment = razorpayClient.Payments.fetch("payment_id");
// The the Entity.get("attribute_key") method has flexible return types depending on the attribute
int amount = payment.get("amount");
String id = payment.get("id");
Date createdAt = payment.get("created_at");