Integrate Viabill Through Yourpay

Yourpay provides a full integration of Viabill for all Merchants.

This part of our integration explains how you forward the consumer to proceed towards the payment.

You can find a code example here.

TIP You can open the file with notepad, if you do not have an editor for viewing source code.
  • In $currency input the ISO-4217 ID of your desired currency. You can find a full list of currency codes here.
  • For $orderid, insert your desired ID.
  • Next input your yourpay merchantid into $merchantid.
  • $billing_first_name should contain the first name of the customer.
  • $billing_last_name should contain the last name of the customer.
  • $customer_phone should contain the phone number of the customer.
  • $customer_email should contain the email address of the customer.
  • $accepturl which as the name suggests is the URL we return the customer to when the payment is processed, normally a “thank you” page.
  • $callbackurl is the url of the IPN listener page, this is where we send all transaction related event notifications to. When customers pay for goods or services, Yourpay sends a secure FORM POST containing payment information (IPN messages) to the URL. The IPN listener page detects and processes IPN messages using the merchant backend processes. The listener page contains a script or program which waits for the messages, validates them and passes them to various backend applications for processing.

Next is

  • $urlparts[“total_products”] should contain the total amount of unique products.

Next we have the following fields for each unique product:

  • $urlparts[‘product_1_id’] : The product id
  • $urlparts[‘product_1_name’] : Name of the product
  • $urlparts[‘product_1_qty’] : Quantity of this product on order.
  • $urlparts[‘product_1_total’] : Total price
  • $urlparts[‘product_1_tax’] : Amount in tax

If you had another product then it would be product_2_id etc.

Next, we need to provide billing information, and for this, we have these fields:

$urlparts["billing_first_name"] = $billing_first_name; $urlparts["billing_last_name"] = $billing_last_name; $urlparts["billing_address_1"] = ""; $urlparts["billing_address_2"] = ""; $urlparts["billing_city"] = ""; $urlparts["billing_postcode"] = ""; // Zip code $urlparts["billing_country"] = "";

Fill in the billing information in the corresponding $urlparts.

Finally we have the last few fields to set; luckily, we have most of the values in the variables from the beginning of this.

$urlparts["accepturl"] = $accepturl; $urlparts["callbackurl"] = $callbackurl; $urlparts["version"] = 201; $urlparts["split"] = 0;
$urlparts["ShopPlatform"] = "ManualPayments"; $urlparts["CurrencyCode"] = $currency; $urlparts["time"] = time(); $urlparts["cartid"] = $orderid; $urlparts["customername"] = $billing_first_name . " " . $billing_last_name ; $urlparts["MerchantNumber"] = $merchantid; $urlparts["customer_email"] = $customer_phone; $urlparts["customer_phone"] = $customer_email; $urlparts["amount"] = $urlparts["product_1_total"] + $urlparts["product_2_total"];


Most of these should also be self-explanatory so we’ll go over the few less obvious ones.

In ‘ShopPlatform’ you input the shop used to make the order. For instance Woo commerce, Magento etc.

For ‘version’ this is if you are running a specific version, then some dependancies are activated, however 201 is a clean version so you can leave it as it is.

This is always ‘0’.

Now we are ready to call to the payment window. We do that with the following URL & append each query variable along with the value of each on the url like this:

$url = "https://payments.yourpay.se/betalingsvindue.php?method=viabill"; foreach($urlparts as $key=>$value) { $url .= "&$key=$value"; }

If everything is done right, you get to a payment window that looks like this:


The customer then provides his/her CPR number (a person identification number) and if valid is sent to this page:



In the first field the customer input his/her cellphone number. Below is the field that requires an e-mail.

Now the customer fill out the creditcard details in the fields at the bottom and accepts the terms of service on the right hand side. Now all that is left is to hit the blue “ansøg nu” button. 


If the information is valid you are sent to the accepturl you defined earlier along with the following response:

Uxtime: A unix timestamp of the moment the Callback was created.

MerchantNumber: The merchantid which the transaction is processed for.

Tchecksum: SHA1 encode of PaymentID + Integrationkey.

Checksum: SHA1 encode of PaymentID + Integrationkey.

Orderid: The order id provided.

ShopPlatform: The platform from which the order is made on.

Amount: Amount reserved on the customers credit card, in the subunit of the currency.

Split: Always 0.

Date: The date of the transaction note it’s in the format “YYYY-MM-DD”
cvc: The CVC ID of the credit card. Always empty

Expmonth: Expiration month of the credit card.

Expyear: Expiration year of the credit card.

Tcardno: Credit card number. We do not expose the entire number.

Time: PHP timestamp that indicates the time of the transaction.

Cardid: Our ID for the card type used, VISA, Mastercard etc.

Currency: The currency code for the currency used in the transaction.

NOTE: The variables related to credit card data is empty here because in this case we simply pass them to Viabill.

Congratulations you have now sucessfully completed a payment with Viabill & Yourpay.

Was this article helpful?
Dislike 0
Views: 149

Fandt du ikke svar på det du søgte?