Skip to content

Commit 95cb8a1

Browse files
committed
Merge branch 'develop' of bitbucket.org:sipay_team/hsdk into HSDK-7
2 parents 7fd0987 + a63c3f1 commit 95cb8a1

File tree

9 files changed

+440
-188
lines changed

9 files changed

+440
-188
lines changed

etc/config.ini

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
; **************************************************************
2+
; LOGGER
3+
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
; Configuración asociada al sistema de trazas.
5+
;
6+
; path: Nombre del directorio donde se crearan los logs (Nota: si la ruta es relativa se creará en el directorio del paquete)
7+
; level: nivel minimo de trazas [debug, info, warning, error, critical]
8+
; prefix: prefijo del nombre del archivo
9+
; extension: extensión del archivo
10+
; date_format: Formato de fecha de las trazas de log
11+
; backup_file_rotation: Número de ficheros de backup
12+
; ------------------------------------------------------------//
13+
114
[logger]
215
path=logs
316
level=warning
@@ -6,15 +19,43 @@ extension=log
619
date_format=d/m/Y H:i:s
720
backup_file_rotation = 5
821

22+
; **************************************************************
23+
; CREDENTIALS
24+
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25+
; Credenciales para obtener acceso al recurso.
26+
;
27+
; key: Key del cliente
28+
; secret: Secret del cliente
29+
; resouce: Recurso al que se quiere acceder
30+
; ------------------------------------------------------------//
31+
932
[credentials]
1033
key=api-key
1134
secret=api-secret
1235
resource=resource
1336

37+
; **************************************************************
38+
; API
39+
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40+
; Configuracion de la API.
41+
;
42+
; environment: Entorno al que se deben enviar las peticiones ['sandbox', 'staging', 'live']
43+
; version: Versión de la api a usar actualmente solo existe v1
44+
; mode: Modo de encriptacion de la firma, [sha256, sha512]
45+
; ------------------------------------------------------------//
46+
1447
[api]
1548
environment=sandbox
1649
version=v1
1750
mode=sha256
1851

52+
; **************************************************************
53+
; Connection
54+
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
; Cofiguracion de la conexión.
56+
;
57+
; timeout: Tiempo máximo de respuesta de la petición.
58+
; ------------------------------------------------------------//
59+
1960
[connection]
2061
timeout=30

examples/authorization.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
require_once realpath(__DIR__.'/../src/autoload.php');
3+
4+
$ecommerce = new \Sipay\Ecommerce(realpath(__DIR__."/../etc/config.ini"));
5+
6+
print("Autorización \n");
7+
8+
$amount = new \Sipay\Amount(200, 'EUR');
9+
10+
$card = new \Sipay\Paymethods\Card('4242424242424242', 2018, 12);
11+
12+
$options = array(
13+
'order' => 'order-test',
14+
'reference' => '1234',
15+
'token' => 'new-token'
16+
);
17+
18+
$auth = $ecommerce->authorization($card, $amount, $options);
19+
20+
if($auth->code == 0) {
21+
print("Autorización aceptada, el pago ha sido completado!\n");
22+
}else{
23+
print("Error: ".$auth->description."\n");
24+
}
25+
print("Autorización tokenizada \n");
26+
27+
$stored_card = new \Sipay\Paymethods\StoredCard('ABC123');
28+
29+
$auth2 = $ecommerce->authorization($stored_card, $amount, $options);
30+
31+
if($auth2->code == 0) {
32+
print("Autorización aceptada, el pago ha sido completado!\n");
33+
}else{
34+
print("Error: ".$auth2->description."\n");
35+
}
36+
37+
print("Autorización con FPAY \n");
38+
$fast_pay = new \Sipay\Paymethods\FastPay('0f266784e7ba4e438040fdd1dbbfcd73');
39+
40+
$auth3 = $ecommerce->authorization($fast_pay, $amount, $options);
41+
42+
if($auth3->code == 0) {
43+
print("Autorización aceptada, el pago ha sido completado!\n");
44+
}else{
45+
print("Error: ".$auth3->description."\n");
46+
}

examples/cancellation.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
require_once realpath(__DIR__.'/../src/autoload.php');
3+
4+
$ecommerce = new \Sipay\Ecommerce(realpath(__DIR__."/../etc/config.ini"));
5+
6+
$amount = new \Sipay\Amount(200, 'EUR');
7+
8+
$card = new \Sipay\Paymethods\Card('4242424242424242', 2018, 12);
9+
10+
$auth = $ecommerce->authorization($card, $amount);
11+
12+
if($auth->code == 0) {
13+
print("Autorización aceptada, el pago ha sido completado!\n");
14+
}else{
15+
print("Error: ".$auth->description."\n");
16+
}
17+
18+
$cancel = $ecommerce->cancellation($auth->transaction_id);
19+
20+
if($cancel->code == 0) {
21+
print("Cancelación aceptada!\n");
22+
}else{
23+
print("Error: ".$cancel->description."\n");
24+
}

