1. Go to this page and download the library: Download maxiewright/laravel-wipay 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 Illuminate\Http\Request;
use Maxiewright\LaravelWipay\Facades\LaravelWipay as Wipay;
public function __invoke(Request $request)
{
$result = Wipay::verifyReturn($request, [
'order_id' => $request->input('order_id'),
'total' => '99.00',
'currency' => 'TTD',
]);
if ($result->ok()) {
// Mark the local order paid using $result->transactionId.
}
return view('payments.return', ['result' => $result]);
}
use Illuminate\Support\Facades\Event;
use Maxiewright\LaravelWipay\Events\WipayWebhookVerified;
Event::listen(WipayWebhookVerified::class, function (WipayWebhookVerified $event): void {
$result = $event->result;
// Reconcile the local payment by $result->orderId and $result->transactionId.
});
use Maxiewright\LaravelWipay\Data\WipayCheckout;
use Maxiewright\LaravelWipay\Facades\LaravelWipay as Wipay;
Wipay::fake()->checkoutUrl('https://tt.wipayfinancial.com/hosted-page/test');
$response = Wipay::platformCheckout(new WipayCheckout(
orderId: 'TS-001',
total: '99.00',
responseUrl: 'https://app.test/wipay/return',
))->create();
expect($response->url())->toBe('https://tt.wipayfinancial.com/hosted-page/test');
Wipay::assertCheckoutCreated(
fn (array $fields): bool => $fields['order_id'] === 'TS-001'
);