Skip to content

Commit

Permalink
Added missing metadata to scheduled charge
Browse files Browse the repository at this point in the history
  • Loading branch information
AnasNaouchi committed Jul 12, 2023
1 parent 0bafcb9 commit 482f53d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
Binary file added file.ser
Binary file not shown.
8 changes: 8 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Jul 11 00:17:04 ICT 2023
sdk.dir=/Users/anass.n/Library/Android/sdk
7 changes: 7 additions & 0 deletions src/main/java/co/omise/models/schedules/ChargeSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static class Params extends co.omise.models.Params {
@JsonProperty
private String description;

@JsonProperty
private Map<String, Object> metadata;

public Params amount(long amount) {
this.amount = amount;
return this;
Expand All @@ -116,5 +119,9 @@ public Params description(String description) {
this.description = description;
return this;
}
public Params metadata(Map<String, Object> metadata) {
this.metadata = metadata;
return this;
}
}
}
16 changes: 10 additions & 6 deletions src/test/java/co/omise/live/LiveScheduleRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.junit.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.*;

Expand All @@ -24,7 +26,7 @@ public void setup() throws Exception {
}

@Test
@Ignore("only hit the network when we need to.")
//@Ignore("only hit the network when we need to.")
public void testLiveScheduleListGet() throws IOException, OmiseException {
Request<ScopedList<Schedule>> request =
new Schedule.ListRequestBuilder()
Expand Down Expand Up @@ -63,7 +65,7 @@ public void testLiveScheduleGet() throws IOException, OmiseException {
.name("testLiveSchedule")
.number("4242424242424242")
.securityCode("123")
.expiration(10, 2020))
.expiration(7, 2023))
.build();

Token token = client.sendRequest(tokenRequest);
Expand All @@ -75,18 +77,20 @@ public void testLiveScheduleGet() throws IOException, OmiseException {
.build();

Customer customer = client.sendRequest(customerRequest);

Map<String, Object> metadata = new HashMap<>();
metadata.put("testKey","testData");
Request<Schedule> scheduleRequest = new Schedule.CreateRequestBuilder()
.every(1)
.period(SchedulePeriod.Week)
.period(SchedulePeriod.Day)
.on(new ScheduleOn.Params().weekdays(Weekdays.Friday))
.endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 99))
.charge(new ChargeSchedule.Params()
.customer(customer.getId())
.amount(2000)
.currency("THB")
.description("Monthly membership fee"))
.build();
.description("Monthly membership fee")
.metadata(metadata)
).build();

Schedule createdSchedule = client.sendRequest(scheduleRequest);

Expand Down

0 comments on commit 482f53d

Please sign in to comment.