承接 zoodpay/api-php-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

zoodpay/api-php-sdk

Composer 安装命令:

composer require zoodpay/api-php-sdk

包简介

Official ZoodPay API PHP SDK

README 文档

README

Software License Packagist Downloads

ZoodPay API

ZoodPay wants to provide its payment solution to every online business who may be interested in it. ZoodPay API v0 is the latest version which offers our latest features.

ZoodPay API Documentation

ZoodPay API API Simulator

Requirement

"Php Extension": curl, json , openssl
"php" : >=5.6,

Installation

You can install the package via composer:

composer require zoodpay/api-php-sdk

Setup

You can setup the SDK:

  1. Through .env file.
  • Copy and create .env from sample.env.php and load it.
  • Change the values accordingly.
  • The SDK will load the values automaticly.
  1. Through .env.php
  • Copy and create .env.php from sample.env.php
  • Change the values accordingly.
  • The SDK will load the values automaticly.
  1. Through Config Setter.
$config = new  Config();
$merchantKey = $config::get('merchant_id');
$merchantSecretKey = $config::get('secret_key');
$merchantSaltKey = $config::get('salt_key');
$apiBaseUrl = $config::get('api_endpoint');
$apiVersion = $config::get('api_version');
$marketCode= $config::get('market_code');
$dbHost = $config::get('db_host');
$dbPort = $config::get('db_port');
$dbDataBase = $config::get('db_database');
$dbTable = $config::get('db_table_prefix');
$dbUser = $config::get('db_user');
$dbPassword = $config::get('db_password');

Usage

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

use ZoodPay\Api\SDK\Config;
use ZoodPay\Api\SDK\Model\BillingShipping;
use ZoodPay\Api\SDK\Model\Credit;
use ZoodPay\Api\SDK\Model\Customer;
use Zoodpay\Api\SDK\Model\Delivery;
use ZoodPay\Api\SDK\Model\Items;
use ZoodPay\Api\SDK\Model\Order;
use ZoodPay\Api\SDK\Model\RefundCreate;
use ZoodPay\Api\SDK\Model\ShippingService;
use ZoodPay\Api\SDK\PersistentStorage;

use ZoodPay\Api\SDK\Requests\HealthCheck;
use ZoodPay\Api\SDK\Requests\GetConfiguration;
use ZoodPay\Api\SDK\Requests\GetTransactionById;
use ZoodPay\Api\SDK\Requests\GetRefundById;
use ZoodPay\Api\SDK\Requests\GetCreditBalance;
use ZoodPay\Api\SDK\Requests\SetTransactionDelivery;
use ZoodPay\Api\SDK\Requests\CreateTransaction;
use ZoodPay\Api\SDK\Requests\CreateRefund;
use ZoodPay\Api\SDK\Requests\Signature;

// Health check
try{
    echo "Health Check" . PHP_EOL;
    $request = new HealthCheck();
    $response = $request->get();

    echo "Status Code: " . $response->getStatusCode() . PHP_EOL; 
    echo "Response: "; print_r($response->getBody()->getContents()); 
    echo PHP_EOL;
}
catch(Exception $e){
    echo "Error: " . $e->getMessage();
    die;
}

