Skip to content

Added support for Level III data on the Charge resource #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/com/stripe/model/Charge.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class Charge extends APIResource implements MetadataStore<Charge>, HasId
String failureMessage;
FraudDetails fraudDetails;
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<Invoice> invoice;
ChargeLevel3 level3;
Boolean livemode;
@Getter(onMethod = @__({@Override})) Map<String, String> metadata;
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<Account> onBehalfOf;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/stripe/model/ChargeLevel3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stripe.model;

import java.util.List;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public final class ChargeLevel3 extends StripeObject {
protected List<ChargeLevel3LineItem> lineItems;
protected String merchantReference;
protected String shippingAddressZip;
protected Long shippingAmount;
}
17 changes: 17 additions & 0 deletions src/main/java/com/stripe/model/ChargeLevel3LineItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stripe.model;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public final class ChargeLevel3LineItem extends StripeObject {
protected Long discountAmount;
protected String productCode;
protected String productDescription;
protected Long quantity;
protected Long taxAmount;
protected Long unitCost;
}
19 changes: 19 additions & 0 deletions src/test/java/com/stripe/model/ChargeLevel3Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.stripe.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import com.stripe.BaseStripeTest;
import com.stripe.net.APIResource;

import org.junit.Test;

public class ChargeLevel3Test extends BaseStripeTest {
@Test
public void testDeserialize() throws Exception {
final String data = getResourceAsString("/api_fixtures/charge_level3.json");
final ChargeLevel3 object = APIResource.GSON.fromJson(data, ChargeLevel3.class);
assertEquals("1234", object.getMerchantReference());
assertEquals(2, object.getLineItems().size());
}
}
23 changes: 23 additions & 0 deletions src/test/resources/api_fixtures/charge_level3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"line_items": [
{
"discount_amount": 200,
"product_code": "1234",
"product_description": "description 1",
"quantity": 2,
"tax_amount": 200,
"unit_cost": 1000
},
{
"discount_amount": 300,
"product_code": "1235",
"product_description": "description 2",
"quantity": 3,
"tax_amount": 300,
"unit_cost": 3000
}
],
"merchant_reference": "1234",
"shipping_address_zip": "94110",
"shipping_amount": 700
}