This file contains hidden or 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
// Url RestClient = https://restsharp.dev/ | |
// Remplazar Merchand_id | |
var client = new RestClient("https://sandbox-api.openpay.mx/v1/mdrhnprmsmxkgxtegzhk/customers?external_id=Customer_001"); | |
client.Timeout = -1; | |
var request = new RestRequest(Method.GET); | |
// REMPLAZAR por sk propia despues de Basic | |
// Es necesario convertir la llave secreta a base64 para poder entablar la conversación |
This file contains hidden or 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
var Openpay = require('openpay'); | |
//instantiation | |
var openpay = new Openpay('mdrhnprmsmxkgxtegzhk', 'sk_c71babd865fd420b94bc588a8585c122'); | |
console.log('=============================================================================='); | |
console.log('OBTENER TOKEN'); | |
console.log('=============================================================================='); | |
This file contains hidden or 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
$.ajax({ | |
type: 'POST', //aqui puede ser igual get | |
url: 'procesos/crearPago.php', //aqui va tu direccion donde esta tu funcion php | |
data: data, //aqui tus datos | |
success: function(response) { | |
// | |
var jsonData2 = JSON.parse(response); | |
var resp = JSON.parse(jsonData2.charge); | |
console.log(jsonData2); | |
console.log(resp); |
This file contains hidden or 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
if ($resp["status"] == true) { | |
$responseJson = new\ stdClass(); | |
$responseJson - > status = true; | |
$responseJson - > msg = "Pago con suceso"; | |
$responseJson - > charge = $jsonCharge; | |
$myJSON = json_encode($responseJson); | |
echo $myJSON; | |
} else { | |
print_r($ret["error"]); | |
print_r("La generación del pago falló"); |
This file contains hidden or 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
try { | |
$charge = $this - > openpay - > charges - > create($chargeData); | |
} catch (Exception $e) { | |
$errorMsg = $e - > getMessage(); | |
$errorCode = $e - > getCode(); | |
} | |
$status = null; | |
if ($errorMsg !== null || $errorCode !== null) { | |
$errorMsg = $this - > getError($errorCode); | |
$status = array("status" => false, "error" => $errorMsg, "errorCode" => $errorCode); |
This file contains hidden or 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
var sucess_callbak = function(response) { | |
var token_id = response.data.id; | |
console.log("Su token es " + token_id); | |
$('#token_id').val(token_id); | |
// $('#payment-form').submit(); | |
var data = $("#payment-form").serializeArray(); | |
console.log(data); |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import sys | |
import datetime | |
from os import path, pardir | |
PROJECT_ROOT = path.dirname(path.abspath(__file__)) | |
sys.path.append(path.join(PROJECT_ROOT, pardir)) | |
import openpay | |
openpay.api_key = "sk_c71babd865fd420b94bc588a8585c122" | |
openpay.verify_ssl_certs = False |
This file contains hidden or 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
var settings = { | |
"url": "https://sandbox-api.openpay.mx/v1/mzdtln0bmtms6o3kck8f/tokens", | |
"method": "POST", | |
"timeout": 0, | |
"headers": { | |
"Content-type": "application/json", | |
"Authorization": "Basic c2tfZTU2OGM0MmE2YzM4NGI3YWIwMmNkNDdkMmU0MDdjYWI6" | |
}, | |
"data": JSON.stringify({"card_number":"4111111111111111","holder_name":"Juan Perez Ramirez","expiration_year":"20","expiration_month":"12","cvv2":"110","address":{"city":"Querétaro","country_code":"MX","postal_code":"76900","line1":"Av 5 de Febrero","line2":"Roble 207","line3":"col carrillo","state":"Queretaro"}}), | |
}; |
This file contains hidden or 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
var error_callbak = function(response) { | |
var desc = response.data.description != undefined ? response.data.description : response.message; | |
alert("ERROR [" + response.status + "] " + desc); | |
$("#pay-button").prop("disabled", false); | |
}; |
This file contains hidden or 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
var sucess_callbak = function(response) { | |
var token_id = response.data.id; | |
alert("Su token es "+token_id); | |
$('#token_id').val(token_id); | |
// $('#payment-form').submit(); | |
$('#payment-form').reset(); | |
$("#pay-button").prop( "disabled", false); | |
}; |