-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a80494
commit 61841ae
Showing
10 changed files
with
286 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.twikey; | ||
|
||
import com.twikey.callback.DocumentCallback; | ||
import com.twikey.modal.Customer; | ||
import org.json.JSONObject; | ||
import org.junit.Assume; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class DocumentGatewayTest { | ||
|
||
private final String apiKey = System.getenv("TWIKEY_API_KEY"); // found in https://www.twikey.com/r/admin#/c/settings/api | ||
|
||
private final String ct = System.getenv("CT"); // found @ https://www.twikey.com/r/admin#/c/template | ||
|
||
private Customer customer; | ||
|
||
private TwikeyClient api; | ||
|
||
@Before | ||
public void createCustomer(){ | ||
customer = new Customer() | ||
.setNumber("customerNum123") | ||
.setEmail("no-reply@example.com") | ||
.setFirstname("Twikey") | ||
.setLastname("Support") | ||
.setStreet("Derbystraat 43") | ||
.setCity("Gent") | ||
.setZip("9000") | ||
.setCountry("BE") | ||
.setLang("nl") | ||
.setMobile("32498665995"); | ||
|
||
api = new TwikeyClient(apiKey,true) | ||
.withUserAgent("twikey-api-java/junit"); | ||
} | ||
|
||
@Test | ||
public void testInviteMandateWithoutCustomerDetails() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey); | ||
JSONObject response = api.document().create(Long.parseLong(ct), null, new HashMap<>()); | ||
assertNotNull("Invite URL",response.getString("url")); | ||
assertNotNull("Document Reference",response.getString("mndtId")); | ||
} | ||
|
||
@Test | ||
public void testInviteMandateCustomerDetails() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey); | ||
JSONObject response = api.document().create(Long.parseLong(ct), customer, new HashMap<>()); | ||
assertNotNull("Invite URL",response.getString("url")); | ||
assertNotNull("Document Reference",response.getString("mndtId")); | ||
} | ||
|
||
@Test | ||
public void getMandatesAndDetails() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey); | ||
api.document().feed(new DocumentCallback() { | ||
@Override | ||
public void newDocument(JSONObject newMandate) { | ||
System.out.println("New mandate: "+newMandate); | ||
} | ||
|
||
@Override | ||
public void updatedDocument(JSONObject updatedMandate) { | ||
System.out.println("Updated mandate: "+updatedMandate); | ||
} | ||
|
||
@Override | ||
public void cancelledDocument(JSONObject cancelledMandate) { | ||
System.out.println("Cancelled mandate: "+cancelledMandate); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.twikey; | ||
|
||
import com.twikey.modal.Customer; | ||
import junit.framework.TestCase; | ||
import org.json.JSONObject; | ||
import org.junit.Assume; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class InvoiceGatewayTest { | ||
|
||
private final String apiKey = System.getenv("TWIKEY_API_KEY"); // found in https://www.twikey.com/r/admin#/c/settings/api | ||
|
||
private final String ct = System.getenv("CT"); // found @ https://www.twikey.com/r/admin#/c/template | ||
|
||
private Customer customer; | ||
|
||
private TwikeyClient api; | ||
|
||
@Before | ||
public void createCustomer() { | ||
customer = new Customer() | ||
.setNumber("customerNum123") | ||
.setEmail("no-reply@example.com") | ||
.setFirstname("Twikey") | ||
.setLastname("Support") | ||
.setStreet("Derbystraat 43") | ||
.setCity("Gent") | ||
.setZip("9000") | ||
.setCountry("BE") | ||
.setLang("nl") | ||
.setMobile("32498665995"); | ||
|
||
api = new TwikeyClient(apiKey, true) | ||
.withUserAgent("twikey-api-java/junit"); | ||
} | ||
|
||
@Test | ||
public void testCreateInvoice() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey, ct); | ||
Map<String, String> invoiceDetails = new HashMap<>(); | ||
invoiceDetails.put("number", "Invss123"); | ||
invoiceDetails.put("title", "Invoice April"); | ||
invoiceDetails.put("remittance", "123456789123"); | ||
invoiceDetails.put("amount", "10.90"); | ||
invoiceDetails.put("date", "2020-03-20"); | ||
invoiceDetails.put("duedate", "2020-04-28"); | ||
JSONObject invoiceResponse = api.invoice().create(Long.parseLong(ct), customer, invoiceDetails); | ||
assertNotNull("Payment URL", invoiceResponse.getString("url")); | ||
assertNotNull("Invoice Id", invoiceResponse.getString("id")); | ||
} | ||
|
||
|
||
@Test | ||
public void getInvoicesAndDetails() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey); | ||
api.invoice().feed(updatedInvoice -> System.out.println("Updated invoice: " + updatedInvoice)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.twikey; | ||
|
||
import com.twikey.modal.Customer; | ||
import org.json.JSONObject; | ||
import org.junit.Assume; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertNotEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class PaylinkGatewayTest { | ||
|
||
private final String apiKey = System.getenv("TWIKEY_API_KEY"); // found in https://www.twikey.com/r/admin#/c/settings/api | ||
|
||
private final String ct = System.getenv("CT"); // found @ https://www.twikey.com/r/admin#/c/template | ||
|
||
private Customer customer; | ||
|
||
private TwikeyClient api; | ||
|
||
@Before | ||
public void createCustomer() { | ||
customer = new Customer() | ||
.setNumber("customerNum123") | ||
.setEmail("no-reply@example.com") | ||
.setFirstname("Twikey") | ||
.setLastname("Support") | ||
.setStreet("Derbystraat 43") | ||
.setCity("Gent") | ||
.setZip("9000") | ||
.setCountry("BE") | ||
.setLang("nl") | ||
.setMobile("32498665995"); | ||
|
||
api = new TwikeyClient(apiKey, true) | ||
.withUserAgent("twikey-api-java/junit"); | ||
} | ||
|
||
@Test | ||
public void testCreate() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey, ct); | ||
Map<String, String> extra = new HashMap<>(); | ||
extra.put("message", "Test Link"); | ||
extra.put("amount", "10.00"); | ||
JSONObject linkResponse = api.paylink().create(Long.parseLong(ct), customer, extra); | ||
assertNotNull("Payment URL", linkResponse.getString("url")); | ||
assertNotEquals(0, linkResponse.getLong("id")); | ||
|
||
} | ||
|
||
@Test | ||
public void testFeed() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey); | ||
api.paylink().feed(updatedLink -> System.out.println("Updated link: " + updatedLink)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.twikey; | ||
|
||
import org.json.JSONObject; | ||
import org.junit.Assume; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class TransactionGatewayTest { | ||
|
||
private final String apiKey = System.getenv("TWIKEY_API_KEY"); // found in https://www.twikey.com/r/admin#/c/settings/api | ||
|
||
private final String mandateNumber = System.getenv("mndtNumber"); | ||
|
||
private TwikeyClient api; | ||
|
||
@Before | ||
public void prepClient() { | ||
api = new TwikeyClient(apiKey, true) | ||
.withUserAgent("twikey-api-java/junit"); | ||
} | ||
|
||
@Test | ||
public void testCreate() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey,mandateNumber); | ||
Map<String, String> extra = new HashMap<>(); | ||
extra.put("message", "Test Message"); | ||
extra.put("amount", "10.00"); | ||
JSONObject linkResponse = api.transaction().create(mandateNumber, extra); | ||
System.out.println(linkResponse); | ||
assertNotNull("Payment URL", linkResponse.getString("url")); | ||
assertNotNull("Invoice Id", linkResponse.getString("id")); | ||
} | ||
|
||
@Test | ||
public void testFeed() throws IOException, TwikeyClient.UserException { | ||
Assume.assumeNotNull(apiKey); | ||
api.transaction().feed(updatedTransaction -> System.out.println("Updated transaction: " + updatedTransaction)); | ||
} | ||
|
||
} |
Oops, something went wrong.