Can someone PLEASE share the backend code and the client side code for collecting payments based on QUANTITY? For example I need my clients to pay $25 per page for my Standard Editing service.
https://support.wix.com/en/article/wix-code-tutorial-processing-payments
https://www.wix.com/code/reference/wix-pay.html
https://www.wix.com/code/reference/wix-pay-backend.html
https://support.wix.com/en/article/wix-code-tutorial-using-the-wix-pay-api-to-collect-payments-for-a-single-product
https://support.wix.com/en/article/wix-code-tutorial-using-the-wix-pay-api-to-collect-payments-for-products-in-a-database-collection
https://www.wix.com/code/home/forum/wix-tips-and-updates/example-accept-payments-with-wix-pay-api
I clicked on each one of the links you so graciously took the time to post just to be sure that you didn’t share one that I hadn’t yet discovered. Unfortunately however, in my exhausting search for answers, I read and watched EACH one of the resources you shared before posting my detailed question to this forum. I am now desperately working on my umpteenth attempt to make this work by adding a separate button for each of the 5 quantity options after first creating 5 separate backend functions - one per quantity option. I’ve already added the 5 different client side export functions with the HOPE that this happens to do the trick. If there is a more efficient way of accomplishing the goal I detailed in my post, an example of its implementation would be GREATLY appreciated. Thx.
@juanita-taylor
I believe this should work for you.
PAGE CODE
import {createMyPayment} from 'backend/pay';
import wixPay from 'wix-pay';
export function buynow_click(event) {
createMyPayment($w('#productname').text, $w('#qty').value, $w('#price').text,)
.then( (payment) => {
wixPay.startPayment(payment.id);
} );
}
BACKEND jsw
//pay.jsw
import wixPay from 'wix-pay-backend';
export function createMyPayment(description,value, customamount){
let cPaymentString = {
amount: customamount * value,
quantity: value,
items:
[{name: description, quantity:value, price: customamount, }] };
return wixPay.createPayment(cPaymentString);
}
Note that:
Name is a text field.
Quantity is an input field, but it could be a dropdown
Price is a text field that is a number
This is also attached to a database, but it doesn’t have to be.