0

我刚开始浏览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对象内容映射到我的自定义类?我的理解错了吗?

谢谢你。

4

1 回答 1

1

您使用get()在类中定义的方法Entity来获取您想要的值。请参阅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");
于 2019-01-12T15:13:28.137 回答