I built payment with Wix Pay method integreate with ‘Paymentwall’ for Korean
(References 1 : Velo Tutorial: Using the Velo Pay API to Collect Payments for a Single Product | Help Center | Wix.com )
(References 2 : Velo Tutorial: Processing Payments | Help Center | Wix.com )
and I added payment data in own dataset. Here is the code
export async function createPaymentForProduct(title , price , member , data) {
/*NOT IMPORTANT*/
//#region GET USER INFORMATION
let userInfo = { firstName : '', lastName : '', phone : '', email : '', countryCode : '' };
//RECEIVED OWN MEMBER DATASET
if(member) {
if(member.name) {
userInfo.firstName = member.name.slice(1);
userInfo.lastName = member.name.slice(0,1);
}
if(member.phone) userInfo.phone = member.phone;
if(member.email) userInfo.email = member.email;
else userInfo.email = member.id + '@hand-shake.org';
}
//#endregion
/*NOT IMPORTANT*/
return wixPayBackend.createPayment( {
amount: Number(price),
items: [{name: title, price: Number(price)}],
currency: "KRW",
userInfo : userInfo
}).then((payment) => {
console.log('created payment' , payment);
//GET 'Payment transaction ID' AND THEN SAVE TO DATASET FOR MANAGING PAYMENTS
const save = {
_id : payment.id,
amount : payment.amount,
items : payment.items,
userinfo : payment.userInfo,
type : title,
date : new Date(),
members : member._id
};
//IF USER CALL 'CHARGING POINTS' OR 'RENT FEE'
if(title.includes('point') === true) {
save.point = Number(payment.amount);
} else if(title.includes('rent') === true) {
save.place_rent = data;
}
//SAVE PAYMENT TO DATASET NAMED 'payment'
return wixData.save('payment' , save).then((saved) => {
console.log('Payment Data Saved' , saved);
return payment;
}).catch((error) => {console.log(error)});
}).catch((error) => {console.log(error)});
}
export async function wixPay_onPaymentUpdate(event) {
let payment = await wixData.get('payment' , event.payment.id);
payment.status = event.status;
payment.payDate = new Date();
//IF EVENT FIRED UPDATE THE SAVED PAYMENT
return wixData.update('payment' , payment).then(async function (updated) {
if(event.status === 'Successful') {
if(payment.audition_apply) {
let apply = await wixData.get('audition_apply' , payment.audition_apply);
apply.paid = true;
return wixData.save('audition_apply' , apply).then((saved) => {
console.log('Audition Apply Paid' , saved);
});
} else if(payment.place_rent) {
let rent = await wixData.get('place_rent' , payment.place_rent);
rent.paid = true;
rent.active = true;
return wixData.save('place_rent' , rent).then((saved) => {
console.log('Place Rent Paid' , saved);
})
} else {
let pointQueue = {
title : 'CHARGING POINT',
members : payment.members,
value : payment.amount,
date : new Date(),
payment : payment._id,
active : true
};
return wixData.save('point' , pointQueue).then((saved) => {
console.log('Point Charged' , saved);
})
}
} else {
console.log('error' , event.status , payment);
return null;
}
})
}
It works perfect, but I need ‘Refund’
I’m noop to programming but I think what just need is firing ‘Refund’ and then wixPay_onPaymentUpdate will catch event nicely… But I can’t get through it.
Any helps for me? ![]()
** in Paymentwall said
How can I request a refund?
You can request a refund directly from the seller to whom you made a payment. Refunds are subject to the Paymentwall’s Terms of Service, the website where you made a purchase, the payment method you used, and many other factors. If you feel like you were unfairly denied a refund from the seller, please contact our support team at support@paymentwall.com.
(How can I request a refund? - Support - Paymentwall)