### Installation and Setup Commands Source: https://github.com/sazumivicky/trakteer-payment-api/blob/main/README.MD Commands to clone the repository and install necessary Node.js dependencies. ```bash git clone https://github.com/sazumivicky/trakteer-payment-api.git cd trakteer-payment-api npm install ``` -------------------------------- ### Running the Application Source: https://github.com/sazumivicky/trakteer-payment-api/blob/main/README.MD Commands to start the application using standard Node.js or Docker. ```bash # Standard Mode npm start # Using Docker docker build -t trakteer-payment-api . docker run -p 3000:3000 trakteer-payment-api ``` -------------------------------- ### Dockerfile for Trakteer Payment API Deployment Source: https://context7.com/sazumivicky/trakteer-payment-api/llms.txt This Dockerfile sets up an environment to run the Node.js server along with HAProxy for load balancing. It installs dependencies, copies application code, configures HAProxy, and exposes port 80 for external access. The container starts both HAProxy and the Node.js server. ```dockerfile # Dockerfile FROM node:latest WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN apt-get update && apt-get install -y haproxy && apt-get clean COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg EXPOSE 80 CMD ["sh", "-c", "service haproxy start && node server.js"] ``` -------------------------------- ### Process Payments via Trakteer API (Bash) Source: https://context7.com/sazumivicky/trakteer-payment-api/llms.txt Examples of using curl to interact with the Trakteer Payment Gateway API for various payment methods. This includes QRIS, GoPay, OVO, LinkAja, Virtual Accounts (BNI, BCA), DANA, ShopeePay, and Credit/Debit Cards. Each example shows the curl command and a sample JSON response. ```bash # QRIS Payment - Returns QR code for scanning curl "http://localhost:3000/payment?method=qris&pizzas=2&display_name=John%20Doe&support_message=Keep%20it%20up!" # Response: { "total": { "price": 100000, "fee": 0, "total": 100000 }, "checkout_expiration": "1 menit", "qris": { "qr_string": "00020101021226670016COM.NOBUBANK.WWW...", "status": "pending" } } # GoPay Payment - Returns deep link and QR code curl "http://localhost:3000/payment?method=gopay&pizzas=2&display_name=John%20Doe&support_message=Keep%20creating!" # Response: { "total": { "price": 100000, "fee": 0, "total": 100000 }, "checkout_expiration": "1 menit", "gopay": { "actions": [ { "name": "generate-qr-code", "url": "https://api.midtrans.com/v2/gopay/..." }, { "name": "deeplink-redirect", "url": "gojek://gopay/merchanttransfer?..." } ] } } # OVO Payment - Requires phone number curl "http://localhost:3000/payment?method=ovo&pizzas=1&display_name=John%20Doe&support_message=Great%20work!&ovo_number=085236226786" # LinkAja Payment - Requires phone number curl "http://localhost:3000/payment?method=linkaja&pizzas=1&display_name=John%20Doe&linkaja_number=085236226786" # Virtual Account BNI - Returns VA number for bank transfer curl "http://localhost:3000/payment?method=va-bni&pizzas=3&display_name=John%20Doe&support_message=Amazing!" # Response: { "total": { "price": 150000, "fee": 0, "total": 150000 }, "checkout_expiration": "1 menit", "va-bni": { "va_numbers": [ { "bank": "bni", "va_number": "9888803712345678" } ] } } # Virtual Account BCA curl "http://localhost:3000/payment?method=va-bca&pizzas=3&display_name=John%20Doe&support_message=Amazing!" # DANA Payment curl "http://localhost:3000/payment?method=dana&pizzas=2&display_name=John%20Doe" # ShopeePay Payment curl "http://localhost:3000/payment?method=shopeepay&pizzas=2&display_name=John%20Doe" # Credit/Debit Cards Payment curl "http://localhost:3000/payment?method=cards&pizzas=2&display_name=John%20Doe" ``` -------------------------------- ### GET /payment Source: https://context7.com/sazumivicky/trakteer-payment-api/llms.txt Initiates a payment request by specifying the payment method and quantity of items (e.g., pizzas). ```APIDOC ## GET /payment ### Description Initiates a payment process for Trakteer donations. This endpoint validates the payment method and required parameters to return payment instructions. ### Method GET ### Endpoint /payment ### Parameters #### Query Parameters - **method** (string) - Required - The payment provider (e.g., 'ovo', 'linkaja'). - **pizzas** (integer) - Required - The quantity of donation items. - **phone** (string) - Optional - Required if method is 'ovo' or 'linkaja'. ### Request Example curl "http://localhost:3000/payment?method=ovo&pizzas=2&phone=08123456789" ### Response #### Success Response (200) - **status** (string) - Success message or payment instructions. #### Error Response (400) - **error** (string) - Descriptive message regarding missing parameters or validation failures. #### Error Response (500) - **error** (string) - Internal server or gateway error message. ``` -------------------------------- ### Build and Run Trakteer Payment API with Docker Source: https://context7.com/sazumivicky/trakteer-payment-api/llms.txt These bash commands demonstrate how to build the Docker image for the Trakteer Payment API and run it as a container. It also shows the alternative of running the application directly using npm commands after installation. This provides flexibility in deployment. ```bash # Build and run with Docker docker build -t trakteer-payment-api . docker run -p 3000:3000 trakteer-payment-api # Or run directly with Node.js npm install npm start ``` -------------------------------- ### Trakteer Payment API Error Handling Examples Source: https://context7.com/sazumivicky/trakteer-payment-api/llms.txt This section shows examples of API requests that trigger errors, such as missing required parameters or invalid payment method details. It includes the corresponding `curl` commands and the expected JSON error responses with appropriate HTTP status codes (e.g., 400 Bad Request, 500 Internal Server Error). ```bash # Missing required parameters curl "http://localhost:3000/payment?pizzas=2" # Response (400 Bad Request): { "error": "Missing payment method or pizzas quantity" } # Missing OVO phone number curl "http://localhost:3000/payment?method=ovo&pizzas=2" # Response (400 Bad Request): { "error": "Missing OVO number for OVO payment method" } # Missing LinkAja phone number curl "http://localhost:3000/payment?method=linkaja&pizzas=2" # Response (400 Bad Request): { "error": "Missing LinkAja number for LinkAja payment method" } # Server/Gateway error # Response (500 Internal Server Error): { "error": "Oops, it looks like an error occurred, or the value you entered is wrong" } ``` -------------------------------- ### Environment Configuration for Trakteer API (.env) Source: https://context7.com/sazumivicky/trakteer-payment-api/llms.txt Example of a .env file used for configuring the Trakteer Payment Gateway API. It includes settings for the server port, Trakteer API endpoints, Midtrans integration URL, authentication tokens, and creator-specific identifiers. ```dotenv # .env configuration file PORT=3000 # Trakteer API Endpoints TRAKTEER_API_URL=https://api.trakteer.id/v2/fe/payment/total TRAKTEER_QRIS_URL=https://trakteer.id/pay/xendit/qris TRAKTEER_GOPAY_URL=https://trakteer.id/pay/midtrans/gopay TRAKTEER_OVO_URL=https://trakteer.id/pay/xendit/ovo TRAKTEER_DANA_URL=https://trakteer.id/pay/xendit/dana TRAKTEER_LINKAJA_URL=https://trakteer.id/pay/xendit/linkaja TRAKTEER_SHOPEEPAY_URL=https://trakteer.id/pay/midtrans/shopeepay TRAKTEER_VA_OTHERS_URL=https://trakteer.id/pay/midtrans/va-others TRAKTEER_VA_BNI_URL=https://trakteer.id/pay/midtrans/va-bni TRAKTEER_VA_BRI_URL=https://trakteer.id/pay/midtrans/va-bri TRAKTEER_VA_MANDIRI_URL=https://trakteer.id/pay/midtrans/va-mandiri TRAKTEER_VA_PERMATA_URL=https://trakteer.id/pay/midtrans/va-permata TRAKTEER_VA_BCA_URL=https://trakteer.id/pay/ipay/ipay-va-bca TRAKTEER_CARDS_URL=https://trakteer.id/pay/ipay/cards # Midtrans Integration MIDTRANS_CHARGE_URL=https://app.midtrans.com/snap/v2/transactions # Authentication (obtain from Trakteer.id browser session) TRAKTEER_SESSION=your_trakteer_session_cookie CSRF_TOKEN=your_csrf_token # Creator Configuration CREATOR_ID=your_creator_id UNIT_ID=your_unit_id SUPPORTER_ID=your_supporter_id ``` -------------------------------- ### GET /payment Source: https://github.com/sazumivicky/trakteer-payment-api/blob/main/README.MD Initiates a payment request through the Trakteer gateway using a specified payment method and quantity of items. ```APIDOC ## GET /payment ### Description Initiates a payment process for the specified method. The cost is calculated based on the number of pizzas (50,000 per unit). ### Method GET ### Endpoint /payment ### Parameters #### Query Parameters - **method** (string) - Required - Payment method (qris, gopay, ovo, dana, linkaja, shopeepay, va-others, va-bni, va-bri, va-mandiri, va-permata, va-bca, cards) - **pizzas** (integer) - Required - Quantity of pizzas to purchase - **display_name** (string) - Optional - Supporter's display name - **support_message** (string) - Optional - Support message - **ovo_number** (string) - Required for OVO - Phone number for OVO payment - **linkaja_number** (string) - Required for LinkAja - Phone number for LinkAja payment ### Request Example GET /payment?method=qris&pizzas=2&display_name=John%20Doe ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful - **data** (object) - Contains payment_url and order_id #### Response Example { "success": true, "data": { "payment_url": "https://payment-url.example", "order_id": "ORDER123" } } ``` -------------------------------- ### GET /payment Source: https://context7.com/sazumivicky/trakteer-payment-api/llms.txt Processes a donation payment request by calculating costs based on unit quantity and initiating the transaction via the selected payment method. ```APIDOC ## GET /payment ### Description Initiates a payment transaction for a creator support donation using specified payment methods like QRIS, e-wallets, or virtual accounts. ### Method GET ### Endpoint /payment ### Parameters #### Query Parameters - **method** (string) - Required - The payment method (e.g., qris, gopay, ovo, dana, linkaja, shopeepay, va-bni, va-bca, cards) - **pizzas** (integer) - Required - Number of units to purchase (50,000 IDR per unit) - **display_name** (string) - Required - Name of the supporter - **support_message** (string) - Optional - Message from the supporter - **ovo_number** (string) - Optional - Required if method is 'ovo' - **linkaja_number** (string) - Optional - Required if method is 'linkaja' ### Request Example curl "http://localhost:3000/payment?method=qris&pizzas=2&display_name=John%20Doe" ### Response #### Success Response (200) - **total** (object) - Contains price, fee, and total amount - **checkout_expiration** (string) - Time remaining for payment - **[method]** (object) - Payment specific details like qr_string, actions, or va_numbers #### Response Example { "total": { "price": 100000, "fee": 0, "total": 100000 }, "checkout_expiration": "1 menit", "qris": { "qr_string": "00020101021226670016...", "status": "pending" } } ``` -------------------------------- ### Payment Initiation API Source: https://github.com/sazumivicky/trakteer-payment-api/blob/main/url.txt This API endpoint allows for the initiation of payments using various methods. Different payment methods may require specific parameters. ```APIDOC ## GET /payment ### Description Initiates a payment transaction with specified details and payment method. ### Method GET ### Endpoint /payment ### Query Parameters - **method** (string) - Required - The payment method to use (e.g., qris, gopay, ovo, dana, linkaja, shopeepay, va-bni, va-bri, va-mandiri, va-permata, va-bca, va-others, cards). - **pizzas** (integer) - Required - The number of pizzas to purchase. - **display_name** (string) - Required - The display name of the customer. - **support_message** (string) - Required - A support message to be displayed. - **ovo_number** (string) - Optional - Required for OVO method, the OVO account number. - **linkaja_number** (string) - Optional - Required for LinkAja method, the LinkAja account number. ### Request Example ```json { "example": "GET http://localhost:3000/payment?method=qris&pizzas=2&display_name=John%20Doe&support_message=Semangat%20terus!" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the payment initiation. - **message** (string) - A confirmation message. #### Response Example ```json { "example": "{\"status\": \"success\", \"message\": \"Payment initiated successfully\"}" } ``` ``` -------------------------------- ### HAProxy Configuration for Load Balancing Source: https://context7.com/sazumivicky/trakteer-payment-api/llms.txt This configuration file sets up HAProxy to act as a load balancer for the Trakteer Payment API. It defines global settings, default parameters for client and server connections, and frontend/backend rules to distribute traffic across available servers. This is crucial for production deployments requiring high availability. ```cfg # haproxy.cfg - Load balancer configuration global log /dev/log local0 log /dev/log local1 notice daemon defaults log global mode http timeout connect 5000 timeout client 50000 timeout server 50000 frontend http-in bind *:3000 default_backend servers backend servers server server1 localhost:3001 check server proxy1 your-proxy-server:40007 check ``` -------------------------------- ### Environment Variable Configuration Source: https://github.com/sazumivicky/trakteer-payment-api/blob/main/README.MD Required environment variables for the application, including API URLs, session tokens, and IDs. ```env PORT=3000 TRAKTEER_API_URL=your_api_url TRAKTEER_QRIS_URL=your_qris_url TRAKTEER_GOPAY_URL=your_gopay_url TRAKTEER_OVO_URL=your_ovo_url TRAKTEER_DANA_URL=your_dana_url TRAKTEER_LINKAJA_URL=your_linkaja_url TRAKTEER_SHOPEEPAY_URL=your_shopeepay_url TRAKTEER_VA_OTHERS_URL=your_va_others_url TRAKTEER_VA_BNI_URL=your_va_bni_url TRAKTEER_VA_BRI_URL=your_va_bri_url TRAKTEER_VA_MANDIRI_URL=your_va_mandiri_url TRAKTEER_VA_PERMATA_URL=your_va_permata_url TRAKTEER_VA_BCA_URL=your_va_bca_url TRAKTEER_CARDS_URL=your_cards_url TRAKTEER_SESSION=your_session_token CSRF_TOKEN=your_csrf_token CREATOR_ID=your_creator_id UNIT_ID=your_unit_id SUPPORTER_ID=your_supporter_id MIDTRANS_CHARGE_URL=your_midtrans_url ``` -------------------------------- ### API Response Formats Source: https://github.com/sazumivicky/trakteer-payment-api/blob/main/README.MD JSON structures for successful and error API responses. ```json { "success": true, "data": { "payment_url": "https://payment-url.example", "order_id": "ORDER123" } } { "success": false, "error": "Error message description" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.