|  | 
|  | 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('6712009000000205', 2018, 12); | 
|  | 9 | + | 
|  | 10 | +$options = array( | 
|  | 11 | +  'order' => 'order-test', | 
|  | 12 | +  'reference' => '1234', | 
|  | 13 | +  'token' => 'new-token' | 
|  | 14 | +); | 
|  | 15 | + | 
|  | 16 | +$refund = $ecommerce->refund($card, $amount, $options); | 
|  | 17 | + | 
|  | 18 | +if($refund->code == 0) { | 
|  | 19 | +    print("Devolución aceptada!\n"); | 
|  | 20 | +}else{ | 
|  | 21 | +    print("Error: ".$refund->description."\n"); | 
|  | 22 | +} | 
|  | 23 | + | 
|  | 24 | +$stored_card = new \Sipay\Paymethods\StoredCard('new-token'); | 
|  | 25 | + | 
|  | 26 | +$refund2 = $ecommerce->refund($stored_card, $amount, $options); | 
|  | 27 | + | 
|  | 28 | +if($refund2->code == 0) { | 
|  | 29 | +    print("Devolución aceptada!\n"); | 
|  | 30 | +}else{ | 
|  | 31 | +    print("Error: ".$refund2->description."\n"); | 
|  | 32 | +} | 
|  | 33 | + | 
|  | 34 | +$fast_pay = new \Sipay\Paymethods\FastPay('0f266784e7ba4e438040fdd1dbbfcd73'); | 
|  | 35 | + | 
|  | 36 | +$refund3 = $ecommerce->refund($fast_pay, $amount, $options); | 
|  | 37 | + | 
|  | 38 | +if($refund3->code == 0) { | 
|  | 39 | +    print("Devolución aceptada!\n"); | 
|  | 40 | +}else{ | 
|  | 41 | +    print("Error: ".$refund3->description."\n"); | 
|  | 42 | +} | 
|  | 43 | + | 
|  | 44 | + | 
|  | 45 | + | 
|  | 46 | +$auth = $ecommerce->authorization($card, $amount, $options); | 
|  | 47 | + | 
|  | 48 | +if($auth->code == 0) { | 
|  | 49 | +    print("Autorización aceptada, el pago ha sido completado!\n"); | 
|  | 50 | +}else{ | 
|  | 51 | +    print("Error: ".$auth->description."\n"); | 
|  | 52 | +} | 
|  | 53 | + | 
|  | 54 | + | 
|  | 55 | +$refund4 = $ecommerce->refund($auth->transaction_id, $amount, $options); | 
|  | 56 | + | 
|  | 57 | +if($refund4->code == 0) { | 
|  | 58 | +    print("Devolución aceptada!\n"); | 
|  | 59 | +}else{ | 
|  | 60 | +    print("Error: ".$refund4->description."\n"); | 
|  | 61 | +} | 
0 commit comments