@muhammedaksam/sipay-node
Version:
Node.js TypeScript SDK for Sipay payment gateway
81 lines • 3.29 kB
TypeScript
/**
* Utility functions for Sipay SDK
*/
/**
* Validate credit card number using Luhn algorithm
*/
export declare function luhnCheck(cardNumber: string): boolean;
/**
* Validate credit card number (alias for luhnCheck)
*/
export declare function validateCreditCard(cardNumber: string): boolean;
/**
* Mask credit card number for display
*/
export declare function maskCardNumber(cardNumber: string): string;
/**
* Format amount for Sipay API - amounts should be sent as numbers, not cents
*/
export declare function formatAmount(amount: number): string;
/**
* Format amount specifically for hash key generation
* This should match PHP's number_format($amount, 2, ".", "") exactly
* PHP always formats with 2 decimal places: 10.00, 125.50, etc.
*/
export declare function formatAmountForHash(amount: number): string;
/**
* Generate hash key for payment requests
* Order matches PHP SDK CreateNonSecurePaymentRequest::generateHashKeyParts():
* 1. total, 2. installments_number, 3. currency_code, 4. merchant_key, 5. invoice_id
*/
export declare function generatePaymentHashKey(total: number, installment: number, currencyCode: string, merchantKey: string, invoiceId: string, apiSecret: string): string;
/**
* Generate hash key for status check requests
* Order matches PHP SDK CheckTransactionStatusRequest::generateHashKeyParts():
* 1. invoice_id, 2. merchant_key
*/
export declare function generateStatusHashKey(invoiceId: string, merchantKey: string, apiSecret: string): string;
/**
* Generate hash key for payment confirmation requests
* Order matches PHP SDK: merchant_key|invoice_id|status
*/
export declare function generateConfirmPaymentHashKey(merchantKey: string, invoiceId: string, status: number, apiSecret: string): string;
/**
* Generate hash key for payment requests
* Exact 1:1 Node.js implementation of PHP's generateHashKey function
* Matches: $total . '|' . $installment . '|' . $currency_code . '|' . $merchant_key . '|' . $invoice_id
* with openssl_encrypt('aes-256-cbc') encryption
*/
export declare function generateHashKey(parts: (string | number)[], appSecret: string): string;
/**
* Generate a unique invoice ID
*/
export declare function generateInvoiceId(prefix?: string): string;
/**
* Validate required payment fields
*/
export declare function validatePaymentData(data: any): string[];
/**
* Mask credit card number for logging
*/
export declare function maskCreditCard(cardNumber: string): string;
/**
* Parse Sipay error response
*/
export declare function parseSipayError(error: any): {
code: number;
message: string;
};
/**
* Validate hash key using server-side validation logic
* This matches exactly what the PHP SDK does for server-side validation
* Expected decrypted format: status|total|invoiceId|orderId|currencyCode
*/
export declare function validateHashKey(hashKey: string, secretKey: string): [string, number, string, number, string];
/**
* Generate hash key in server validation format
* Server expects: status|total|invoiceId|orderId|currencyCode
*/
export declare function generateServerFormatHashKey(status: string, total: number, invoiceId: string, orderId: number, currencyCode: string, appSecret: string): string;
export * from './status-code-helpers';
//# sourceMappingURL=index.d.ts.map