ตั้งค่า

เตรียม Consumer Key ของท่าน

  1. ไปที่ https://apiportal.kasikornbank.com/product และเข้าสู่ระบบด้วยบัญชีผู้ใช้งานของท่าน

  2. สร้าง Application จาก Product ที่ท่านต้องการใช้งาน

  3. หลังจากที่สร้าง application, ท่านจะได้ consumer id และ consumer secret, 2 ค่านี้จะใช้ในการตั้งค่าต่อไป

  4. นำทั้งสองค่านี้มาตั้งค่าใน client ของท่านดังนี้

use Farzai\KApi\ClientBuilder;

$client = ClientBuilder::make()
    ->setConsumer("<YOUR_CONSUMER_ID>", "<YOUR_CONSUMER_SECRET>")
    ->asSandbox()
    ->build();

การตั้งค่าอื่นๆ

use Farzai\KApi\ClientBuilder;

$builder = ClientBuilder::make();

// ตั้งค่า consumer id และ consumer secret
$builder->setConsumer("<YOUR_CONSUMER_ID>", "<YOUR_CONSUMER_SECRET>");

// ตั้งค่าเป็น sandbox
$builder->asSandbox();

// ตั้งค่าให้เป็น production
$builder->asProduction();

// ใช้งาน http client ที่ต้องการ
$builder->setClient(Psr\Http\Client\ClientInterface);

// เปลี่ยนวิธีการเก็บ token ด้วยตนเอง
$builder->setTokenRespository(Farzai\KApi\Contracts\AccessTokenRepositoryInterface);

// ตั้งค่า logger
$builder->setLogger(Psr\Log\LoggerInterface);

// สร้าง Client
$client = $builder->build();

Last updated