Chained Payments & Rebilling (2 recipients)

Du er her:
Anslået læsetid: 3 min

Yourpay’s support payment method is where you have more than one recipient.
This functionality is commonly used by marketplaces, who is carrying a transaction for an author and is taking a cut of the transaction.

To secure both the author and the marketplace, Yourpay’s unique Chained Payments are automatically splitting the payments into two chained-payments, one for each party in the chain.

The Master (Keyholder) is always able to capture and release the full payment, where the Slave (Chained) automatically will follow the instructions of The Master.

  1. Create Payment through process_payment
  2. Capture funds through MasterID

For starters, you need to create the payments with processs payment as shown in the file: process_payment_chained.php

TIP You can open the file with notepad, if you do not have an editor for viewing source code.

If you run this file, you get a form that looks like this:

process_payment_chained_form.png

For merchant 1. you input your merchantid.

For merchant 2. you input the merchantid of the 2. Recipient.

Next, add the total amount to be captured on the customers card. NOTE: 100 = 1 EUR/DKK/SEK

Next, add the amount to split from the total amount which is sent to your 2. Recipient.

For the order ID you can add a number or a string. Whatever you need to identify the payment.

Choose the desired currency.

Input the card number of the customer.

Input expiry month.

Input expiry year.

Input CCV/CVC from the back of the customer’s credit card.

Let’s say you were making a platform selling a weekly service or product. In this case it would be a great idea to store the customers card information for later rebilling with our rebilling_customer. In this case put a 1 into the next field to get a CCRG Id in the response, this is important if you need to rebill later as this saves the customers card information on our end and allows for rebilling on that particular card. If you don’t need to rebill later just put a 0.

Now enter the name of the cardholder.

Finally enter the platform from which you are making the request.

Now if everything is entered correctly and is valid, you have a new payment for each merchant entered and you have a response, which looks which might look like this:

process_payment_chained_response.png

Now you probably want to capture those two payments and you do that, with the code in the file: capture_payment_chained.php

TIP You can open the file with notepad, if you do not have an editor for viewing source code.

If you run this you get a form, which looks like this:

capture_payment_chained_form.png

Now input the merchantid of the master.

Now in PaymentID identifier (Merchant 1) enter the ID you got from the previous response body with the key “PaymentID”

Next, enter the amount to capture from the payment. Remember 100 = 1 EUR/DKK/SEK.

Now enter the PaymentID you got from the previous response body with the key “chained”.

Next, enter the amount to be captured on merchant 2. Payment.

Finally enter the TimeID you got from the previous response body with the key “Time”

If everything is correct, you get a response body, which looks like this:

capture_payment_chained_response.png

Congratulations, you have now captured the two payments.

Rebilling Customer (2 recipients)

If you want to rebill a customer, you want to use our function rebilling_customer. To do this you need to provide the CCRG id for that particular customers credit card, along with the merchant id’s for the recipients and the amount to capture on the card and finally the amount to split from the total amount to be sent to the 2. Recipient.

The code for this is in the file

I will for convenience sake paste the top part of that file: rebilling_customer_chained.php

TIP You can open the file with notepad, if you do not have an editor for viewing source code.

rebilling_chained2_variables.PNG

merchantid should be the Yourpay merchantid of the master.

merchantid should be the 2. Recipient.

Subscription code should be the CCRG id of the customer’s card, which you have gotten from process payment or our payment window. You need to use the ID every time you want to rebill that customer, so it might be a good idea to save it.

Amount is the total amount to capture from the customer’s credit card.

Amount2 is the amount to split from the total amount to be sent to merchant 2.

orderid is the order id that will show up on the payment in our admin portal.

If everything is correct & valid, you get a response like this:

rebilling_customer_chained_response.png

Congratulations, you have successfully rebilled a customer and you are able to see the captured payment in our admin dashboard.