examples/query.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
require_once realpath(__DIR__.'/../src/autoload.php');
3+
4+
$ecommerce = new \Sipay\Ecommerce(realpath(__DIR__."/../etc/config.ini"));
5+
6+
$amount = new \Sipay\Amount(200, 'EUR');
7+
8+
$card = new \Sipay\Paymethods\Card('42424242424242', 2018, 12);
9+
10+
$options = array(
11+
'order' => 'order-test'
12+
);
13+
14+
$auth = $ecommerce->authorization($card, $amount, $options);
15+
16+
if($auth->code == 0) {
17+
print("Autorización aceptada, el pago ha sido completado!\n");
18+
}else{
19+
print("Error: ".$auth->description."\n");
20+
}
21+
22+
$auth2 = $ecommerce->authorization($card, $amount, $options);
23+
24+
if($auth2->code == 0) {
25+
print("Autorización aceptada, el pago ha sido completado!\n");
26+
}else{
27+
print("Error: ".$auth2->description."\n");
28+
}
29+
30+
$query = $ecommerce->query(array('order' => 'order-test'));
31+
32+
if($query->code == 0) {
33+
print(count($query->transactions)." transacciones recuperadas con éxito!\n");
34+
foreach ($query->transactions as $transaction ){
35+
print($transaction->transaction_id."\n");
36+
print($transaction->masked_card."\n");
37+
}
38+
}else{
39+
print("Error: ".$query->description."\n");
40+
}

examples/refund.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
require_once realpath(__DIR__.'/../src/autoload.php');
3+
4+
$ecommerce = new \Sipay\Ecommerce(realpath(__DIR__."/../etc/config.ini"));
5+
6+
7+
$amount = new \Sipay\Amount(200, 'EUR');
8+
9+
$card = new \Sipay\Paymethods\Card('4242424242424242', 2018, 12);
10+
11+
$options = array(
12+
'order' => 'order-test',
13+
'reference' => '1234',
14+
'token' => 'new-token'
15+
);
16+
17+
// Devolución
18+
$refund = $ecommerce->refund($card, $amount, $options);
19+
20+
if($refund->code == 0) {
21+
print("Devolución aceptada!\n");
22+
}else{
23+
print("Error: ".$refund->description."\n");
24+
}
25+
26+
$stored_card = new \Sipay\Paymethods\StoredCard('new-token');
27+
28+
29+
// Devolución
30+
$refund2 = $ecommerce->refund($stored_card, $amount, $options);
31+
32+
if($refund2->code == 0) {
33+
print("Devolución aceptada!\n");
34+
}else{
35+
print("Error: ".$refund2->description."\n");
36+
}
37+
38+
$fast_pay = new \Sipay\Paymethods\FastPay('50d79105f6f848f9ad30f9c5970adf7c');
39+
40+
// Devolución
41+
$refund3 = $ecommerce->refund($fast_pay, $amount, $options);
42+
43+
if($refund3->code == 0) {
44+
print("Devolución aceptada!\n");
45+
}else{
46+
print("Error: ".$refund3->description."\n");
47+
}
48+
49+
50+
// Autorización
51+
$auth = $ecommerce->authorization($card, $amount, $options);
52+
53+
if($auth->code == 0) {
54+
print("Autorización aceptada, el pago ha sido completado!\n");
55+
}else{
56+
print("Error: ".$auth->description."\n");
57+
}
58+
59+
60+
// Devolución
61+
$refund4 = $ecommerce->refund($auth->transaction_id, $amount, $options);
62+
63+
if($refund4->code == 0) {
64+
print("Devolución aceptada!\n");
65+
}else{
66+
print("Error: ".$refund4->description."\n");
67+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
require_once realpath(__DIR__.'/../src/autoload.php');
3+
4+
$ecommerce = new \Sipay\Ecommerce(realpath(__DIR__."/../etc/config.ini"));
5+
6+
$card = new \Sipay\Paymethods\Card('4242424242424242', 2018, 12);
7+
8+
$register = $ecommerce->register($card, $token = 'new-token');
9+
10+
if($register->code == 0) {
11+
print("Tarjeta registrada con éxito!\n");
12+
}else{
13+
print("Error: ".$register->description."\n");
14+
}
15+
16+
$masked_card = $ecommerce->card($token);
17+
18+
if($masked_card->code == 0) {
19+
print("Tarjeta consultada con éxito!\n");
20+
}else{
21+
print("Error: ".$masked_card->description."\n");
22+
}
23+
24+
$unregiter = $ecommerce->unregister($token);
25+
26+
if($unregiter->code == 0) {
27+
print("Tarjeta borrada con éxito!\n");
28+
}else{
29+
print("Error: ".$unregiter->description."\n");
30+
}

0 commit comments

Comments
 (0)