// Get configuration
try{
    echo "Get Configuration" . PHP_EOL;
    $request = new GetConfiguration(['market_code' => 'UZ']);
    $response = $request->get();
    echo "Status Code: " . $response->getStatusCode() . PHP_EOL; 
    echo "Response: "; print_r($response->getBody()->getContents()); 
    echo PHP_EOL;
}
catch(Exception $e){
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
    

// Check database connection & fetch order limit from database.
try{
    echo "Get Limits" . PHP_EOL;
    PersistentStorage::testConnection();

    // Get order limits if Persistent Storage is configured.
    $limits = PersistentStorage::getLimits('UZ', 'ZPI');
    echo "Response: "; print_r($limits);
    echo PHP_EOL;
}
catch(Exception $e){
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}

// Get transaction status
try{
    echo "Get transaction status" . PHP_EOL;
    $request = new GetTransactionById();
    $response = $request->get('6041db6798805');
    echo "Status Code: " . $response->getStatusCode() . PHP_EOL; 
    echo "Response: "; print_r($response->getBody()->getContents()); 
    echo PHP_EOL;
}
catch(Exception $e){
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}

// Get refund status
try{
    echo "Get refund status" . PHP_EOL;
    $request = new GetRefundById();
    $response = $request->get('5f47b1ca6cf38');
    echo "Status Code: " . $response->getStatusCode() . PHP_EOL; 
    echo "Response: "; print_r($response->getBody()->getContents()); 
    echo PHP_EOL;
}
catch(Exception $e){
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}



$creditModel = new Credit();
$creditModel->setCustomerMobile("998989898895");
$creditModel->setMarketCode("UZ");

// Get credit balance
try{
    echo "Get Credit balance" . PHP_EOL;
    $request = new GetCreditBalance($creditModel->jsonSerialize());
    $response = $request->get();
    echo "Status Code: " . $response->getStatusCode() . PHP_EOL; 
    echo "Response: "; print_r($response->getBody()->getContents()); 
    echo PHP_EOL;
}
catch(Exception $e){
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
    
// Update transaction delivery
$delivery = new Delivery();
$delivery->setDeliveredAt("2021-08-10 10:42:10");
$delivery->setFinalCaptureAmount(10815);
try{
    echo "Update transaction delivery" . PHP_EOL;
    $request = new SetTransactionDelivery($delivery->jsonSerialize());
    $response = $request->set('639541327461611');
    echo "Status Code: " . $response->getStatusCode() . PHP_EOL; 
    echo "Response: "; print_r($response->getBody()->getContents()); 
    echo PHP_EOL;
}
catch(Exception $e){
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
    
// Create transaction
$billing = new BillingShipping();

$billing->setName("Test User");
$billing->setPhoneNumber("998993123456");
$billing->setAddressLine1("Test Address 1");
$billing->setAddressLine2("Test Address 2");
$billing->setCity("Test City");
$billing->setCountryCode("UZ");
$billing->setState("Test");
$billing->setZipcode("Test-123");

$order = new Order();
$order->setAmount(600.00);
$order->setCurrency("UZS");
$order->setDiscountAmount(1.00);
$order->setLang("en");
$order->setMarketCode("UZ");
$order->setMerchantReferenceNo("Test1234");
$order->setServiceCode("ZPI");
$order->setShippingAmount(1.00);
$order->setTaxAmount(1.00);
$signatureRequest = new Signature();
$order =  $signatureRequest->CreateTransactionSignature($order);

$shipping = $billing;

$customer = new Customer();
$customer->setCustomerDob("2000-12-23");
$customer->setCustomerEmail("test@zoodpay.com");
$customer->setCustomerPhone("+998993123456");
$customer->setFirstName("Test");
$customer->setLastName("TestLast");
$customer->setCustomerPid(585478965);

$shippingService = new ShippingService();
$shippingService->setName("Test Service");
$shippingService->setPriority("Express");
$shippingService->setShippedAt("Date");
$shippingService->setTracking("HHHHHHH0-hhsh");

$items[] = new Items();
$items[0]->setName("Test Product");
$items[0]->setCategories(["Products-Category1"]);
$items[0]->setCurrencyCode("UZS");
$items[0]->setDiscountAmount(1.00);
$items[0]->setPrice(600.00);
$items[0]->setQuantity(1.00);
$items[0]->setSku("Test-SKU");
$items[0]->setTaxAmount(1.00);

$callbacks = new Callbacks();
$callbacks->setErrorUrl("https://zoodpay.com");
$callbacks->setSuccessUrl("https://zoodpay.com");
$callbacks->setIpnUrl("https://zoodpay.com");
$callbacks->setRefundUrl("https://zoodpay.com");

try{
    echo "Create transaction" . PHP_EOL;
    $transactionRequest = new CreateTransaction();
    $response = $transactionRequest->create($billing,$customer,$items,$order,$shipping,$shippingService,$callbacks);
    echo "Status Code: " . $response->getStatusCode() . PHP_EOL; 
    echo "Response: "; print_r($response->getBody()->getContents()); 
    echo PHP_EOL;
}

catch(Exception $e){
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}

// Create refund


$refundModel = new RefundCreate();
$refundModel->setMerchantRefundReference("3000000004");
$refundModel->setReason("Test Unit");
$refundModel->setRefundAmount(1000);
$refundModel->setRequestId("3000000004-refund");
$refundModel->setTransactionId("639541327461611");
try{
    echo "Create refund" . PHP_EOL;
    $request = new CreateRefund();
    $response = $request->create($refundModel);
    echo "Status Code: " . $response->getStatusCode() . PHP_EOL; 
    echo "Response: "; print_r($response->getBody()->getContents()); 
    echo PHP_EOL;
}
catch(Exception $e){
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}


//ZoodPay Transaction Response Signature
echo "ZoodPay Transaction Response Signature" . PHP_EOL;
$signatureRequest = new Signature();
try {
    $ResponseSign = $signatureRequest->ZoodPayResponseSignature("UZ", "UZS", "123.00", "12345", "1133333333333");
} catch (\ZoodPay\Api\SDK\Exception\InvalidArgumentException $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}

echo "Signature: "; print_r($ResponseSign);
echo PHP_EOL;


//ZoodPay Refund Response Signature

echo "ZoodPay Refund Response Signature" . PHP_EOL;
$RefundSignatureRequest = new Signature();
try {
    $ResponseSign = $RefundSignatureRequest->ZoodPayRefundResponseSignature("000001-Refund", "1000.00", "Approved", "ZoodPay-Refund-ID");
} catch (\ZoodPay\Api\SDK\Exception\InvalidArgumentException $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}


echo "Refund Signature: "; print_r($ResponseSign);
echo PHP_EOL;

Security

If you discover any security related issues, please email integration@zoodpay.com instead of using the issue tracker.

Changelog

Please see CHANGELOG for more information what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

zoodpay/api-php-sdk 适用场景与选型建议

zoodpay/api-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 55 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「api」 「payment」 「sdk」 「bnpl」 「zoodpay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 zoodpay/api-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 zoodpay/api-php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 zoodpay/api-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-10