diff --git a/.gitignore b/.gitignore index bab356a..10999b9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,10 @@ .DS_Store www/tests sync.sh +/nbproject/private/ +.idea/lyra.iml +.idea/misc.xml +.idea/modules.xml +.idea/php.xml +.idea/vcs.xml +.idea/workspace.xml diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..c0c2ef4 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_73 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..3523c15 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + lyra + + + diff --git a/www/PagoUnClic.php b/www/PagoUnClic.php new file mode 100644 index 0000000..401354c --- /dev/null +++ b/www/PagoUnClic.php @@ -0,0 +1,47 @@ + $total, + "currency" => "ARS", + "paymentMethodToken"=> $token + ); +} + + + +/** + * I create a formToken + */ + +$response = $client->post("V4/Charge/CreatePayment", $store); + +//* I check if there are some errors */ +if ($response['status'] != 'SUCCESS') { + /* an error occurs */ + $error = $response['answer']; + header("Content-Type", "application/json"); + header('HTTP/1.1 500 Internal Server Error'); + echo '{"error": "' . $error['errorCode'] . '", "_type": "DemoError" }'; + die(); +} + +/* everything is fine, I extract the formToken */ +$Token = $response["answer"]["paymentMethodToken"]; +//header("Content-Type", "application/json"); +//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; + diff --git a/www/SearchPay.php b/www/SearchPay.php new file mode 100644 index 0000000..11115c9 --- /dev/null +++ b/www/SearchPay.php @@ -0,0 +1,48 @@ + $token, + ); +} + +//print_r($store); + +/** + * I create a formToken + */ + +$response = $client->post("V4/Token/Get", $store); + +//* I check if there are some errors */ +if ($response['status'] != 'SUCCESS') { + /* an error occurs */ + $error = $response['answer']; + header("Content-Type", "application/json"); + header('HTTP/1.1 500 Internal Server Error'); + echo '{"error": "' . $error['errorCode'] . '", "_type": "DemoError" }'; + die(); +} + +/* everything is fine, I extract the formToken */ +$Token = $response["answer"]["paymentMethodToken"]; + +//header("Content-Type", "application/json"); +//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; + diff --git a/www/cancelPay.php b/www/cancelPay.php new file mode 100644 index 0000000..b3b6d6d --- /dev/null +++ b/www/cancelPay.php @@ -0,0 +1,45 @@ + $total, + "currency" => "$currency", + "uuid" => $uuid + ); +} + +/** + * I create a formToken + */ + +$responseCancel = $client->post("V4/Transaction/CancelOrRefund", $store); + +//* I check if there are some errors */ +if ($responseCancel['status'] != 'SUCCESS') { + /* an error occurs */ +// $error = $responseCancel['answer']; +// header("Content-Type", "application/json"); +// header('HTTP/1.1 500 Internal Server Error'); +// echo '{"error": "' . $error['errorCode'] . '", "_type": "DemoError" }'; +// die(); +} + +/* everything is fine, I extract the formToken */ +//$formToken = $responseCancel["answer"]["formToken"]; +//header("Content-Type", "application/json"); +//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; + diff --git a/www/createRegisterPay.php b/www/createRegisterPay.php new file mode 100644 index 0000000..c0ae46b --- /dev/null +++ b/www/createRegisterPay.php @@ -0,0 +1,71 @@ + $total, + "formAction" => "REGISTER_PAY", + "currency" => "ARS", + "orderId" => uniqid($compra->get_id()), + "customer" => array( + "email" => $compra->get_idUser()->get_email() + + )); + break; + + case "SILENT": + $store = array( "amount" => $total, + "currency" => "ARS", + "paymentMethodToken"=> $paytoken, + "formAction" => "SILENT", + "orderId" => uniqid($compra->get_id()), + "customer" => array( + "email" => $compra->get_idUser()->get_email(), + "reference"=> "12345678" + ) + ); + break; + } + + } + + $response = $client->post("V4/Charge/CreatePayment", $store); + +//* I check if there are some errors */ + if ($response['status'] != 'SUCCESS') { + /* an error occurs */ + $error = $response['answer']; + header("Content-Type", "application/json"); + header('HTTP/1.1 500 Internal Server Error'); + echo '{"error": "' . $error['errorCode'] . '", "_type": "DemoError" }'; + die(); + } + + /* everything is fine, I extract the formToken */ + $formToken = $response["answer"]["formToken"]; +//header("Content-Type", "application/json"); +//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; + +} + + + + + diff --git a/www/createSilentPay.php b/www/createSilentPay.php new file mode 100644 index 0000000..5345d38 --- /dev/null +++ b/www/createSilentPay.php @@ -0,0 +1,54 @@ + $total, + "currency" => "ARS", + "paymentMethodToken"=> $token, + "formAction" => "SILENT", + + "transactionOptions"=> array( + "cardOptions"=> array("installmentNumber"=> $silent_cuotas) + ) + ); +} + +//print_r($store); + +/** + * I create a formToken + */ + +$responseSlient = $client->post("V4/Charge/CreatePayment", $store); + +//* I check if there are some errors */ +if ($responseSlient['status'] != 'SUCCESS') { + /* an error occurs */ + $error = $responseSlient['answer']; + header("Content-Type", "application/json"); + header('HTTP/1.1 500 Internal Server Error'); + echo '{"error": "' . $error['errorCode'] . '", "_type": "DemoError" }'; + die(); +} + +/* everything is fine, I extract the formToken */ +$Token = $responseSlient["answer"]["paymentMethodToken"]; + +//header("Content-Type", "application/json"); +//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; + diff --git a/www/createToken.php b/www/createToken.php index 519c0d6..4ee294e 100644 --- a/www/createToken.php +++ b/www/createToken.php @@ -4,22 +4,24 @@ */ require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/keys.php'; - +require_once __DIR__ . '/helpers.php'; /** * Initialize the SDK * see keys.php */ $client = new Lyra\Client(); - +$total = number_format($total_final, 2, '', ''); +//$total = $total . 0000; if (isset($_GET['requestObject'])) { $store = json_decode($_GET['requestObject']); } else { - $store = array( "amount" => 250, - "currency" => "EUR", - "orderId" => uniqid("MyOrderId"), + $store = array( "amount" => $total, + "formAction" => "REGISTER_PAY", + "currency" => "ARS", + "orderId" => uniqid($compra->get_id()), "customer" => array( - "email" => "sample@example.com" - )); + "email" => $_usuario->get_email()) + ); } /** @@ -40,5 +42,6 @@ /* everything is fine, I extract the formToken */ $formToken = $response["answer"]["formToken"]; -header("Content-Type", "application/json"); -echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; + +//header("Content-Type", "application/json"); +//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; diff --git a/www/keys.php b/www/keys.php index db8d0d6..297c628 100644 --- a/www/keys.php +++ b/www/keys.php @@ -9,12 +9,25 @@ */ /* Username, password and endpoint used for server to server web-service calls */ -Lyra\Client::setDefaultUsername("69876357"); -Lyra\Client::setDefaultPassword("testpassword_DEMOPRIVATEKEY23G4475zXZQ2UA5x7M"); -Lyra\Client::setDefaultEndpoint("https://api.payzen.eu"); +//Lyra\Client::setDefaultUsername("31916241"); +//Lyra\Client::setDefaultPassword("testpassword_KmsHiyWyJEaMBn5sO2gLdxYyVjMZKPBSaDDSuOrMuXikD"); +//Lyra\Client::setDefaultEndpoint("https://api.payzen.lat/"); +// +///* publicKey and used by the javascript client */ +//Lyra\Client::setDefaultPublicKey("31916241:testpassword_KmsHiyWyJEaMBn5sO2gLdxYyVjMZKPBSaDDSuOrMuXikD"); +// +///* SHA256 key */ +////sha1(31916241:testpassword_KmsHiyWyJEaMBn5sO2gLdxYyVjMZKPBSaDDSuOrMuXikD) +Lyra\Client::setDefaultSHA256Key($claveSHA256); + +/* Username, password and endpoint used for server to server web-service calls */ +Lyra\Client::setDefaultUsername($shopID); +Lyra\Client::setDefaultPassword($clave); +Lyra\Client::setDefaultEndpoint($endPoint); +//Lyra\Client::setDefaultEndpoint("https://static.payzen.lat"); /* publicKey and used by the javascript client */ -Lyra\Client::setDefaultPublicKey("69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5"); +Lyra\Client::setDefaultPublicKey($publicKey); /* SHA256 key */ -Lyra\Client::setDefaultSHA256Key("38453613e7f44dc58732bad3dca2bca3"); \ No newline at end of file +Lyra\Client::setDefaultSHA256Key($claveSHA256); \ No newline at end of file diff --git a/www/soloToken.php b/www/soloToken.php new file mode 100644 index 0000000..c96d324 --- /dev/null +++ b/www/soloToken.php @@ -0,0 +1,46 @@ + $total, + "currency" => "ARS", + "orderId" => uniqid($compra->get_id()), + "customer" => array( + "email" => $compra->get_idUser()->get_email() + + )); +} + +/** + * I create a formToken + */ + +$response = $client->post("V4/Charge/CreatePayment", $store); + +//* I check if there are some errors */ +if ($response['status'] != 'SUCCESS') { + /* an error occurs */ + $error = $response['answer']; + header("Content-Type", "application/json"); + header('HTTP/1.1 500 Internal Server Error'); + echo '{"error": "' . $error['errorCode'] . '", "_type": "DemoError" }'; + die(); +} + +/* everything is fine, I extract the formToken */ +$formToken = $response["answer"]["formToken"]; +//header("Content-Type", "application/json"); +//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; diff --git a/www/updatePay.php b/www/updatePay.php new file mode 100644 index 0000000..b954308 --- /dev/null +++ b/www/updatePay.php @@ -0,0 +1,48 @@ + $total, + "uuid" => $uuid, + "cardUpdate" => array( + "amount" => $total, + "currency" => "ARS" + + )); +} + +/** + * I create a formToken + */ + +$responseUpdate = $client->post("V4/Transaction/Update", $store); + +//* I check if there are some errors */ +if ($responseUpdate['status'] != 'SUCCESS') { + /* an error occurs */ + $error = $responseUpdate['answer']; + header("Content-Type", "application/json"); + header('HTTP/1.1 500 Internal Server Error'); + echo '{"error": "' . $error['errorCode'] . '", "_type": "DemoError" }'; + die(); +} + +/* everything is fine, I extract the formToken */ +$formToken = $responseUpdate["answer"]["formToken"]; +//header("Content-Type", "application/json"); +//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }'; +