if (is_array($mData)) { $sHTML = '<ul>'; foreach ($mData as $sKey => $sValue) { $sHTML .= '<li>' . '<strong>' . $sKey . ':</strong> ' . _toHTML($sValue) . '</li>'; } $sHTML .= '</ul>'; } else { $sHTML = $mData; } return $sHTML; } $order = 'TEST_DEBIT_' . rand(0, 99999); /* Prereq. Create parent payment */ echo '<h2>Prerequisite: create a parent payment</h2>'; try { $oNewPayment = Payment::create(array('order' => $order)); echo '<strong>Payment created:</strong>' . "\n"; echo _toHTML($oNewPayment); } catch (\Payname\Exception $e) { echo $e . "\n"; } /* Create simple debit */ echo '<h2>Creation</h2>' . "\n"; try { $oNewDebit = Debit::create(array('payment' => $order, 'method' => 'cb', 'amount' => '10,9', 'card' => array('number' => '4970100000000000', 'expiry' => array('month' => '1', 'year' => '2018'), 'cvv' => '345'))); echo '<strong>Debit created:</strong>' . "\n"; echo _toHTML($oNewDebit); } catch (\Payname\Exception $e) { echo $e . "\n"; } /* Get existing debit */
$sHTML .= '<li>' . '<strong>' . $sKey . ':</strong> ' . _toHTML($sValue) . '</li>'; } $sHTML .= '</ul>'; } else { $sHTML = $mData; } return $sHTML; } $order = 'TCARD'; // todo : HTML form to set it from page? $amount = '10'; /* 1. Payment creation */ if (!isset($_POST['PaRes'])) { echo '<h2>Create new payment</h2>'; try { $oNewPayment = Payment::create(array('type' => 'cb', 'datas' => array('general' => array('amount' => $amount, 'order_id' => $order), 'card' => array('number' => '4970100000000009', 'expiry' => array('month' => '1', 'year' => '2018'), 'cvv' => '345')))); echo '<strong>Payment created:</strong>' . "\n"; echo _toHTML($oNewPayment); } catch (\Payname\Exception $e) { echo $e . "\n"; } } /* 2. 3DS Validation */ if (!isset($_POST['PaRes']) and isset($oNewPayment) and in_array($oNewPayment->status, ['W_3DS', 'W_SENDING'])) { ?> <h2>3DS Validation</h2> <form name="test3DS" action="<?php echo $oNewPayment->test_3DS['url']; ?> "
/* 1. Token creation */ if (!isset($_POST['PaRes'])) { echo '<h2>create a new card token</h2>'; try { $aRes = Card::create(array('number' => '4970100000000009', 'expiry' => array('month' => '1', 'year' => '2018'), 'cvv' => '345', 'email' => '*****@*****.**')); $sToken = $aRes['token']; } catch (\Payname\Exception $e) { echo $e . "\n"; } echo 'Token created: ' . $sToken . "\n"; } /* 2. Payment creation */ if (!isset($_POST['PaRes'])) { echo '<h2>create new payment by itself</h2>'; try { $oNewPayment = Payment::create(array('type' => 'token', 'datas' => array('token' => $sToken, 'amount' => $amount, 'order_id' => $order))); } catch (\Payname\Exception $e) { echo $e . "\n"; } echo 'Payment created: ' . "\n"; echo _toHTML($oNewPayment); } /* 3. 3DS validation only if payment in W_3DS mode */ if (!isset($_POST['PaRes']) and isset($oNewPayment) and $oNewPayment->status == 'W_3DS') { ?> <h2>Validation 3DS</h2> <form name="test3DS" action="<?php echo $oNewPayment->test_3DS['url']; ?> "