Yansongda Pay v3

website·Indexed 32 days ago

https://pay.yansongda.cn

A PHP payment SDK providing a unified architecture and plugin mechanism for integrating multiple payment gateways, including Alipay V3, WeChat Pay, Douyin, UnionPay, PayPal, Stripe, Allinpay, BestPay, and Jiangsu Bank e-融 payment. It supports common payment operations such as pay, query, refund, close, and callback handling.

Tokens
57.5K
Snippets
331
Records
406
Agent score
55%

What's inside Yansongda Pay

  1. Overview of yansongda/pay SDK v3

    v3
    The yansongda/pay SDK v3 is a payment integration library for Alipay and WeChat Pay. It features a redesigned architecture compared to v2 for better extensibility and ease of use. Key capabilities include multi-tenant support, Swoole support, a flexible plugin mechanism, and a rich event system. It abstracts the complexity of JSON and XML construction for payment APIs and includes built-in methods for automatically retrieving WeChat public certificates. The SDK is compliant with PSR standards (PSR2, PSR3, PSR4, PSR7, PSR11, PSR14, PSR18), making it compatible with various PHP frameworks.
  2. Overview of Yansongda Pay v2.x Features

    v2
    Yansongda Pay v2.x is a PHP SDK for integrating Alipay and WeChat payments. It is compliant with PSR standards and provides a high level of abstraction to avoid manual JSON/XML construction. Note that v2.x is not backward compatible with v1.x.
  3. Overview of WeChat Pay methods in Yansongda Pay

    v3
    The Yansongda Pay library provides built-in support for several WeChat Pay methods. By default, for all methods except APP and Mini Program payments, the library uses the mp_app_id (Official Account ID) from the configuration. To use a different type of AppID (e.g., a Mini Program AppID for an H5 payment), add the _type parameter to the order array (e.g., ['_type' => 'mini']).
    methodDescriptionParameterReturn Value
    mpOfficial Account (JSAPI)array $orderCollection
    h5H5 Paymentarray $orderCollection
    appAPP Paymentarray $orderCollection
    miniMini Program Paymentarray $orderCollection
    posCard/Code Paymentarray $orderCollection
    scanScan Paymentarray $orderCollection
    transferAccount Transferarray $orderCollection
  4. Overview of supported WeChat Pay methods

    v2
    The library supports 9 different WeChat Pay methods. For all methods, 'objective' parameters (such as trade_type, appid, sign, and spbill_create_ip) are handled automatically by the extension package; developers only need to provide the 'subjective' order parameters.
    methodDescriptionParameterReturn Value
    mpOfficial Account (JSAPI)array $orderCollection
    wapMobile Website (H5)array $orderResponse
    appAPP Paymentarray $orderJsonResponse
    posCard Paymentarray $orderCollection
    scanQR Code Paymentarray $orderCollection
    transferAccount Transferarray $orderCollection
    miniappMini Program Paymentarray $orderCollection
    redpackStandard Red Packetarray $orderCollection
    groupRedpackFission Red Packetarray $orderCollection
  5. Overview of supported Alipay payment methods

    v3
    The SDK provides built-in support for several Alipay payment methods. Each method accepts an order configuration array and returns either a Response or a Collection.
    methodDescriptionParameterReturn Value
    webWeb Paymentarray $orderResponse
    h5H5 Paymentarray $orderResponse
    appAPP Paymentarray $orderResponse
    miniMini Program Paymentarray $orderCollection
    posCard/POS Paymentarray $orderCollection
    scanQR Code Scan Paymentarray $orderCollection
    transferAccount Transferarray $orderCollection
  6. Overview of supported Alipay payment methods

    v2
    The Yansongda Alipay library supports 7 different payment methods. Each method takes an order array as a parameter and returns either a Response object or a Collection object.
    methodDescriptionParameterReturn Value
    webPC Paymentarray $orderResponse
    wapMobile Website Paymentarray $orderResponse
    appAPP Paymentarray $orderResponse
    posCard Payment (POS)array $orderCollection
    scanQR Code Paymentarray $orderCollection
    transferAccount Transferarray $orderCollection
    miniMini Program Paymentarray $orderCollection
  7. Listen to payment events using the Yansongda Pay SDK

    v2
    Starting from version v2.6.0-beta.1, the Yansongda Pay SDK allows developers to listen to events during the payment process to handle auxiliary tasks. The SDK implements this functionality using the symfony/event-dispatcher component.
  8. Integrate WeChat PayScore

    v3
    WeChat PayScore is accessed via the Pay::wechat()->payscore() method. The specific action to perform is determined by the _action parameter. Currently, only the direct merchant mode is supported; service provider mode is not supported. You must enable the "WeChat PayScore" feature in the WeChat Merchant Platform before use.
  9. Execute PayPal API calls using plugins in yansongda/pay

    v3
    The yansongda/pay library uses a plugin-based architecture for PayPal integrations. To call a specific PayPal API, you must provide an array of plugins to the pay() method. This array typically includes lifecycle plugins (like token acquisition and response parsing) and the specific functional plugin for the task (e.g., QueryPlugin).
    Pay::config($config);
    
    $params = [
        'order_id' => '5O190127TN364715T',
    ];
    
    // Define the plugin pipeline required for the request
    $allPlugins = [
        StartPlugin::class, 
        ObtainAccessTokenPlugin::class, 
        QueryPlugin::class, 
        AddPayloadBodyPlugin::class, 
        AddRadarPlugin::class, 
        ResponsePlugin::class, 
        ParserPlugin::class
    ];
    
    $result = Pay::paypal()->pay($allPlugins, $params);
  10. Use Allinpay plugins with yansongda/pay

    v3
    The yansongda/pay library uses a plugin architecture allowing developers to call any Allinpay API by specifying a sequence of plugins to handle the request and response lifecycle. You can mix built-in plugins and custom plugins to customize the API call behavior.
    Pay::config($config);
    
    $params = [
        'reqsn' => 'order-1001',
    ];
    
    // Define the plugin pipeline for the request
    $allPlugins = [
        \Yansongda\Pay\Plugin\Allinpay\StartPlugin::class,
        \Yansongda\Pay\Plugin\Allinpay\Tranx\QueryPlugin::class,
        \Yansongda\Pay\Plugin\Allinpay\AddPayloadSignPlugin::class,
        \Yansongda\Pay\Plugin\Allinpay\AddRadarPlugin::class,
        \Yansongda\Pay\Plugin\Allinpay\VerifySignaturePlugin::class,
        \Yansongda\Pay\Plugin\Allinpay\ResponsePlugin::class,
        \Yansongda\Artful\Plugin\ParserPlugin::class,
    ];
    
    $result = Pay::allinpay()->pay($allPlugins, $params);
  11. Call Alipay APIs using custom plugin stacks in yansongda/pay

    v3
    The yansongda/pay architecture allows calling any Alipay API by specifying a sequence of plugins. To execute a request, configure the SDK and pass an array of plugin classes to the pay() method of the Alipay instance.
    Pay::config($config);
    
    $params = [
        'out_trade_no' => '1514027114',
    ];
    
    // Define the plugin stack required for the specific API call
    $allPlugins = [
        StartPlugin::class, 
        QueryPlugin::class, 
        FormatPayloadBizContentPlugin::class, 
        AddPayloadSignaturePlugin::class, 
        AddRadarPlugin::class, 
        VerifySignaturePlugin::class, 
        ResponsePlugin::class, 
        ParserPlugin::class
    ];
    
    $result = Pay::alipay()->pay($allPlugins, $params);
  12. Execute Jiangsu Bank e-融支付 API calls using plugins

    v3
    The yansongda/pay architecture allows calling any Jiangsu Bank API by specifying a sequence of built-in or custom plugins. To execute a payment or API call, configure the SDK and pass an array of plugin classes to the pay method of the epay() instance.
    Pay::config($config);
    
    $params = [
        'outTradeNo' => '1514027114',
    ];
    
    // Define the plugin pipeline for the request
    $allPlugins = [
        StartPlugin::class, 
        QueryPlugin::class, 
        AddPayloadSignPlugin::class, 
        AddRadarPlugin::class, 
        VerifySignaturePlugin::class, 
        ResponsePlugin::class, 
        ParserPlugin::class
    ];
    
    $result = Pay::epay()->pay($allPlugins, $params);