### Get Merchant Information (TypeScript) Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Retrieves detailed merchant account information and configuration settings from GB Prime Pay. This includes currency details, display settings, and merchant contact information. ```typescript const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); const merchantInfo = await gbpay.getMerchantInfo(); if (merchantInfo) { console.log(merchantInfo); /* Output: { currency_code: "THB", currency_code_th: "บาท", currency_iso: "THB", currency_iso_th: "บาท", currency_sign: "฿", currency_sign_th: "฿", display_theme: "light", display_color: "#FF5733", merchantId: 12345, merchant_address_1: "123 Business Street", merchant_address_2: "Bangkok, Thailand", merchant_address_1_th: "123 ถนนธุรกิจ", merchant_address_2_th: "กรุงเทพฯ ประเทศไทย", merchant_companyname: "My Company Ltd.", merchant_companyname_th: "บริษัท ของฉัน จำกัด", merchant_conditions: "Terms and conditions...", merchant_logo: "https://example.com/logo.png", merchant_phone: "+66-2-123-4567", merchant_taxid: "0123456789012", merchant_website: "https://example.com" } */ } else { console.log('Failed to retrieve merchant info'); } ``` -------------------------------- ### Initialize GBPrimePay Client (TypeScript) Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Instantiates the GBPrimePay client with merchant credentials for either production or sandbox environments. Supports raw mode for unprocessed API responses. ```typescript import { GBPrimePay } from 'gbprimepay'; // Production environment const gbpay = new GBPrimePay( 'your-token', 'your-public-key', 'your-secret-key', false, // sandbox mode (false = production) false // raw mode (false = parsed responses) ); // Sandbox/test environment const gbpayTest = new GBPrimePay( 'test-token', 'test-public-key', 'test-secret-key', true, // sandbox mode enabled false ); // Raw mode for unprocessed API responses const gbpayRaw = new GBPrimePay( 'your-token', 'your-public-key', 'your-secret-key', false, true // raw mode enabled - returns unparsed HTML/JSON ); ``` -------------------------------- ### Create QR Code Payment with GBPrimePay SDK Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Generates a Thai QR code for PromptPay payments using the GBPrimePay SDK. Requires GBPrimePay SDK initialization with token, public key, and secret key. Outputs QR code data and transaction details. ```typescript import { GBPrimePay, Channels } from 'gbprimepay'; const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); try { const qrPayment = await gbpay.create(Channels.QR_CASH, { amount: 150.50, referenceNo: 'INV-2025-001', detail: 'Product purchase', customerName: 'John Doe', customerEmail: 'john@example.com', customerTelephone: '0812345678', merchantDefined1: 'user_id:12345', merchantDefined2: 'cart_id:abc123' }); console.log(qrPayment); /* Output: { referenceNo: "INV-2025-001", qrcode: "00020101021230820016A000000677010111011301234567890208GBPAY999530376454041505802TH5913My Company Ltd6304ABCD", resultCode: "00", gbpReferenceNo: "gbp_20250101_123456", resultMessage: "Success" } */ // Display QR code to customer for scanning displayQRCode(qrPayment.qrcode); } catch (error) { console.error('Payment creation failed:', error); } ``` -------------------------------- ### Create LINE Pay Payment with GBPrimePay SDK Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Initiates a LINE Pay payment and provides a direct checkout URL. Requires GBPrimePay SDK initialization. Accepts amount, reference number, details, and callback URLs. Returns a checkout URL for redirection. ```typescript import { GBPrimePay, Channels } from 'gbprimepay'; const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); const linePayment = await gbpay.create(Channels.LINEPAY, { amount: '299.00', referenceNo: 'ORDER-LINE-001', detail: 'Premium subscription', responseUrl: 'https://example.com/payment/callback', backgroundUrl: 'https://example.com/payment/webhook', customerName: 'Jane Smith', customerEmail: 'jane@example.com', customerTelephone: '0898765432' }); // Returns direct LINE Pay checkout URL (when raw=false) console.log(linePayment); // Output: "https://pay.line.me/checkout/web/payment?transactionId=2025010112345678" // Redirect customer to this URL res.redirect(linePayment); ``` -------------------------------- ### Create Alipay Payment (TypeScript) Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Processes Alipay payments for Chinese customers. The process involves initializing the GBPrimePay SDK with credentials and providing payment details such as amount, reference number, background URL, and customer information. The output format varies based on merchant configuration. ```typescript import { GBPrimePay, Channels } from 'gbprimepay'; const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); const alipayPayment = await gbpay.create(Channels.ALIPAY, { amount: '3200.00', referenceNo: 'ORDER-ALIPAY-001', backgroundUrl: 'https://example.com/payment/webhook', detail: 'Hotel booking', customerName: 'Zhang San', customerEmail: 'zhangsan@example.com' }); console.log(alipayPayment); // Output: Payment data or redirect URL (format varies) // Note: Alipay integration format depends on merchant configuration ``` -------------------------------- ### Create TrueMoney Wallet Payment with GBPrimePay SDK Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Processes TrueMoney Wallet payments, including OTP verification. This involves creating the payment, sending an OTP, and submitting the OTP for verification. Requires GBPrimePay SDK initialization and customer's phone number. Supports resending OTP if verification fails. ```typescript import { GBPrimePay, Channels } from 'gbprimepay'; const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); // Step 1: Create payment const ptxId = await gbpay.create(Channels.TRUEWALLET, { amount: 500, referenceNo: 'ORDER-TMN-001', responseUrl: 'https://example.com/payment/callback', backgroundUrl: 'https://example.com/payment/webhook', customerTelephone: '0812345678', customerName: 'Somchai', customerEmail: 'somchai@example.com' }); console.log('Payment Transaction ID:', ptxId); // Output: "987654321" // Step 2: Send OTP to customer's mobile const otpForm = await gbpay.truemoney_sendOtp('0812345678', ptxId); console.log('OTP sent, form data:', otpForm); // Output: { payment_id: "pay_123", transaction_id: "txn_456", ... } // Step 3: Customer receives OTP via SMS, submit it try { await gbpay.truemoney_submitOtp('123456', otpForm); console.log('Payment successful!'); } catch (error) { console.error('OTP verification failed:', error); // Step 4 (optional): Resend OTP if needed const resendForm = await gbpay.truemoney_resendOtp(ptxId); console.log('OTP resent, new form data:', resendForm); } ``` -------------------------------- ### Create ShopeePay Payment with GBPrimePay SDK Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Generates a ShopeePay checkout URL for payment processing. Uses the GBPrimePay SDK with required API keys. Accepts payment details and callback URLs. The returned URL is used to redirect the customer to ShopeePay. ```typescript import { GBPrimePay, Channels } from 'gbprimepay'; const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); const shopeePayment = await gbpay.create(Channels.SHOPEEPAY, { amount: 750.00, referenceNo: 'ORDER-SHOPEE-001', responseUrl: 'https://example.com/payment/callback', backgroundUrl: 'https://example.com/payment/webhook', detail: 'Electronics purchase', customerName: 'Preecha', customerEmail: 'preecha@example.com' }); // Returns direct ShopeePay checkout URL console.log(shopeePayment); // Output: "https://wsa.wallet.airpay.th/checkout/pay?transactionId=SP2025010112345" // Redirect to ShopeePay window.location.href = shopeePayment; ``` -------------------------------- ### Create WeChat Pay Payment (TypeScript) Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Initializes a WeChat Pay transaction for Chinese customers. Requires GBPrimePay SDK initialization and payment details including amount, reference number, and callback URL. The output can be an HTML page for QR code display or raw payment data. ```typescript import { GBPrimePay, Channels } from 'gbprimepay'; const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); const wechatPayment = await gbpay.create(Channels.WECHAT, { amount: 2500, referenceNo: 'ORDER-WECHAT-001', backgroundUrl: 'https://example.com/payment/webhook', detail: 'Fashion items', customerName: 'Li Wei', customerEmail: 'liwei@example.com' }); console.log(wechatPayment); // Output: HTML page or payment data (format varies) // Note: WeChat Pay integration may return HTML for QR code display ``` -------------------------------- ### Create Mobile Banking Payment (TypeScript) Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Generates mobile banking app deeplinks for various Thai banks (e.g., SCB Easy, Bangkok Bank). Requires GBPrimePay SDK initialization with API keys and payment details including amount, reference number, bank code, and callback URLs. ```typescript import { GBPrimePay, Channels, BankCodes } from 'gbprimepay'; const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); // SCB Easy App payment const scbPayment = await gbpay.create(Channels.MOBILE_BANKING, { amount: 1250.00, referenceNo: 'ORDER-SCB-001', bankCode: BankCodes.SCB_EASY, responseUrl: 'https://example.com/payment/callback', backgroundUrl: 'https://example.com/payment/webhook', customerName: 'Nattapong', customerEmail: 'nattapong@example.com' }); console.log('SCB Easy App Deeplink:', scbPayment); // Output: "scbeasy://pay?deeplink_param=abc123..." // Bangkok Bank mBanking payment const bblPayment = await gbpay.create(Channels.MOBILE_BANKING, { amount: 890.00, referenceNo: 'ORDER-BBL-001', bankCode: BankCodes.BBL, responseUrl: 'https://example.com/payment/callback', backgroundUrl: 'https://example.com/payment/webhook' }); console.log('Bangkok Bank mBanking Deeplink:', bblPayment); // Output: "bualuangmbanking://mbanking.payment?merchantId=123&amount=890.00..." // Supported bank codes: KPLUS (004), SCB_EASY (014), KMA (025), BBL (002), KTB (006) ``` -------------------------------- ### Check Payment Status (TypeScript) Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Queries the status of a transaction using the merchant reference number. This function requires the GBPrimePay SDK to be initialized. It returns detailed payment status information, including success, pending, or failure codes, allowing for order processing logic. ```typescript const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); const paymentStatus = await gbpay.check('ORDER-2025-001'); if (paymentStatus) { console.log(paymentStatus); /* Output example: { referenceNo: "ORDER-2025-001", gbpReferenceNo: "gbp_20250101_123456", resultCode: "00", amount: "150.50", currency: "THB", statusCode: "001", statusText: "Successful", date: "2025-01-01 14:30:00", cardNo: "xxxx-xxxx-xxxx-1234" } */ if (paymentStatus.statusCode === '001') { console.log('Payment successful! Processing order...'); // Update order status in database } else if (paymentStatus.statusCode === '000') { console.log('Payment pending...'); } else { console.log('Payment failed or cancelled'); } } else { console.log('Transaction not found or API error'); } ``` -------------------------------- ### Validate Merchant Credentials (TypeScript) Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Verifies the validity of merchant public key, secret key, and token with the GB Prime Pay gateway. Returns merchant information upon successful validation or null if validation fails. ```typescript const gbpay = new GBPrimePay('token', 'public-key', 'secret-key'); // Validate public key try { const publicKeyInfo = await gbpay.validatePublicKey(); if (publicKeyInfo) { console.log('Public key valid:', publicKeyInfo); // Output: { merchantId: "12345", initialShop: "Shop1", merchantName: "My Store" } } else { console.log('Invalid public key'); } } catch (error) { console.error('Validation failed:', error); } // Validate secret key const secretKeyInfo = await gbpay.validateSecretKey(); console.log(secretKeyInfo); // Output: { merchantId: "12345", initialShop: "Shop1", merchantName: "My Store" } or null // Validate token const tokenInfo = await gbpay.validateToken(); console.log(tokenInfo); // Output: { merchantId: "12345", initialShop: "Shop1", merchantName: "My Store" } or null ``` -------------------------------- ### Generate Checksum for Payment Verification (TypeScript) Source: https://context7.com/maythiwat/node-gbprimepay/llms.txt Generates an HMAC SHA256 checksum required for payment request validation. This static method can be used without instantiating the client and supports optional bank codes for mobile banking. ```typescript import { GBPrimePay } from 'gbprimepay'; // Static method - can be used without instantiating const checksum = GBPrimePay.getChecksum( 'your-secret-key', '100.00', // amount 'ORDER-20250101', // referenceNo 'https://example.com/callback', // responseUrl 'https://example.com/background' // backgroundUrl ); console.log(checksum); // Output: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2" // With bank code for mobile banking const checksumMobile = GBPrimePay.getChecksum( 'your-secret-key', '100.00', 'ORDER-20250102', 'https://example.com/callback', 'https://example.com/background', '014' // SCB bank code ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.