Payment types
You can get available payment types for your project in real time, before redirecting the user to Paysera system. It might be useful if you want to display the choice of payment methods on your website - in this case, you do not have to update configuration each time something changes.
Also, with each payment type available, minimum and maximum amounts are provided. This allows to show only those payment methods, which are relevant for a particular user.
Retrieval of payment methods is implemented in WebToPay library. Be sure that you have the last version of the library - this functionality was not yet realised in older 1.5 version.
Payment methods
Albania
Austria
Belgium
Bulgaria
Canada
Czech Republic
Germany
Denmark
Estonia
Spain
Finland
France
United Kingdom
Georgia
Greece
Croatia
Hungary
Ireland
Italy
Lithuania
Luxembourg
Latvia
Malta
Netherlands
Norway
Other countries
Poland
Portugal
Romania
Sweden
Slovenia
Slovakia
Turkey
United States
Kosovo
Payment logos for footer
Enter country to display:
Country
Albania
Austria
Belgium
Bulgaria
Canada
Czech Republic
Germany
Denmark
Estonia
Spain
Finland
France
United Kingdom
Georgia
Greece
Croatia
Hungary
Ireland
Italy
Lithuania
Luxembourg
Latvia
Malta
Netherlands
Norway
Other countries
Poland
Portugal
Romania
Sweden
Slovenia
Slovakia
Turkey
United States
Kosovo
Getting available payment types with WebToPay library
Information about payment methods is held in a special class. This allows to manipulate data more easily, and receive necessary information quicker. As minimum and maximum amounts are provided, you need to specify not only the project ID, but also the currency for payment types.
<?php $paymentMethodsInfo = WebToPay::getPaymentMethodList($projectid, $currency);
Information about payment methods is desegregated into 4 levels:
-
WebToPay_PaymentMethodList- holds all information available.WebToPay::getPaymentMethodListmethod returns an object of this class.
Class methods:-
filterForAmount($amount, $currency)returns a new instance ofWebToPay_PaymentMethodListclass with only those payment methods, which are relevant for a particular amount. -
getCountries()returns the array ofWebToPay_PaymentMethodCountryobjects. -
getCountry($countryCode)returns a singleWebToPay_PaymentMethodCountryobject. -
setDefaultLanguage($language)sets a default language for the whole tree of objects. Default language is used for getting titles and addresses of logotypes. A language can be passed to specific methods too.
-
-
WebToPay_PaymentMethodCountry- information about payment types in a country.
Class methods:-
getTitle()returns the title of the country. -
getGroups()returns the array ofWebToPay_PaymentMethodGroupobjects. -
getPaymentMethods()returns the array ofWebToPay_PaymentMethodobjects. All payment methods are taken from every group in the country. Use this method if you do not want to divide payment methods into groups.
-
-
WebToPay_PaymentMethodGroup- information about payment types for a group.
Class methods:-
getTitle()returns the title of the group. -
getPaymentMethods()returns the array ofWebToPay_PaymentMethodobjects.
-
-
WebToPay_PaymentMethod- information about the payment type.
Class methods:-
getKey()returns the identifier of this payment type. It must be passed when making a request to Paysera system. -
getTitle()returns the title of this payment type. -
getLogoUrl()returns the address of the logotype for this payment type. Returns null if the logotype is unavailable. -
isAvailableForAmount($amount, $currency)returns whether this payment method is available for the specified amount. If payment types are filtered withWebToPay_PaymentMethodList::filterForAmountmethod, there is no point in checking once again.
-
Example of how one can provide available payment types for a specific amount in Lithuania without grouping:
<?php
$paymentMethodsInfo = WebToPay::getPaymentMethodList($projectid, $currency)
->filterForAmount($amount, $currency) // leave only methods, available for this amount
->setDefaultLanguage('lt') // display titles in Lithuanian
;
foreach ($paymentMethodsInfo->getCountry('lt')->getPaymentMethods() as $paymentMethod) {
echo '<input type="radio" name="payment" value="' . $paymentMethod->getKey() . '" />';
if ($paymentMethod->getLogoUrl()) { // display logo only if available
echo '<img src="' . $paymentMethod->getLogoUrl() . '" />';
}
echo $paymentMethod->getTitle() . '<br />';
}
Example of how one can provide all possible payment types in all countries by their groups, disabling the selection of unavailable payment types:
<?php
$paymentMethodsInfo = WebToPay::getPaymentMethodList($projectid, $currency)
->setDefaultLanguage('en') // display titles in English
;
foreach ($paymentMethodsInfo->getCountries() as $country) {
echo '<h2>' . $country->getTitle() . '</h2>';
foreach ($country->getGroups() as $group) {
echo '<h3>' . $group->getTitle() . '</h3>';
foreach ($group->getPaymentMethods() as $paymentMethod) {
// display radio only if available
if ($paymentMethod->isAvailableForAmount($amount, $currency)) {
echo '<input type="radio" name="payment" value="' . $paymentMethod->getKey() . '" />';
}
// display logo only if available
if ($paymentMethod->getLogoUrl()) {
echo '<img src="' . $paymentMethod->getLogoUrl() . '" />';
}
echo $paymentMethod->getTitle() . '<br />';
}
}
}
Getting payment types without WebToPay library
If your project is not written in PHP language, you can retrieve payment types through the same interface that WebToPay library uses.
Payment types are provided in XML format at the following address:
https://www.paysera.com/payment-methods/yourProjectId/currency:desiredCurrency/amount:desiredAmount/language:desiredLanguage
Every parameter except for yourProjectId is optional. Also, you can provide only one or several parameters in any order.
-
desiredCurrency- specifies the currency, in which minimum and maximum possible amounts will be provided. If not set, amounts are provided in in euro. -
desiredAmount- only those payment methods are provided, which are available for the specified amount. Amount should be in cents. -
desiredLanguage- titles are provided only in this language. If not set, names are provided in all available languages.
For example, if you want to receive payment methods available for 10000 EUR payment, use this address (let's say that the project ID is 6028):
https://www.paysera.com/payment-methods/6028/currency:EUR/amount:1000000