Download the PHP package sunmi/sunbay-nexus-sdk-php without Composer
On this page you can find all versions of the php package sunmi/sunbay-nexus-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sunbay-nexus-sdk-php
Sunbay Nexus PHP SDK
Official PHP SDK for Sunbay Nexus Payment Platform
Current Version: 1.0.5
Features
- ✅ Simple and intuitive API
- ✅ PHP 8.1+ named arguments for clean, readable construction
- ✅ Fluent setter & Builder pattern also supported
- ✅ Automatic authentication
- ✅ Automatic retry for GET requests
- ✅ HTTP connection pool with configurable limits
- ✅ Comprehensive exception handling
- ✅ Minimal dependencies
Installation
Please visit https://packagist.org/packages/sunmi/sunbay-nexus-sdk-php to get the latest version.
Add the following to your composer.json:
Then run:
Quick Start
1. Initialize Client
The NexusClient is thread-safe and should be instantiated once and reused throughout
your application's lifecycle. Each instance holds its own HTTP connection pool; creating a
new client per request wastes connections and defeats connection reuse.
Builder pattern:
2. Sale Transaction
Important: All amount fields use the smallest currency unit (integer).
For example: 100.00 USD = 10000 cents.
API Methods
All request classes support named arguments (recommended), fluent setters, and Builder pattern.
Transaction APIs
sale(SaleRequest)- Sale transactionauth(AuthRequest)- Authorization (pre-auth)forcedAuth(ForcedAuthRequest)- Forced authorizationincrementalAuth(IncrementalAuthRequest)- Incremental authorizationpostAuth(PostAuthRequest)- Post authorization (pre-auth completion)refund(RefundRequest)- RefundvoidTransaction(VoidRequest)- Void transactionabort(AbortRequest)- Abort transactiontipAdjust(TipAdjustRequest)- Tip adjust
Query APIs
query(QueryRequest)- Query transaction
Settlement APIs
batchQuery(BatchQueryRequest)- Batch querybatchClose(BatchCloseRequest)- Batch closebatchCloseList(BatchCloseListRequest)- Query settled batch list
Merchant APIs
merchantQuery(MerchantQueryRequest)- Query merchant informationmerchantTerminalsQuery(MerchantTerminalsQueryRequest)- Query merchant terminals (token-based pagination, max 100 per page)
Online Checkout APIs
createCheckoutSession(CreateCheckoutSessionRequest)- Create hosted payment page sessionexpireCheckoutSession(ExpireCheckoutSessionRequest)- Expire checkout sessioncheckoutSale(CheckoutSaleRequest)- Direct online checkout sale (Google Pay / Apple Pay)onlineRefund(OnlineRefundRequest)- Online refund
Response Objects
All response objects extend BaseResponse and provide the following common methods:
isSuccess()- Check if the response is successful (code is "0"). Note: If code is not "0", aSunbayBusinessExceptionwill be thrown automatically, so you typically don't need to check this manually.getCode()- Get response codegetMsg()- Get response messagegetTraceId()- Get trace ID for troubleshooting
Important: The SDK automatically throws SunbayBusinessException when the API returns a non-zero code. If your code reaches the response handling without catching an exception, the response is guaranteed to be successful (code = "0").
Transaction responses (e.g., SaleResponse, AuthResponse) also provide:
getTransactionId()- Get transaction IDgetReferenceOrderId()- Get reference order IDgetTransactionRequestId()- Get transaction request ID
Exception Handling
The SDK throws two types of exceptions:
- SunbayNetworkException: Network-related errors (connection timeout, network error, etc.)
- SunbayBusinessException: Business logic errors (parameter validation, API business errors, etc.)
Always catch SunbayNetworkException before SunbayBusinessException:
Configuration
Logging
The SDK supports PSR-3 compatible loggers for recording HTTP requests and responses. You can use any PSR-3 compatible logging library:
Enums
The SDK provides type-safe enums for common payment-related values. These enums help prevent invalid values and provide better IDE support:
Available Enums
PaymentCategory- Payment method categories (CARD, CARD_CREDIT, CARD_DEBIT, QR_MPM, QR_CPM)TransactionStatus- Transaction status codes returned by API (I=INITIAL, P=PROCESSING, S=SUCCESS, F=FAIL, C=CLOSED)TransactionType- Transaction types (SALE, AUTH, FORCED_AUTH, INCREMENTAL, POST_AUTH, REFUND, VOID)CardNetworkType- Card network types (CREDIT, DEBIT, EBT, EGC, UNKNOWN)EntryMode- Card entry modes (MANUAL, SWIPE, FALLBACK_SWIPE, CONTACT, CONTACTLESS)AuthenticationMethod- Authentication methods (NOT_AUTHENTICATED, PIN, OFFLINE_PIN, BY_PASS, SIGNATURE)SignatureEntryLocation- Signature entry locations (ON_SCREEN, ON_RECEIPT)
Usage Example
Note:
- While enums provide type safety, the SDK maintains backward compatibility with string values. You can continue using strings (e.g.,
"CARD") or use enums for better type safety. - For
TransactionStatus, the API returns single-character codes (I, P, S, F, C) rather than full names. The enum values match these codes.
Requirements
- PHP 8.1 or higher
- Guzzle HTTP 7.5+
- PSR-3 Logger (optional)
License
MIT License