Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Fix getRequest JSONArray to query logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MauricioMurga committed Jan 29, 2015
1 parent e315a6d commit cd2eafc
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
=== 1.0.5 2014-10-07
* Change url encoded to json data in http request.
=== 1.0.6 2014-10-07
* Fix getRequest JSONArray to query logic.
=== 1.0.7 2014-10-07
* Fix getRequest JSONArray to query logic.
2 changes: 1 addition & 1 deletion build/built-jar.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Wed, 28 Jan 2015 18:22:37 -0600
#Thu, 29 Jan 2015 10:48:18 -0600


/home/mauricio/NetBeansProjects/ConektaJava=
Binary file modified build/classes/com/conekta/Conekta.class
Binary file not shown.
Binary file modified build/classes/com/conekta/Requestor.class
Binary file not shown.
Binary file modified dist/ConektaJava.jar
Binary file not shown.
6 changes: 2 additions & 4 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/home/mauricio/NetBeansProjects/ConektaJava/src/com/conekta/Conekta.java</file>
<file>file:/home/mauricio/NetBeansProjects/ConektaJava/test/com/conekta/ConektaTest.java</file>
<file>file:/home/mauricio/NetBeansProjects/ConektaJava/test/com/conekta/ChargeTest.java</file>
<file>file:/home/mauricio/NetBeansProjects/ConektaJava/src/com/conekta/Requestor.java</file>
<file>file:/home/mauricio/NetBeansProjects/ConektaJava/src/com/conekta/SpeiPayment.java</file>
</group>
</open-files>
</project-private>
2 changes: 1 addition & 1 deletion src/com/conekta/Conekta.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class Conekta {
public static String apiKey;
public static String apiBase = "https://api.conekta.io";
public static String apiVersion = "1.0.0";
public static final String VERSION = "1.0.6";
public static final String VERSION = "1.0.7";

public static void setApiKey(String apiKey) {
Conekta.apiKey = apiKey;
Expand Down
4 changes: 3 additions & 1 deletion src/com/conekta/Requestor.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public Object request(String method, String url, JSONObject params) throws Error
try {
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
writer.write(Requestor.getQuery(params, null));
String r = Requestor.getQuery(params, null);
writer.write(r);
writer.flush();
writer.close();
os.close();
Expand Down Expand Up @@ -196,6 +197,7 @@ private static String getQuery(JSONObject jsonObject, String index) throws Excep
result.append("=");
result.append(URLEncoder.encode(array.getString(i), "UTF-8"));
}
result.append("&");
}

} else {
Expand Down
55 changes: 47 additions & 8 deletions test/com/conekta/ChargeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ChargeTest extends ConektaTest {
JSONObject valid_payment_method;
JSONObject invalid_payment_method;
JSONObject valid_visa_card;
JSONObject params;

public ChargeTest() throws JSONException {
super();
Expand All @@ -32,9 +33,50 @@ public ChargeTest() throws JSONException {
"'amount':10," +
"'currency':'MXN'}");
valid_visa_card = new JSONObject("{'card':'tok_test_visa_4242'}");
}


params = new JSONObject("{"+
" 'currency': 'MXN',"+
" 'details': {"+
" 'billing_address': {"+
" 'zip': '53422',"+
" 'state': 'Estado de Mexico',"+
" 'country': 'MX',"+
" 'city': 'Naucalpan',"+
" 'email': 'oscar.jimenez+loctommy@edgebound.com',"+
" 'phone': '5514945290',"+
" 'street1': 'Los Remedios 17, Loma Colorada 2a Seccion'"+
" },"+
" 'line_items': ["+
" {"+
" 'type': 'ecommerce_shopping',"+
" 'quantity': 2,"+
" 'name': 'Bg Ss Shoshanna Yd Polo Dress',"+
" 'description': 'Un vestido que podría ser definido como sporty- chic. De cuello blanco y líneas horizontales en varios colores, hace referencia a la vida en altamar. ',"+
" 'sku': '7500244741187',"+
" 'unit_price': 59000"+
" },"+
" {"+
" 'type': 'ecommerce_shopping',"+
" 'quantity': 1,"+
" 'name': 'Farris Chino Gmd St',"+
" 'description': 'Producto Tommy',"+
" 'sku': '8718771353202',"+
" 'unit_price': 69000"+
" }"+
" ],"+
" 'name': 'Oscar',"+
" 'email': 'oscar.jimenez+loctommy@edgebound.com',"+
" 'phone': '5514945290'"+
" },"+
" 'amount': 187000,"+
" 'bank': {"+
" 'type': 'banorte'"+
" },"+
" 'description': 'Stogies',"+
" 'reference_id': 'conekta.tommy_12014_11019'"+
"}");
}

public Charge testSuccesfulCardPMCreate() throws Exception {
JSONObject params = valid_payment_method.put("card", valid_visa_card.get("card"));
Charge charge = Charge.create(params);
Expand All @@ -48,14 +90,14 @@ public Charge testSuccesfulCardPMCreate() throws Exception {
return charge;
}

// @Test
//@Test
public void testSuccesfulFindCharge() throws Exception {
Charge charge = testSuccesfulCardPMCreate();
charge = Charge.find(charge.id);
assertTrue(charge instanceof Charge);
}

// @Test
//@Test
public void testSuccesfulWhere() throws Exception {
ConektaObject charges = Charge.where();
assertTrue(charges instanceof ConektaObject);
Expand Down Expand Up @@ -102,9 +144,7 @@ public void testSuccesfulRealTimePMCreate() throws Exception {
assertTrue(
!((RealTimePayment)charge.payment_method).barcode.isEmpty()
);
}


}

//@Test
public void testUnsuccesfulPMCreate() throws Exception {
Expand All @@ -115,7 +155,6 @@ public void testUnsuccesfulPMCreate() throws Exception {
} catch (ParameterValidationError e) {
assertTrue(e instanceof ParameterValidationError);
}

}

//@Test
Expand Down

0 comments on commit cd2eafc

Please sign in to comment.