PHP code example of rstacode / wayl
1. Go to this page and download the library: Download rstacode/wayl 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/ */
rstacode / wayl example snippets
use Wayl\Facades\Wayl;
$response = Wayl::auth()->verifyKey();
[
'data' => [],
'message' => 'Authenticated successfully'
]
use Wayl\Facades\Wayl;
$channels = Wayl::channels()->all();
foreach ($channels['data'] as $channel) {
echo $channel['name'];
echo $channel['icon'];
}
[
'data' => [
[
'id' => 'channel-123',
'name' => 'FIB',
'icon' => 'https://example.com/icon.png'
]
],
'message' => 'Success'
]
use Wayl\Facades\Wayl;
$response = Wayl::links()->create([
'referenceId' => 'order-123',
'total' => 10000,
'currency' => 'IQD',
'customParameter' => '',
'lineItem' => [
[
'label' => 'Product Name',
'amount' => 10000,
'type' => 'increase',
'image' => 'https://example.com/product.jpg'
]
],
'webhookUrl' => 'https://your-site.com/webhooks/wayl',
'webhookSecret' => 'your_webhook_secret',
'redirectionUrl' => 'https://your-site.com/success'
]);
echo $response['data']['url'];
echo $response['data']['code'];
[
'data' => [
'customParameter' => '',
'referenceId' => 'order-123',
'id' => 'cmjicw32o00jnjy089lh5kvri',
'total' => '10000',
'currency' => 'IQD',
'code' => '7G2DG958',
'paymentMethod' => null,
'type' => 'Schrödinger',
'status' => 'Created',
'completedAt' => null,
'createdAt' => '2025-12-23T09:01:58.032Z',
'updatedAt' => '2025-12-23T09:01:58.032Z',
'url' => 'https://link.thewayl.com/pay?id=cmjicw32o00jnjy089lh5kvri',
'webhookUrl' => 'https://your-site.com/webhooks/wayl',
'redirectionUrl' => 'https://your-site.com/success?referenceId=order-123&orderid=cmjicw32o00jnjy089lh5kvri'
],
'message' => 'Done',
'success' => true
]
use Wayl\Facades\Wayl;
$links = Wayl::links()->all([
'take' => 10,
'skip' => 0,
'statuses' => 'Pending'
]);
foreach ($links['data'] as $link) {
echo $link['referenceId'];
echo $link['status'];
echo $link['total'];
}
use Wayl\Facades\Wayl;
$link = Wayl::links()->find('order-123');
echo $link['data']['status'];
echo $link['data']['url'];
use Wayl\Facades\Wayl;
$response = Wayl::links()->invalidate('order-123');
use Wayl\Facades\Wayl;
$response = Wayl::links()->invalidateIfPending('order-123');
use Wayl\Facades\Wayl;
$response = Wayl::links()->batch([
'ref-001',
'ref-002',
'ref-003'
]);
echo $response['totalRequested'];
echo $response['totalFound'];
[
'data' => [...],
'message' => 'Found 2 links out of 3 requested reference IDs',
'totalRequested' => 3,
'totalFound' => 2
]
use Wayl\Facades\Wayl;
$products = Wayl::products()->all([
'take' => 10,
'skip' => 0
]);
foreach ($products['data'] as $product) {
echo $product['name'];
echo $product['price'];
echo $product['status'];
}
[
'data' => [
[
'id' => 'product-123',
'name' => 'Product Name',
'price' => '10000',
'url' => 'https://example.com/product',
'status' => 'active',
'image' => 'https://example.com/image.jpg',
'tags' => 'tag1,tag2',
'description' => 'Product description',
'createdAt' => '2025-12-23T08:42:32.665Z',
'updatedAt' => '2025-12-23T08:42:32.665Z',
'productType' => 'physical',
'qt' => 1,
'unlimited' => true
]
],
'message' => 'Success'
]
use Wayl\Facades\Wayl;
$product = Wayl::products()->find('product-123');
echo $product['data']['name'];
echo $product['data']['price'];
use Wayl\Facades\Wayl;
$subscriptions = Wayl::subscriptions()->all([
'take' => 10,
'skip' => 0
]);
foreach ($subscriptions['data'] as $subscription) {
echo $subscription['title'];
echo $subscription['amount'];
echo $subscription['subscriptionPeriod'];
}
[
'data' => [
[
'createdAt' => '2025-12-23T08:42:32.665Z',
'updatedAt' => '2025-12-23T08:42:32.665Z',
'id' => 'subscription-123',
'title' => 'Monthly Plan',
'amount' => '10000',
'currency' => 'IQD',
'subscriptionPeriod' => 'Monthly',
'gracePeriod' => 3,
'pausedSubscription' => false
]
],
'message' => 'Success'
]
use Wayl\Facades\Wayl;
$subscription = Wayl::subscriptions()->find('subscription-123');
echo $subscription['data']['title'];
echo $subscription['data']['amount'];
use Wayl\Facades\Wayl;
$subscribers = Wayl::subscribers()->all([
'take' => 10,
'skip' => 0,
'status' => 'Active'
]);
foreach ($subscribers['data'] as $subscriber) {
echo $subscriber['status'];
echo $subscriber['nextBillingAt'];
echo $subscriber['customer']['name'];
}
[
'data' => [
[
'id' => 'subscriber-123',
'createdAt' => '2025-12-23T08:42:32.665Z',
'updatedAt' => '2025-12-23T08:42:32.665Z',
'amount' => 10000,
'currency' => 'IQD',
'period' => 'Monthly',
'status' => 'Active',
'nextBillingAt' => '2025-01-23T08:42:32.665Z',
'pendingAmount' => 0,
'retryCount' => 0,
'product' => [
'id' => 'product-123',
'title' => 'Monthly Plan',
'price' => 10000,
'subscriptionPeriod' => 'Monthly'
],
'customer' => [
'id' => 'customer-123',
'name' => 'John Doe',
'email' => '[email protected] ',
'phone' => '9647501234567'
]
]
],
'message' => 'Success'
]
use Wayl\Facades\Wayl;
$response = Wayl::refunds()->create([
'referenceId' => 'order-123',
'reason' => 'Customer requested refund',
'amount' => 5000
]);
use Wayl\Facades\Wayl;
$refunds = Wayl::refunds()->all([
'referenceId' => 'order-123',
'take' => 10,
'skip' => 0,
'statuses' => 'Requested'
]);
foreach ($refunds['data'] as $refund) {
echo $refund['reason'];
echo $refund['amount'];
echo $refund['status'];
}
[
'data' => [
[
'id' => 'refund-123',
'reason' => 'Customer requested refund',
'linkId' => 'link-123',
'referenceId' => 'order-123',
'amount' => 5000,
'initiatedBy' => 'merchant',
'status' => 'Requested'
]
],
'message' => 'Success'
]
use Wayl\Facades\Wayl;
$refund = Wayl::refunds()->find('refund-123');
echo $refund['data']['status'];
echo $refund['data']['amount'];
use Wayl\Facades\Wayl;
$response = Wayl::refunds()->cancel('refund-123');
use Wayl\Wayl;
class PaymentController extends Controller
{
public function __construct(protected Wayl $wayl)
{
}
public function createPayment()
{
return $this->wayl->links()->create([
'referenceId' => 'order-123',
'total' => 10000,
'currency' => 'IQD',
]);
}
}
use Wayl\Facades\Wayl;
use Wayl\Exceptions\WaylException;
try {
$response = Wayl::links()->create([
'referenceId' => 'order-123',
'total' => 10000,
'currency' => 'IQD',
]);
} catch (WaylException $e) {
$message = $e->getMessage();
$code = $e->getCode();
$response = $e->getResponse();
// Handle the error
logger()->error('Wayl API Error', [
'message' => $message,
'code' => $code,
'response' => $response
]);
}
bash
php artisan vendor:publish --tag=wayl-config