Skip to content

Commit acf0bb5

Browse files
authoredJun 25, 2018
Merge pull request #537 from stripe/remi-add-charge-level3
Added support for Level III data on the Charge resource
2 parents 5b44568 + 1ef89eb commit acf0bb5

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed
 

‎src/main/java/com/stripe/model/Charge.java

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class Charge extends APIResource implements MetadataStore<Charge>, HasId
4444
String failureMessage;
4545
FraudDetails fraudDetails;
4646
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<Invoice> invoice;
47+
ChargeLevel3 level3;
4748
Boolean livemode;
4849
@Getter(onMethod = @__({@Override})) Map<String, String> metadata;
4950
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<Account> onBehalfOf;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.stripe.model;
2+
3+
import java.util.List;
4+
5+
import lombok.EqualsAndHashCode;
6+
import lombok.Getter;
7+
import lombok.Setter;
8+
9+
@Getter
10+
@Setter
11+
@EqualsAndHashCode(callSuper = false)
12+
public final class ChargeLevel3 extends StripeObject {
13+
protected List<ChargeLevel3LineItem> lineItems;
14+
protected String merchantReference;
15+
protected String shippingAddressZip;
16+
protected Long shippingAmount;
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.stripe.model;
2+
3+
import lombok.EqualsAndHashCode;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
7+
@Getter
8+
@Setter
9+
@EqualsAndHashCode(callSuper = false)
10+
public final class ChargeLevel3LineItem extends StripeObject {
11+
protected Long discountAmount;
12+
protected String productCode;
13+
protected String productDescription;
14+
protected Long quantity;
15+
protected Long taxAmount;
16+
protected Long unitCost;
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.stripe.model;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNotNull;
5+
6+
import com.stripe.BaseStripeTest;
7+
import com.stripe.net.APIResource;
8+
9+
import org.junit.Test;
10+
11+
public class ChargeLevel3Test extends BaseStripeTest {
12+
@Test
13+
public void testDeserialize() throws Exception {
14+
final String data = getResourceAsString("/api_fixtures/charge_level3.json");
15+
final ChargeLevel3 object = APIResource.GSON.fromJson(data, ChargeLevel3.class);
16+
assertEquals("1234", object.getMerchantReference());
17+
assertEquals(2, object.getLineItems().size());
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"line_items": [
3+
{
4+
"discount_amount": 200,
5+
"product_code": "1234",
6+
"product_description": "description 1",
7+
"quantity": 2,
8+
"tax_amount": 200,
9+
"unit_cost": 1000
10+
},
11+
{
12+
"discount_amount": 300,
13+
"product_code": "1235",
14+
"product_description": "description 2",
15+
"quantity": 3,
16+
"tax_amount": 300,
17+
"unit_cost": 3000
18+
}
19+
],
20+
"merchant_reference": "1234",
21+
"shipping_address_zip": "94110",
22+
"shipping_amount": 700
23+
}

0 commit comments

Comments
 (0)
Please sign in to comment.