|
| 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 | +} |
0 commit comments