public function testExistsServices() { $khipu = new Khipu(); $khipu->authenticate(KHIPU_TEST_RECEIVER_ID, KHIPU_TEST_SECRET); $exists = TRUE; $fail = ''; foreach ($this->services_name as $service_name => $need_authenticate) { if (!$this->loadServiceKhipu($khipu, $service_name) instanceof KhipuService) { $exists = FALSE; $fail = $service_name; break; } } $this->assertTrue($exists, 'Deben existir todos los servicios. No existe ' . $fail); }
<label class="label-example">Correo</label> <input required type="email" name="email" value="<?php print isset($_POST['email']) ? $_POST['email'] : ''; ?> "/> </div> <input type="submit" value="Crear Cobro"/> </form> <?php if (isset($_POST['receiver_id']) && isset($_POST['secret']) && isset($_POST['email'])) { ?> <div>Respuesta: <?php $Khipu = new Khipu(); // Nos identificamos $Khipu->authenticate($_POST['receiver_id'], $_POST['secret']); // Cargamos el servicio para crear el boton // Luego cargamos el servicio. $khipu_service = $Khipu->loadService('CreateEmail'); // Preparamos los datos que queremos enviar $data = array('subject' => 'Título del pago', 'body' => 'Descripción del producto', 'transaction_id' => '1', 'pay_directly' => 'false', 'send_emails' => 'true', 'return_url' => '', 'expires_date' => time() + 30 * 24 * 60 * 60, 'picture_url' => ''); if ($_POST['amount'] > 0) { $amount = $_POST['amount']; } $khipu_service->setParameters($data); // Agregamos un destinatario con un monto $khipu_service->addRecipient('Example Name', $_POST['email'], $amount); // Lo enviamos $respuesta = $khipu_service->send(); ?> <ul>
function khipu_get_verified_order_id_1_3($receiver_id, $secret, $params, $agent) { $Khipu = new Khipu(); $Khipu->authenticate($receiver_id, $secret); $Khipu->setAgent($agent); $service = $Khipu->loadService('GetPaymentNotification'); $service->setDataFromPost(); $response = json_decode($service->consult()); if ($response->receiver_id != $receiver_id) { error_log("recibido " . $response->receiver_id . " en el receiver_id"); return 0; } return $response->receiver_id == $receiver_id ? $response->custom : 0; }
public function setUp() { $khipu = new Khipu(); $khipu->authenticate(KHIPU_TEST_RECEIVER_ID, KHIPU_TEST_SECRET); $this->service = $khipu->loadService('CreateEmail'); }
public static function getOrderFromNotification_1_2($methodname) { require_once "lib-khipu/src/Khipu.php"; $Khipu = new Khipu(); $_POST = array_map('stripslashes', $_POST); $Khipu->authenticate(Mage::getStoreConfig("payment/{$methodname}/receiver_id"), Mage::getStoreConfig("payment/{$methodname}/api_secret")); $Khipu->setAgent('khmage-1.5.0;;' . Mage::app()->getStore()->getHomeUrl() . ';;' . Mage::app()->getStore()->getName()); $create_page_service = $Khipu->loadService('VerifyPaymentNotification'); $create_page_service->setDataFromPost(); if ($_POST['receiver_id'] != Mage::getStoreConfig("payment/{$methodname}/receiver_id")) { return false; } $verify = $create_page_service->verify(); $verified = $verify['response'] == 'VERIFIED'; if ($verified) { $order = Mage::getModel('sales/order'); $order->loadByIncrementId($_POST['transaction_id']); return $order; } return null; }