Reputation: 1522
I just started going through Razorpay
documentation. As per their document their Payment
object has the structure
{
"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": "[email protected]",
"contact": "9364591752",
"notes": {},
"fee": 1145,
"tax": 145,
"error_code": null,
"error_description": null,
"created_at": 1400826750
}
But when I imported their object import com.razorpay.Payment
and clicked on that class in my code editor I found no fields.
//
// 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);
}
}
There are no fields and getters. So How can I map the Payment
object contents to my custom class? Is my understanding wrong?
Thank you.
Upvotes: 0
Views: 320
Reputation: 19546
You use the get()
method, which is defined in the Entity
class, to get the values you want. See the 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");
Upvotes: 1