Skip to content

Instantly share code, notes, and snippets.

@marti1125
Last active December 19, 2016 11:13
Show Gist options
  • Save marti1125/a0e7dca854d47d1fac457d7984a4b49a to your computer and use it in GitHub Desktop.
Save marti1125/a0e7dca854d47d1fac457d7984a4b49a to your computer and use it in GitHub Desktop.
culqi-java-work
package test;
import com.culqi.model.Config;
import com.culqi.model.Plan;
import org.apache.http.*;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
/**
* Created by willyaguirre on 17/12/16.
*/
public class Main {
public static void main(String[] args) throws Exception {
Config config = new Config();
Plan plan = new Plan();
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://integ-pago.culqi.com/api/v1/planes");
post.setHeader("Authorization","Bearer N4Eim7OKvOnB844Zkc3Z4KFUpPFdC19tcUsynAkaeI0=");
post.setHeader("Content-Type","application/json");
StringEntity entity = new StringEntity("{\"codigo_comercio\": \"test_hupNaBiZ4J2F\", \"moneda\": \"PEN\", \"monto\": \"1000\", \"id\": \"plan-test666\", \"periodo\": \"dias\", \"nombre\": \"Plan de A\", \"intervalo\": 2, \"gracia\": 5, \"gracia_medida\": \"dias\", \"ciclos\": 12}");
post.setEntity(entity);
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(post);
System.out.println(response.getStatusLine());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.culqi</groupId>
<artifactId>culqi-java</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment