1. Go to this page and download the library: Download voxyfy/anadolupay 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/ */
new RefundPaymentData('SIPARIS-123', 49.90, metadata: ['ref_ret_num' => '...']);
use Voxyfy\AnadoluPay\Contracts\SupportsStatusQuery;
$gateway = AnadoluPay::driver('garanti');
if ($gateway instanceof SupportsStatusQuery) {
$status = $gateway->status('SIPARIS-123');
}
$status = AnadoluPay::driver('garanti')->status('SIPARIS-123');
$status->found; // banka bu siparişi tanıyor mu
$status->isPaid(); // para tahsil edildi mi
$status->isPending(); // 3D doğrulaması bekleniyor
$status->amount; // Money
$status->refundedAmount;
$gateway = AnadoluPay::driver('garanti');
// Bloke et
$response = $gateway->preAuthorize($data);
// Nihai tutar belli olunca tahsil et
$gateway->capture(new CapturePaymentData(
orderId: 'SIPARIS-123',
amount: 149.90, // blokeden küçük olabilir
metadata: ['ref_ret_num' => '...'], // Garanti bu referansı ister
));
new CreatePaymentData(
amount: 49.90,
// …
metadata: ['recurring' => new RecurringPlan(
interval: 1,
frequency: RecurringPlan::FREQUENCY_MONTH,
paymentCount: 12,
)],
);
use Voxyfy\AnadoluPay\Support\Money;
new CreatePaymentData(amount: Money::fromMinorUnits(19990), ...); // 199,90 TL
new CreatePaymentData(amount: 199.90, ...); // eşdeğer
use Voxyfy\AnadoluPay\Exceptions\PaymentFailedException;
use Voxyfy\AnadoluPay\Exceptions\TransportException;
try {
$result = AnadoluPay::driver('garanti')->verify($data);
} catch (PaymentFailedException $e) {
// Kesin ret: siparişi iptal edebilirsiniz.
} catch (TransportException $e) {
// Belirsiz: siparişi "beklemede" bırakın, durum sorgusuyla teyit edin.
$e->safeToRetry; // yalnızca isteğin bankaya ulaşmadığı kesinse true
}
Event::listen(PaymentVerified::class, function (PaymentVerified $event) {
if ($event->success) {
Order::where('code', $event->orderId)->update([
'status' => 'paid',
'payment_reference' => $event->paymentId,
]);
}
});
$status = AnadoluPay::driver('paratika')->status('SIPARIS-123');
$status->isPaid(); // kısmi iadeden sonra da true
$status->refundedAmount; // Money|null
$response = AnadoluPay::driver('moka')->createPayment($data);
// Bu değeri siparişle birlikte saklayın.
$codeForHash = $response->raw['code_for_hash'];
return redirect()->away($response->redirectUrl);