|
| 1 | +package com.stripe.model; |
| 2 | + |
| 3 | +import com.stripe.exception.APIConnectionException; |
| 4 | +import com.stripe.exception.APIException; |
| 5 | +import com.stripe.exception.AuthenticationException; |
| 6 | +import com.stripe.exception.CardException; |
| 7 | +import com.stripe.exception.InvalidRequestException; |
| 8 | +import com.stripe.net.APIResource; |
| 9 | +import com.stripe.net.RequestOptions; |
| 10 | + |
| 11 | +import java.util.List; |
| 12 | +import java.util.Map; |
| 13 | + |
| 14 | +import lombok.AccessLevel; |
| 15 | +import lombok.EqualsAndHashCode; |
| 16 | +import lombok.Getter; |
| 17 | +import lombok.Setter; |
| 18 | + |
| 19 | +@Getter |
| 20 | +@Setter |
| 21 | +@EqualsAndHashCode(callSuper = false) |
| 22 | +public class PaymentIntent extends APIResource implements MetadataStore<PaymentIntent>, HasId { |
| 23 | + @Getter(onMethod = @__({@Override})) String id; |
| 24 | + String object; |
| 25 | + List<String> allowedSourceTypes; |
| 26 | + Long amount; |
| 27 | + Long amountCapturable; |
| 28 | + Long amountReceived; |
| 29 | + @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<Application> application; |
| 30 | + Long applicationFee; |
| 31 | + Long canceledAt; |
| 32 | + String captureMethod; |
| 33 | + ChargeCollection charges; |
| 34 | + String clientSecret; |
| 35 | + String confirmationMethod; |
| 36 | + Long created; |
| 37 | + String currency; |
| 38 | + @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<Customer> customer; |
| 39 | + Boolean livemode; |
| 40 | + @Getter(onMethod = @__({@Override})) Map<String, String> metadata; |
| 41 | + PaymentIntentSourceAction nextSourceAction; |
| 42 | + @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<Account> onBehalfOf; |
| 43 | + String receiptEmail; |
| 44 | + String returnUrl; |
| 45 | + Boolean saveSourcetoCustomer; |
| 46 | + ShippingDetails shipping; |
| 47 | + @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<ExternalAccount> source; |
| 48 | + String statementDescriptor; |
| 49 | + PaymentIntentTransferData transferData; |
| 50 | + String status; |
| 51 | + |
| 52 | + // <editor-fold desc="application"> |
| 53 | + public String getApplication() { |
| 54 | + return (this.application != null) ? this.application.getId() : null; |
| 55 | + } |
| 56 | + |
| 57 | + public void setApplication(String applicationID) { |
| 58 | + this.application = setExpandableFieldID(applicationID, this.application); |
| 59 | + } |
| 60 | + |
| 61 | + public Application getApplicationObject() { |
| 62 | + return (this.application != null) ? this.application.getExpanded() : null; |
| 63 | + } |
| 64 | + |
| 65 | + public void setApplicationObject(Application c) { |
| 66 | + this.application = new ExpandableField<Application>(c.getId(), c); |
| 67 | + } |
| 68 | + // </editor-fold> |
| 69 | + |
| 70 | + // <editor-fold desc="customer"> |
| 71 | + public String getCustomer() { |
| 72 | + return (this.customer != null) ? this.customer.getId() : null; |
| 73 | + } |
| 74 | + |
| 75 | + public void setCustomer(String customerID) { |
| 76 | + this.customer = setExpandableFieldID(customerID, this.customer); |
| 77 | + |
| 78 | + } |
| 79 | + |
| 80 | + public Customer getCustomerObject() { |
| 81 | + return (this.customer != null) ? this.customer.getExpanded() : null; |
| 82 | + } |
| 83 | + |
| 84 | + public void setCustomerObject(Customer c) { |
| 85 | + this.customer = new ExpandableField<Customer>(c.getId(), c); |
| 86 | + } |
| 87 | + // </editor-fold> |
| 88 | + |
| 89 | + // <editor-fold desc="onBehalfOf"> |
| 90 | + public String getOnBehalfOf() { |
| 91 | + return (this.onBehalfOf != null) ? this.onBehalfOf.getId() : null; |
| 92 | + } |
| 93 | + |
| 94 | + public void setOnBehalfOf(String onBehalfOfID) { |
| 95 | + this.onBehalfOf = APIResource.setExpandableFieldID(onBehalfOfID, this.onBehalfOf); |
| 96 | + } |
| 97 | + |
| 98 | + public Account getOnBehalfOfObject() { |
| 99 | + return (this.onBehalfOf != null) ? this.onBehalfOf.getExpanded() : null; |
| 100 | + } |
| 101 | + |
| 102 | + public void setOnBehalfOfObject(Account c) { |
| 103 | + this.onBehalfOf = new ExpandableField<Account>(c.getId(), c); |
| 104 | + } |
| 105 | + // </editor-fold> |
| 106 | + |
| 107 | + // <editor-fold desc="source"> |
| 108 | + public String getSource() { |
| 109 | + return (this.source != null) ? this.source.getId() : null; |
| 110 | + } |
| 111 | + |
| 112 | + public void setSource(String sourceID) { |
| 113 | + this.source = APIResource.setExpandableFieldID(sourceID, this.source); |
| 114 | + } |
| 115 | + |
| 116 | + public ExternalAccount getSourceObject() { |
| 117 | + return (this.source != null) ? this.source.getExpanded() : null; |
| 118 | + } |
| 119 | + |
| 120 | + public void setSourceObject(Account c) { |
| 121 | + this.onBehalfOf = new ExpandableField<Account>(c.getId(), c); |
| 122 | + } |
| 123 | + // </editor-fold> |
| 124 | + |
| 125 | + // <editor-fold desc="cancel"> |
| 126 | + /** |
| 127 | + * Cancel a payment intent. |
| 128 | + */ |
| 129 | + public PaymentIntent cancel() |
| 130 | + throws AuthenticationException, InvalidRequestException, |
| 131 | + APIConnectionException, CardException, APIException { |
| 132 | + return cancel(null); |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Cancel a payment intent. |
| 137 | + */ |
| 138 | + public PaymentIntent cancel(RequestOptions options) |
| 139 | + throws AuthenticationException, InvalidRequestException, |
| 140 | + APIConnectionException, CardException, APIException { |
| 141 | + return request(RequestMethod.POST, instanceURL(PaymentIntent.class, this.id) + "/cancel", null, |
| 142 | + PaymentIntent.class, options); |
| 143 | + } |
| 144 | + // </editor-fold> |
| 145 | + |
| 146 | + // <editor-fold desc="capture"> |
| 147 | + /** |
| 148 | + * capture a payment intent. |
| 149 | + */ |
| 150 | + public PaymentIntent capture() |
| 151 | + throws AuthenticationException, InvalidRequestException, |
| 152 | + APIConnectionException, CardException, APIException { |
| 153 | + return capture(null); |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * capture a payment intent. |
| 158 | + */ |
| 159 | + public PaymentIntent capture(RequestOptions options) |
| 160 | + throws AuthenticationException, InvalidRequestException, |
| 161 | + APIConnectionException, CardException, APIException { |
| 162 | + return request(RequestMethod.POST, instanceURL(PaymentIntent.class, this.id) + "/capture", null, |
| 163 | + PaymentIntent.class, options); |
| 164 | + } |
| 165 | + // </editor-fold> |
| 166 | + |
| 167 | + // <editor-fold desc="confirm"> |
| 168 | + /** |
| 169 | + * confirm a payment intent. |
| 170 | + */ |
| 171 | + public PaymentIntent confirm() |
| 172 | + throws AuthenticationException, InvalidRequestException, |
| 173 | + APIConnectionException, CardException, APIException { |
| 174 | + return confirm(null); |
| 175 | + } |
| 176 | + |
| 177 | + /** |
| 178 | + * confirm a payment intent. |
| 179 | + */ |
| 180 | + public PaymentIntent confirm(RequestOptions options) |
| 181 | + throws AuthenticationException, InvalidRequestException, |
| 182 | + APIConnectionException, CardException, APIException { |
| 183 | + return request(RequestMethod.POST, instanceURL(PaymentIntent.class, this.id) + "/confirm", null, |
| 184 | + PaymentIntent.class, options); |
| 185 | + } |
| 186 | + // </editor-fold> |
| 187 | + |
| 188 | + // <editor-fold desc="create"> |
| 189 | + /** |
| 190 | + * Create a payment intent. |
| 191 | + */ |
| 192 | + public static PaymentIntent create(Map<String, Object> params) |
| 193 | + throws AuthenticationException, InvalidRequestException, |
| 194 | + APIConnectionException, CardException, APIException { |
| 195 | + return create(params, null); |
| 196 | + } |
| 197 | + |
| 198 | + /** |
| 199 | + * Create a payment intent. |
| 200 | + */ |
| 201 | + public static PaymentIntent create(Map<String, Object> params, RequestOptions options) |
| 202 | + throws AuthenticationException, InvalidRequestException, |
| 203 | + APIConnectionException, CardException, APIException { |
| 204 | + return request(RequestMethod.POST, classURL(PaymentIntent.class), params, |
| 205 | + PaymentIntent.class, options); |
| 206 | + } |
| 207 | + // </editor-fold> |
| 208 | + |
| 209 | + // <editor-fold desc="list"> |
| 210 | + /** |
| 211 | + * List all payment intents. |
| 212 | + */ |
| 213 | + public static PaymentIntentCollection list(Map<String, Object> params) |
| 214 | + throws AuthenticationException, InvalidRequestException, |
| 215 | + APIConnectionException, CardException, APIException { |
| 216 | + return list(params, null); |
| 217 | + } |
| 218 | + |
| 219 | + /** |
| 220 | + * List all payment intents. |
| 221 | + */ |
| 222 | + public static PaymentIntentCollection list(Map<String, Object> params, RequestOptions options) |
| 223 | + throws AuthenticationException, InvalidRequestException, APIConnectionException, |
| 224 | + CardException, APIException { |
| 225 | + return requestCollection(classURL(PaymentIntent.class), params, |
| 226 | + PaymentIntentCollection.class, options); |
| 227 | + } |
| 228 | + // </editor-fold> |
| 229 | + |
| 230 | + // <editor-fold desc="retrieve"> |
| 231 | + /** |
| 232 | + * Retrieve a payment intent. |
| 233 | + */ |
| 234 | + public static PaymentIntent retrieve(String id) throws AuthenticationException, |
| 235 | + InvalidRequestException, APIConnectionException, CardException, |
| 236 | + APIException { |
| 237 | + return retrieve(id, null); |
| 238 | + } |
| 239 | + |
| 240 | + /** |
| 241 | + * Retrieve a payment intent. |
| 242 | + */ |
| 243 | + public static PaymentIntent retrieve(String id, RequestOptions options) |
| 244 | + throws AuthenticationException, InvalidRequestException, |
| 245 | + APIConnectionException, CardException, APIException { |
| 246 | + return request(RequestMethod.GET, instanceURL(PaymentIntent.class, id), null, |
| 247 | + PaymentIntent.class, options); |
| 248 | + } |
| 249 | + |
| 250 | + /** |
| 251 | + * Retrieve a payment intent. |
| 252 | + */ |
| 253 | + public static PaymentIntent retrieve(String id, Map<String, Object> params, |
| 254 | + RequestOptions options) |
| 255 | + throws AuthenticationException, InvalidRequestException, |
| 256 | + APIConnectionException, CardException, APIException { |
| 257 | + return request(RequestMethod.GET, instanceURL(PaymentIntent.class, id), params, |
| 258 | + PaymentIntent.class, options); |
| 259 | + } |
| 260 | + // </editor-fold> |
| 261 | + |
| 262 | + // <editor-fold desc="update"> |
| 263 | + /** |
| 264 | + * Update a payment intent. |
| 265 | + */ |
| 266 | + @Override |
| 267 | + public PaymentIntent update(Map<String, Object> params) |
| 268 | + throws AuthenticationException, InvalidRequestException, |
| 269 | + APIConnectionException, CardException, APIException { |
| 270 | + return update(params, null); |
| 271 | + } |
| 272 | + |
| 273 | + /** |
| 274 | + * Update a payment intent. |
| 275 | + */ |
| 276 | + @Override |
| 277 | + public PaymentIntent update(Map<String, Object> params, RequestOptions options) |
| 278 | + throws AuthenticationException, InvalidRequestException, |
| 279 | + APIConnectionException, CardException, APIException { |
| 280 | + return request(RequestMethod.POST, instanceURL(PaymentIntent.class, this.id), params, |
| 281 | + PaymentIntent.class, |
| 282 | + options); |
| 283 | + } |
| 284 | + // </editor-fold> |
| 285 | +} |
0 commit comments