Skip to content

Commit a63c3f1

Browse files
ivancalle-sipayXayOn
authored andcommitted
Merged in HSDK-6 (pull request #6)
HSDK-6 Approved-by: David Francos <davidfrancos@sipay.es>
2 parents e824e07 + a58e8ba commit a63c3f1

File tree

5 files changed

+207
-0
lines changed

5 files changed

+207
-0
lines changed

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)