Created
March 23, 2021 02:26
-
-
Save gusLopezC/6a19fab79f496823d7e4414f7237584c to your computer and use it in GitHub Desktop.
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
// Java - OkHttp | |
import java.io.*; | |
import okhttp3.*; | |
public class main { | |
public static void main(String []args) throws IOException{ | |
OkHttpClient client = new OkHttpClient().newBuilder() | |
.build(); | |
MediaType mediaType = MediaType.parse("application/json"); | |
RequestBody body = RequestBody.create(mediaType, "{\r\n \"holder_name\": \"Tarjeta actualizada\",\r\n \"cvv2\":\"000\"\r\n }"); | |
Request request = new Request.Builder() | |
// Remplazar Merchant_id de la url | |
.url("https://sandbox-api.openpay.mx/v1/mdrhnprmsmxkgxtegzhk/cards/kcr1usqdyrmgjevswb92") | |
.method("PUT", body) | |
.addHeader("Content-Type", "application/json") | |
// Es necesario convertir su llave secreta agregando ':' a base64 para poder completar la verificacion | |
// Ejemplo sk_c71babd865000000000bc588a2: | |
.addHeader("Authorization", "Basic c2tfYzcxYmFiZDg2NWZkNDIwYjk0YmM1ODhhODU4NWMxMjI6") | |
.build(); | |
Response response = client.newCall(request).execute(); | |
System.out.println(response.body().string()); | |
} | |
} | |
// Java - Unirest | |
Unirest.setTimeouts(0, 0); | |
HttpResponse<String> response = Unirest.put("https://sandbox-api.openpay.mx/v1/mdrhnprmsmxkgxtegzhk/cards/kcr1usqdyrmgjevswb92") | |
.header("Content-Type", "application/json") | |
.header("Authorization", "Basic c2tfYzcxYmFiZDg2NWZkNDIwYjk0YmM1ODhhODU4NWMxMjI6") | |
.body("{\r\n \"holder_name\": \"Tarjeta actualizada\",\r\n \"cvv2\":\"000\"\r\n }") | |
.asString(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment