PHP code example of xorpay / sdk

1. Go to this page and download the library: Download xorpay/sdk 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/ */

    

xorpay / sdk example snippets


'providers' => [
    //...
    Xorpay\XorpayServiceProvider::class,
],
'aliases' => [
    //...
    'Xorpay' => Xorpay\Facade::class,
],

app('xorpay')->requestPay([
    'name' => '订单名字',
    'price' => 200,
    'order_id' => 12,
    'order_uid' => 1,
    'notify_url' => route('pay.notify', $order), //回调路由
], 'native')

// 当验签不通过,自动报失败,而不会执行成功的逻辑
app('xorpay')->notifyOrder(function ($order_id) {
    $order = Order::findOrFail($order_id);
    $order->status = Order::STATUS_PAID;
    $order->save();
})