Learn how to embed TruBuy App Payments and start collecting from your clients!
Integrating the TruBuy App with your Wix website allows you to accept secure, fast, and reliable online payments directly from your visitors. With TruBuy App's PCI-compliant gateway redirection and easy-to-use payment links, Wix users can quickly add custom checkout buttons, invoices, and hosted payment pages without complex coding. This simple integration gives your website a professional payment experience while supporting local banks and regional financial institutions. Whether you're selling products, offering services, or collecting fees online, TruBuy App makes payment processing seamless on Wix.
Tutorial: Connecting TruBuy App Payments to WIX Checkout
It is recommended to create a full site backup and conduct comprehensive testing in a staging environment before enabling this integration in production.
Connecting TruBuy App with Wix to collect payments requires:
Want an easier way to sell online? Try the TruBuy App Webstore — a no-code webstore builder with built-in payments and logistics that make running your business simple



TruBuyApp.
TruBuyApp Configuration FilesTruBuyApp-config.js.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import * as paymentProvider from 'interfaces-psp-v1-payment-service-provider'; export function getConfig() { return { title: 'TruBuy App Payments', paymentMethods: [{ hostedPage: { title: 'TruBuy App Payments', billingAddressMandatoryFields: ['CITY'], logos: { white: { svg: 'https://trubuy.app/images/ic_app_logo.svg', png: 'https://trubuy.app/images/ic_app_logo.png' }, colored: { svg: 'https://trubuy.app/images/ic_app_logo.svg', png: 'https://trubuy.app/images/ic_app_logo.png' } } } }], credentialsFields: [ { simpleField: { name: 'clientId', label: 'Merchant ID' } }, { simpleField: { name: 'clientSecret', label: 'Merchant Shared Secret' } }, { simpleField:{ name: 'paymentFacilitatorLink', label: 'Payment Facilitator Link' } }, { simpleField: { name: 'site_url', label: 'Site Return URL' } } ] } } |
TruBuyApp.js file and paste the following code:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | import * as paymentProvider from 'interfaces-psp-v1-payment-service-provider'; import { fetch } from 'wix-fetch'; import { orders } from 'wix-ecom-backend'; import { elevate } from 'wix-auth'; const crypto = require('crypto'); var debug = false; async function formatWixDate() { const myDate = new Date(); // Get the current date and time const year = myDate.getFullYear(); const month = String(myDate.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed const day = String(myDate.getDate()).padStart(2, '0'); const hours = String(myDate.getHours()).padStart(2, '0'); const minutes = String(myDate.getMinutes()).padStart(2, '0'); const seconds = String(myDate.getSeconds()).padStart(2, '0'); return `${year}:${month}:${day}-${hours}:${minutes}:${seconds}`; } export const connectAccount = async (options, context) => { const {credentials} = options return {credentials}; } export const createTransaction = async (options, context) => { const {order, merchantCredentials, wixTransactionId, paymentMethod, wixMerchantId} = options; if(debug === true)console.log('options:', options); //const url = 'https://remoteshop01.mytrubuy.com/wp-json/nf-ipg/v1/button-data/'; var error_msg = { "reasonCode": 5006, "errorCode": "General error", "errorMessage": "General error" } const formattedDate = await formatWixDate(); var checkoutId = ""; var ProductInfo = ""; var ProductDescription = ""; var ProductAmounts = 0; var ProductValues = 0; var orderId = order._id; try { const elevatedGetOrder = elevate(orders.getOrder); // Call the elevated function const orderDetails = await elevatedGetOrder(orderId); if(debug === true)console.log("orderData:", orderDetails); const retrievedOrder = await orders.getOrder(orderId); checkoutId = retrievedOrder.checkoutId; if(debug === true)console.log("Success order info:", retrievedOrder); } catch (error) { console.error(error); } for(var i = 0;i < order.description.items.length;i++){ ProductValues = ProductValues + (order.description.items[i].quantity * (parseFloat(order.description.items[i].price) / 100)); ProductAmounts = ProductAmounts + order.description.items[i].quantity; if(i === 0){ ProductInfo = order.description.items[i].name ProductDescription = order.description.items[i].quantity + " Item(s) for " + (parseFloat(order.description.items[i].price) / 100).toFixed(2) + ((parseInt(order.description.items[i].quantity) > 1)?" each":""); }else{ ProductInfo = order.description.items[i].name + " plus " + (i) + " more"; ProductDescription = ProductAmounts + " item(s) totaling " + ProductValues.toFixed(2); } } const bodyData = { SettingsCode: merchantCredentials.clientId, hash_algorithm: "HMACSHA256", platformName: 'WIX', platformMerchantId: wixMerchantId, platformTransactionId: wixTransactionId, platformCheckoutId: checkoutId, platformOrderId: orderId, platformPaymentMethod: paymentMethod, platformSiteURL: merchantCredentials.site_url, SuccessURL: order.returnUrls.successUrl, ErrorURL: order.returnUrls.errorUrl, CancelURL: order.returnUrls.cancelUrl, PendingURL: order.returnUrls.pendingUrl, product_info: ProductInfo, product_desc: ProductDescription, txndatetime: formattedDate, total: parseFloat(order.description.totalAmount) / 100, email: order.description.billingAddress?.email, fullname: (order.description.billingAddress?.firstName + " " + order.description.billingAddress?.lastName).trim(), phonenumber: order.description.billingAddress?.phone, baddr1: order.description.billingAddress?.address, bcity: order.description.billingAddress?.city, bcountry: order.description.billingAddress?.countryCode, bzip: order.description.billingAddress?.zipCode, saddr1: order.description.shippingAddress?.address, scity: order.description.shippingAddress?.city, scountry: order.description.shippingAddress?.countryCode, szip: order.description.shippingAddress?.zipCode, currency_code: order.description.currency, }; var arrkeys = Object.keys(bodyData); arrkeys = arrkeys.sort(); var messageSignatureContent = []; for(var s = 0;s < arrkeys.length;s++){ if(bodyData[arrkeys[s]].toString() !== ""){ messageSignatureContent.push(bodyData[arrkeys[s]]); } } var contenttohash = messageSignatureContent.join("|"); const messageSignature = crypto .createHmac('sha256', merchantCredentials.clientSecret) .update(contenttohash) .digest('base64'); bodyData['hashExtended'] = messageSignature; if(debug === true)console.log("bodyData:", bodyData); const http_options = { method: 'post', headers: { 'Content-Type': 'application/json' // Or other content types like 'application/x-www-form-urlencoded' }, body: JSON.stringify(bodyData) // Stringify the body for JSON content type }; var redirectUrl = ""; var pluginTransactionId = ""; var responseData = null; try { var create_payment_url_endpoint = merchantCredentials.paymentFacilitatorLink.toString(); if(create_payment_url_endpoint.endsWith("/") === false){ create_payment_url_endpoint = create_payment_url_endpoint + "/"; } create_payment_url_endpoint = create_payment_url_endpoint + "wp-json/nf-ipg/v1/button-data/"; if(debug === true)console.log("endpoint: ", create_payment_url_endpoint); const response = await fetch(create_payment_url_endpoint, http_options); if (response.ok) { responseData = await response.json(); // Or .text() for plain text if(debug === true)console.log('Success:', responseData); redirectUrl = responseData.link; pluginTransactionId = responseData.okey; } else { console.error('Error:', response.status, response.statusText); console.log('Fail:', responseData); return error_msg; } } catch (error) { console.error('Fetch error:', error); return error_msg; } if(pluginTransactionId !== null && redirectUrl !== null && pluginTransactionId !== "" && redirectUrl !== ""){ return { pluginTransactionId: pluginTransactionId, redirectUrl: redirectUrl } }else{ if(debug === false)console.log('options:', options); if(debug === false)console.log("bodyData:", bodyData); console.log('Fail:', responseData); return error_msg; } }; export const refundTransaction = async (options, context) => {}; |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /******************* http-functions.js ********************/ import { ok, badRequest } from "wix-http-functions"; import wixPaymentProviderBackend from "wix-payment-provider-backend"; // An endpoint for receiving updates about transactions. export async function post_updateTransaction(request) { const transactionRequestBody = await request.body.json(); console.log("request: ", transactionRequestBody); const response = { headers: { "Content-Type": "application/json", }, }; // Validate the request content. if (transactionRequestBody.state === "Payment_Received") { // Update the transaction status on your site. This code assumes that the Wix // transaction ID and the payment provider's transaction ID are included in // the URL as query parameters. await wixPaymentProviderBackend.submitEvent({ event: { transaction: { wixTransactionId: transactionRequestBody.platformTransactionId, pluginTransactionId: transactionRequestBody.pluginTransactionId, }, }, }); return ok(response); }else{ return badRequest(response); } } |




To ensure everything is set up correctly:
Now you’re ready to start accepting payments with TruBuy App on your Wix site!
If you are having challenges completing the integration, you can locate and open the Wix log while making a test payment.

This tutorial provides a step-by-step example for integrating payments into your existing Wix site. TruBuy App does not guarantee the accuracy, performance, or suitability of the information provided. You implement this at your own discretion, and depending on your Wix setup, you may need to hire a Wix developer to customize the integration to meet your specific requirements.
ModalBodyLabel