Community X.

Connect with other creators, share ideas, give feedback and get the latest product updates.

Jan 12

Is there a way to make a chain payment with Velo Pay?

Hi, I am trying to make a system where one client makes a payment to my website/service, and then part of this payment is transferred to another client (also known as chain payment). I was wondering if there is a way to implement this just by using the Velo Pay API, or should I use an external API to be able to achieve this? Thanks for the help in advance!

2

Hey @fi8.office,

I'm Shiri from the Editor X team.

Thank you for bringing this to our attention.

Currently, there is no way to make a chain payment with Velo Pay, so you should use an external API.

We will investigate if we can implement a more direct solution to this in the future.


5d agoEdited: 4d ago

Thank you for your answer! I did manage to implement a chain payment using the Paypal API, but having an integrated Velo solution would be great! I will post my solution for people struggling with the implementation:


export async function chainPayment(receiverEmailprimaryPaymentsecondaryPayment)
{

 var payloadOBJ = {
 "requestEnvelope": {
 "errorLanguage": 'en_US'
      },
 "actionType": 'PAY',
 "currencyCode": 'USD',
 "feesPayer": 'EACHRECEIVER',
 "memo": 'Chained payment',
 "cancelUrl": '', // URL of redirection when payment is unsuccessful
 "returnUrl": '', // URL of redirection when payment is successful
 "receiverList": {
 "receiver": [{
 "email": '', // Primary receiver email (aka you)
 "amount": primaryPayment,
 "primary":'true'
         },
         {
 "email": receiverEmail, // The item owner / service provider email,
 "amount": secondaryPayment,
 "primary":'false'
         }]
      }
   };

 const response = await fetch("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay", {
 method: 'post',
 headers: {
 "X-PAYPAL-SECURITY-USERID" : "", // The developer username
 "X-PAYPAL-SECURITY-PASSWORD": "",// The developer password"
 "X-PAYPAL-SECURITY-SIGNATURE": "", // The developer signature"
 "X-PAYPAL-REQUEST-DATA-FORMAT": "JSON", //NV
 "X-PAYPAL-RESPONSE-DATA-FORMAT": "JSON", //NV
 "X-PAYPAL-APPLICATION-ID": "" // Application ID"    
      },
 body: JSON.stringify(payloadOBJ)
   });
 const ret = await response.json();
 return ret;
}

This is how the request looks like and this is how to use the function


let response = await chainPayment(reveiverEmail, primaryAmount, secondaryAmount); // Primary amount is the amount of money you are looking to receive plus the amount you will give to the secondary reveiver
if(response && response.responseEnvelope.ack === "Success")
{
 return "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=" + response.payKey; // The url that will lead the client to the Paypal form
} 

You should most likely use something like wixLocation.to() to redirect the client to the created PayPal form, but remember you cannot call wixLocation from the backend.


I have only tested it in sandbox mode, but it is working properly. To be able to get the developer username, password, and signature you will need to have a business account in PayPal (it is free I think). From what I have read, when you want to launch the live version of the chain payment, you will have to contact Paypal support so that they can verify that your app is safe and give you an app ID to use.


Editor X

Design your boldest creations.