com.cashfree.pg.model.CFOrderPayResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
Cashfree Payments, PG Java SDK
/*
* New Payment Gateway APIs
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2022-01-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.cashfree.pg.model;
import com.cashfree.pg.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import org.openapitools.jackson.nullable.JsonNullable;
/** CFOrderPayResponse */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
date = "2023-03-16T14:01:52.135917+05:30[Asia/Kolkata]")
public class CFOrderPayResponse {
public static final String SERIALIZED_NAME_CF_PAYMENT_ID = "cf_payment_id";
@SerializedName(SERIALIZED_NAME_CF_PAYMENT_ID)
private Integer cfPaymentId;
public static final String SERIALIZED_NAME_PAYMENT_AMOUNT = "payment_amount";
@SerializedName(SERIALIZED_NAME_PAYMENT_AMOUNT)
private BigDecimal paymentAmount;
/**
* One of [\"upi\", \"netbanking\", \"card\", \"app\",
* \"cardless_emi\", \"paylater\"]
*/
@JsonAdapter(PaymentMethodEnum.Adapter.class)
public enum PaymentMethodEnum {
NETBANKING("netbanking"),
CARD("card"),
UPI("upi"),
APP("app"),
CARDLESS_EMI("cardless_emi"),
PAYLATER("paylater");
private String value;
PaymentMethodEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static PaymentMethodEnum fromValue(String value) {
for (PaymentMethodEnum b : PaymentMethodEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final PaymentMethodEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public PaymentMethodEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return PaymentMethodEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_PAYMENT_METHOD = "payment_method";
@SerializedName(SERIALIZED_NAME_PAYMENT_METHOD)
private PaymentMethodEnum paymentMethod;
/**
* One of [\"link\", \"collect\", \"qrcode\"]. In an older version
* we used to support different channels like 'gpay', 'phonepe' etc. However, we
* now support only the following channels - link, collect and qrcode. To process payments using
* gpay, you will have to provide channel as 'link' and provider as 'gpay'
*/
@JsonAdapter(ChannelEnum.Adapter.class)
public enum ChannelEnum {
LINK("link"),
COLLECT("collect"),
QRCODE("qrcode");
private String value;
ChannelEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static ChannelEnum fromValue(String value) {
for (ChannelEnum b : ChannelEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final ChannelEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public ChannelEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return ChannelEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_CHANNEL = "channel";
@SerializedName(SERIALIZED_NAME_CHANNEL)
private ChannelEnum channel;
/** One of [\"link\", \"custom\", \"form\"] */
@JsonAdapter(ActionEnum.Adapter.class)
public enum ActionEnum {
LINK("link"),
CUSTOM("custom"),
FORM("form");
private String value;
ActionEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static ActionEnum fromValue(String value) {
for (ActionEnum b : ActionEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
return null;
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final ActionEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public ActionEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return ActionEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_ACTION = "action";
@SerializedName(SERIALIZED_NAME_ACTION)
private ActionEnum action;
public static final String SERIALIZED_NAME_DATA = "data";
@SerializedName(SERIALIZED_NAME_DATA)
private CFOrderPayData data;
public CFOrderPayResponse() {}
public CFOrderPayResponse cfPaymentId(Integer cfPaymentId) {
this.cfPaymentId = cfPaymentId;
return this;
}
/**
* Payment identifier created by Cashfree
*
* @return cfPaymentId
*/
@javax.annotation.Nullable
public Integer getCfPaymentId() {
return cfPaymentId;
}
public void setCfPaymentId(Integer cfPaymentId) {
this.cfPaymentId = cfPaymentId;
}
public CFOrderPayResponse paymentAmount(BigDecimal paymentAmount) {
this.paymentAmount = paymentAmount;
return this;
}
/**
* Get paymentAmount
*
* @return paymentAmount
*/
@javax.annotation.Nullable
public BigDecimal getPaymentAmount() {
return paymentAmount;
}
public void setPaymentAmount(BigDecimal paymentAmount) {
this.paymentAmount = paymentAmount;
}
public CFOrderPayResponse paymentMethod(PaymentMethodEnum paymentMethod) {
this.paymentMethod = paymentMethod;
return this;
}
/**
* One of [\"upi\", \"netbanking\", \"card\", \"app\",
* \"cardless_emi\", \"paylater\"]
*
* @return paymentMethod
*/
@javax.annotation.Nullable
public PaymentMethodEnum getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(PaymentMethodEnum paymentMethod) {
this.paymentMethod = paymentMethod;
}
public CFOrderPayResponse channel(ChannelEnum channel) {
this.channel = channel;
return this;
}
/**
* One of [\"link\", \"collect\", \"qrcode\"]. In an older version
* we used to support different channels like 'gpay', 'phonepe' etc. However, we
* now support only the following channels - link, collect and qrcode. To process payments using
* gpay, you will have to provide channel as 'link' and provider as 'gpay'
*
* @return channel
*/
@javax.annotation.Nullable
public ChannelEnum getChannel() {
return channel;
}
public void setChannel(ChannelEnum channel) {
this.channel = channel;
}
public CFOrderPayResponse action(ActionEnum action) {
this.action = action;
return this;
}
/**
* One of [\"link\", \"custom\", \"form\"]
*
* @return action
*/
@javax.annotation.Nullable
public ActionEnum getAction() {
return action;
}
public void setAction(ActionEnum action) {
this.action = action;
}
public CFOrderPayResponse data(CFOrderPayData data) {
this.data = data;
return this;
}
/**
* Get data
*
* @return data
*/
@javax.annotation.Nullable
public CFOrderPayData getData() {
return data;
}
public void setData(CFOrderPayData data) {
this.data = data;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CFOrderPayResponse cfOrderPayResponse = (CFOrderPayResponse) o;
return Objects.equals(this.cfPaymentId, cfOrderPayResponse.cfPaymentId)
&& Objects.equals(this.paymentAmount, cfOrderPayResponse.paymentAmount)
&& Objects.equals(this.paymentMethod, cfOrderPayResponse.paymentMethod)
&& Objects.equals(this.channel, cfOrderPayResponse.channel)
&& Objects.equals(this.action, cfOrderPayResponse.action)
&& Objects.equals(this.data, cfOrderPayResponse.data);
}
private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
return a == b
|| (a != null
&& b != null
&& a.isPresent()
&& b.isPresent()
&& Objects.deepEquals(a.get(), b.get()));
}
@Override
public int hashCode() {
return Objects.hash(cfPaymentId, paymentAmount, paymentMethod, channel, action, data);
}
private static int hashCodeNullable(JsonNullable a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CFOrderPayResponse {\n");
sb.append(" cfPaymentId: ").append(toIndentedString(cfPaymentId)).append("\n");
sb.append(" paymentAmount: ").append(toIndentedString(paymentAmount)).append("\n");
sb.append(" paymentMethod: ").append(toIndentedString(paymentMethod)).append("\n");
sb.append(" channel: ").append(toIndentedString(channel)).append("\n");
sb.append(" action: ").append(toIndentedString(action)).append("\n");
sb.append(" data: ").append(toIndentedString(data)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces (except the first
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static HashSet openapiFields;
public static HashSet openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet();
openapiFields.add("cf_payment_id");
openapiFields.add("payment_amount");
openapiFields.add("payment_method");
openapiFields.add("channel");
openapiFields.add("action");
openapiFields.add("data");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* Validates the JSON Object and throws an exception if issues found
*
* @param jsonObj JSON Object
* @throws IOException if the JSON Object is invalid with respect to CFOrderPayResponse
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!CFOrderPayResponse.openapiRequiredFields
.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(
String.format(
"The required field(s) %s in CFOrderPayResponse is not found in"
+ " the empty JSON string",
CFOrderPayResponse.openapiRequiredFields.toString()));
}
}
Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!CFOrderPayResponse.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(
String.format(
"The field `%s` in the JSON string is not defined in the"
+ " `CFOrderPayResponse` properties. JSON: %s",
entry.getKey(), jsonObj.toString()));
}
}
if ((jsonObj.get("payment_method") != null && !jsonObj.get("payment_method").isJsonNull())
&& !jsonObj.get("payment_method").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `payment_method` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("payment_method").toString()));
}
if ((jsonObj.get("channel") != null && !jsonObj.get("channel").isJsonNull())
&& !jsonObj.get("channel").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `channel` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("channel").toString()));
}
if ((jsonObj.get("action") != null && !jsonObj.get("action").isJsonNull())
&& !jsonObj.get("action").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `action` to be a primitive type in the JSON string"
+ " but got `%s`",
jsonObj.get("action").toString()));
}
// validate the optional field `data`
if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) {
CFOrderPayData.validateJsonObject(jsonObj.getAsJsonObject("data"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CFOrderPayResponse.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CFOrderPayResponse' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter =
gson.getDelegateAdapter(this, TypeToken.get(CFOrderPayResponse.class));
return (TypeAdapter)
new TypeAdapter() {
@Override
public void write(JsonWriter out, CFOrderPayResponse value)
throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public CFOrderPayResponse read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of CFOrderPayResponse given an JSON string
*
* @param jsonString JSON string
* @return An instance of CFOrderPayResponse
* @throws IOException if the JSON string is invalid with respect to CFOrderPayResponse
*/
public static CFOrderPayResponse fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CFOrderPayResponse.class);
}
/**
* Convert an instance of CFOrderPayResponse to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}