PHP code example of vedatunlu / payment
1. Go to this page and download the library: Download vedatunlu/payment library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vedatunlu / payment example snippets
// will return credit card resources
Payment::gateway('sipay')
->getCards([
'customer_number' => 123123
])->toArray();
// will return credit card token
Payment::gateway('sipay')
->saveCard([
'card_number' => 4508034508034509,
'customer_number' => 123123,
'expiry_month' => 12,
'expiry_year' => 2026,
'card_holder_name' => 'Vedat Ünlü'
])->toArray();
// will return a html form body and this form will redirect to the 3D verification
$response = Payment::gateway('sipay')
->payWith3D([
'cc_holder_name' => 'Vedat Ünlü',
'cc_no' => '4508034508034509',
'expiry_month' => '12',
'expiry_year' => '2026',
'cvv' => '000',
'currency_code' => 'TRY',
'installments_number' => 1,
'invoice_id' => rand(100000, 999999),
'invoice_description' => 'invoice_description',
'name' => 'Vedat',
'surname' => 'Ünlü',
'total' => 101.10,
'items' => json_encode([
[
'name' => 'Item 2',
'price' => 101.10,
'quantity' => 1,
'description' => "item description"
]
]),
'cancel_url' => 'payment-success-callback-url', // route('payment.callback.success)
'return_url' => 'payment-error-callback-url', // route('payment.callback.error)
'response_method' => 'POST'
]);
if ($response->isSuccess() == true) {
return $response->get3DSForm(); // get response as html form
}
return $response->toArray(); // get response as array
$hashKey = $request->input('hash_key');
if (!Payment::validate('sipay', $hashKey)) {
return back()->with('error', 'Invalid hash key');
}
bash
php artisan vendor:publish --tag=payment-config