• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Invoiced / invoiced-java / #255

02 Feb 2024 11:00PM CUT coverage: 81.958%. Remained the same
#255

push

github

jaredtking
Add publish action

695 of 848 relevant lines covered (81.96%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.29
/src/main/java/com/invoiced/entity/Charge.java
1
package com.invoiced.entity;
2

3
import com.fasterxml.jackson.annotation.JsonFilter;
4
import com.fasterxml.jackson.annotation.JsonIgnore;
5
import com.fasterxml.jackson.annotation.JsonInclude;
6
import com.fasterxml.jackson.annotation.JsonProperty;
7
import com.invoiced.exception.EntityException;
8
import com.invoiced.util.Util;
9

10
@JsonFilter("customFilter")
11
public final class Charge extends AbstractEntity<Charge> {
12

13
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
14
    @JsonProperty("id")
15
    public Long id;
16

17
    @JsonProperty(value = "object", access = JsonProperty.Access.WRITE_ONLY)
18
    public String object;
19

20
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
21
    @JsonProperty("customer")
22
    public Long customer;
23

24
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
25
    @JsonProperty("status")
26
    public String status;
27

28
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
29
    @JsonProperty("gateway")
30
    public String gateway;
31

32
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
33
    @JsonProperty("gateway_id")
34
    public String gatewayId;
35

36
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
37
    @JsonProperty("payment_source")
38
    public PaymentSource paymentSource;
39

40
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
41
    @JsonProperty("currency")
42
    public String currency;
43

44
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
45
    @JsonProperty("amount")
46
    public Double amount;
47

48
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
49
    @JsonProperty("failure_message")
50
    public String failureMessage;
51

52
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
53
    @JsonProperty("amount_refunded")
54
    public Double amountRefunded;
55

56
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
57
    @JsonProperty("refunded")
58
    public Boolean refunded;
59

60
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
61
    @JsonProperty("refunds")
62
    public Refund[] refunds;
63

64
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
65
    @JsonProperty("disputed")
66
    public Boolean disputed;
67

68
    @JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
69
    public Long createdAt;
70

71
    @JsonProperty(value = "updated_at", access = JsonProperty.Access.WRITE_ONLY)
72
    public Long updatedAt;
73

74
    public Charge(Connection conn) {
75
        super(conn, Charge.class);
1✔
76
        this.entityName = "/charges";
1✔
77
    }
1✔
78

79
    Charge() {
80
        super(Charge.class);
1✔
81
        this.entityName = "/charges";
1✔
82
    }
1✔
83

84
    @Override
85
    @JsonIgnore
86
    protected String getEntityId() {
87
        return String.valueOf(this.id);
×
88
    }
89

90
    @Override
91
    @JsonIgnore
92
    protected String[] getCreateExclusions() {
93
        return new String[]{
×
94
                "id", "payment_source", "failure_reason", "amount_refunded", "refunded", "created_at"
95
        };
96
    }
97

98
    @Override
99
    @JsonIgnore
100
    protected String[] getSaveExclusions() {
101
        return new String[]{
×
102
                "id",
103
                "customer",
104
                "created_at",
105
                "amount_refunded",
106
                "refunded"
107
        };
108
    }
109

110
    @JsonIgnore
111
    public Payment create(ChargeRequest chargeRequest) throws EntityException {
112
        try {
113
            String chargeRequestJson = chargeRequest.toJsonString();
1✔
114

115
            String response = this.getConnection().post("/charges", null, chargeRequestJson);
1✔
116

117
            return Util.getMapper().readValue(response, Payment.class);
1✔
118
        } catch (Throwable c) {
×
119

120
            throw new EntityException(c);
×
121
        }
122
    }
123
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc