1. Go to this page and download the library: Download asciisd/cashier-paytiko 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/ */
use Asciisd\CashierPaytiko\Events\PaytikoPaymentSuccessful;
use Asciisd\CashierPaytiko\Events\PaytikoPaymentFailed;
use Asciisd\CashierPaytiko\Events\PaytikoRefundProcessed;
use Asciisd\CashierPaytiko\Events\PaytikoWebhookReceived;
// Listen to successful payments
Event::listen(PaytikoPaymentSuccessful::class, function ($event) {
$webhookData = $event->webhookData;
// Update your order status
$order = Order::where('id', $webhookData->orderId)->first();
$order->update(['status' => 'paid']);
// Send confirmation email, etc.
});
// Listen to failed payments
Event::listen(PaytikoPaymentFailed::class, function ($event) {
$webhookData = $event->webhookData;
// Handle failed payment
$order = Order::where('id', $webhookData->orderId)->first();
$order->update(['status' => 'failed']);
});
// Listen to all webhook events
Event::listen(PaytikoWebhookReceived::class, function ($event) {
$webhookData = $event->webhookData;
$rawPayload = $event->rawPayload;
// Log webhook for debugging
Log::info('Paytiko webhook received', [
'order_id' => $webhookData->orderId,
'status' => $webhookData->transactionStatus,
]);
});
$result = $processor->charge([
// ... other data
'webhook_url' => 'https://yoursite.com/custom/webhook/endpoint',
]);
$result = $processor->charge([
// ... other data
'credit_card_only' => true,
]);
$result = $processor->charge([
// ... other data
'disabled_psp_ids' => [12321, 54455, 34212],
]);
$result = $processor->charge([
// ... other data
'is_pay_out' => true,
]);
use Asciisd\CashierPaytiko\DataObjects\PaytikoHostedPageRequest;
use Asciisd\CashierPaytiko\DataObjects\PaytikoBillingDetails;
$billingDetails = new PaytikoBillingDetails(
firstName: 'John',
email: '[email protected]',
country: 'US',
phone: '+1234567890',
currency: 'USD'
);
$request = new PaytikoHostedPageRequest(
timestamp: (string) time(),
orderId: 'order_123',
signature: $signature,
billingDetails: $billingDetails
);
use Asciisd\CashierPaytiko\DataObjects\PaytikoWebhookData;
// Webhook data is automatically parsed from incoming webhooks
$webhookData = $event->webhookData;
// Check payment status
if ($webhookData->isSuccessful()) {
// Payment succeeded
}
if ($webhookData->isPayIn()) {
// This is a payment
}
if ($webhookData->isRefund()) {
// This is a refund
}
// Add to PaytikoProcessor
public function directPayment(array $data): PaymentResult
{
// Implement direct payment API integration
}
// Create new DTO
class PaytikoDirectPaymentRequest
{
// Define direct payment request structure
}