craymend/serve-first-php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

craymend/serve-first-php-sdk

最新稳定版本:1.0.1

Composer 安装命令:

composer require craymend/serve-first-php-sdk

包简介

A PHP wrapper for the Serve First payments API

README 文档

README

This package is a PHP wrapper for the Serve First API.

Requirements

This project works with PHP 7.2+.

Installation

Install with composer:

composer require craymend/serve-first-php-sdk

Examples

Create an instance of Request. Be sure to set sandbox mode when testing.

<?php

require __DIR__ . '/vendor/autoload.php';

use Craymend\ServeFirst\Request;

$apiVersion = 'v2';

$mode = Request::MODE_SANDBOX;
// $mode = Request::MODE_PRODUCTION;

$sourceKey = 'your-key';
$sourcePin = 'your-pin';

$request = new Request($sourceKey, $sourcePin);

// the mode controls the baseUrl
echo 'baseUrl: ' . $request->getBaseUrl() . '<br>';
echo 'Switch to sandbox mode<br>';
$request->setMode($mode); // Change to sandbox mode
echo 'baseUrl: ' . $request->getBaseUrl() . '<br>';

You can now use the Serve First API. For example, retrieve product categories:

<?php

echo "Test getting data:<br><br>";

$uri = '/products/categories';

$data = [];

$result = $request->get($uri, $data);

if (!$result->getStatus()) {
    echo 'error:<br><br>';

	$errors = $result->getErrors();
    echo json_encode($errors);
}else{
    echo 'Success! data:<br><br>';
    $data = $result->getData();
    echo 'data: ' . json_encode($data) . '<br>';
}

License

MIT

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-23