spare-technologies/php-sdk
最新稳定版本:1.1.2
Composer 安装命令:
composer require spare-technologies/php-sdk
包简介
Spare payment sdk
README 文档
README
Usage
I- Installation
composer require spare-technologies/php-sdk "^1.1"
Include these files in your application and do this at the top of your file:
require __DIR__ . '/vendor/autoload.php';
II- To Generate ECC key pair
use Helpers\Crypto\SpCrypto; public class MyClass { $keys = SpCrypto::GenerateKeyPair(); echo "Private key \n" . nl2br($keys->getPrivateKey()); echo "\n\n"; echo "Public key \n" . nl2br($keys->getPublicKey()) }
III- To create your first payment request
use Helpers\Security\DigitalSignature\EccSignatureManager; use Helpers\Serialization\SpSerializer; use Payment\Client\SpPaymentClient; public class MyClass { // Business ECC private key public static string $privateKey = ""; // Spare ECC public key public static string $serverPublicKey = ""; public static function createPayment(): void { // Configure client $clientOptions = new SpPaymentClientOptions( "https://payment.tryspare.com", "Your app id", "Your API key" ); $client = new SpPaymentClient($clientOptions); // Initialize payment $paymentRequest = new SpPaymentRequest(); $paymentRequest->setAmount(10.0); $paymentRequest->setDescription("Test payment"); $paymentRequest->setOrderId("8jwaQ"); // Sign the payment $signature = EccSignatureManager::Sign($paymentRequest->toJonsString(), $privateKey); // Create payment $paymentResponse = $this->paymentClient->CreateDomesticPayment($paymentRequest, $signature); // To verify signature of the created payment if (EccSignatureManager::Verify($serverPublicKey, $paymentResponse->getPayment()->toJonsString(), createPayment->getSignature())) { // signature verified } } }
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-05