Abandoned, use https://github.com/worldstream-labs/omnipay-paysafe-payment-hub instead
The NETELLER PHP Library provides PHP developers an easy way to integrate the NETELLER REST API. It is a client library which provides PHP classes that correspond to resources in the NETELLER REST API.
- Installation
- Configuration
- NetellerAPI Class
- RequestPayment Class
- CreatePayment Class
- LookupPayment Class
- CreateOrder Class
- LookupOrder Class
- LookupOrderInvoice Class
- CreateCustomer Class
- LookupCustomer Class
- CreatePlan Class
- LookupPlan Class
- CancelPlan Class
- DeletePlan Class
- ListPlans Class
- CreateSubscription Class
- LookupSubscription Class
- CancelSubscription Class
- ListSubscriptions Class
- LookupSubscriptionInvoice Class
- LookupAllSubscriptionInvoices Class
- WebhookHandler Class
Simply download and include the "NetellerAPI.php" file in your script.
include_once("NetellerAPI.php");
You need to define the configuration details using the following PHP constants:
- NETELLER_BASE_URL - should contain the relevant REST API endpoint depending on whether you are using the sandbox or live environment.
- NETELLER_CLIENT_ID - should contain the Client ID from the merchant account App.
- NETELLER_CLIENT_SECRET - should contain the Client Secret from the merchant account App.
Example:
define('NETELLER_BASE_URL', 'https://test.api.neteller.com/');
define('NETELLER_CLIENT_ID', 'AAABTAiQ9pKruN2Z');
define('NETELLER_CLIENT_SECRET', '0.iSLQ7zzMinac6SbI62onxTdqEYFES1LXoI4paRFFz74.4yFz4Pr3BMIccXgQOb3Ea_FNG2Y');
Alternatively, you may pass these required parameters to the constructor of each method instead:
$deposit = new NetellerAPI\RequestPayment(array(
'NETELLER_BASE_URL' => 'https://test.api.neteller.com/',
'NETELLER_CLIENT_ID' => 'AAABTAiQ9pKruN2Z',
'NETELLER_CLIENT_SECRET' => '0.iSLQ7zzMinac6SbI62onxTdqEYFES1LXoI4paRFFz74.4yFz4Pr3BMIccXgQOb3Ea_FNG2Y'
));
.. etc etc
A parent class which all classes below extend.
- getIP() - Returns the outgoing IP address of the server where the script is hosted using an external service. Useful for debugging the "invalid_client" API error.
- getUrl(string $url) - Executes a GET request to a URL from the NETELLER API and returns the result. Useful when implementing webhooks.
- getToken_ClientCredentials() - Returns a new access token - "client_credentials" grant type.
- getToken_AuthCode(string $authCode, string $redirectUri) - Returns a new access token - "auth_code" grant type.
- getToken_RefreshToken(string $refreshToken) - Returns a new access token using a refresh token.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$api = new NetellerAPI\NetellerAPI();
$ip = $api->getIP();
var_dump($ip);
It can also be used in the context of a child class:
$deposit = new NetellerAPI\RequestPayment();
$deposit->setPaymentMethodValue('[email protected]')
->setVerificationCode(270955)
->setTransactionMerchantRefId('adfiu1i23478172349a')
->setTransactionAmount(1234)
->setTransactionCurrency('USD');
$result = $deposit->doRequest();
$ip = $deposit->getIP();
var_dump($result);
var_dump($ip);
Creates a new incoming transfer payment.
- setPaymentMethodValue(string $paymentMethod) - Sets the member's email or 12 digit NETELLER Account ID.
- setVerificationCode(string $verificationCode) - Sets the member's Secure ID or Google Authenticator OTP.
- setTransactionMerchantRefId(string $merchantRefId) - Sets the merchant reference ID.
- setTransactionAmount(int $transactionAmount) - Sets the amount for the transaction.
- setTransactionCurrency(string $transactionCurrency) - Sets the currency for the transaction.
- setExpand(string $expandObjects) - A list of comma-separated names of objects to be expanded in the NETELLER REST API response.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$deposit = new NetellerAPI\RequestPayment();
$deposit->setPaymentMethodValue('[email protected]')
->setVerificationCode(270955)
->setTransactionMerchantRefId('adfiu1i23478172349a')
->setTransactionAmount(1234)
->setTransactionCurrency('USD');
$result = $deposit->doRequest();
var_dump($result);
Creates a new outgoing payment.
- setPayeeProfileEmail(string $payeeProfileEmail) - Sets the email of the member receiving the payment.
- setTransactionAmount(int $transactionAmount) - Sets the amount for the transaction.
- setTransactionCurrency(string $transactionCurrency) - Sets the currency for the transaction.
- setTransactionMerchantRefId(string $transactionMerchantRefId) - Sets the merchant reference ID.
- setMessage(string $message) - Sets the message that will be shown to the member notifying them of the pending transfer.
- setExpand(string $expandObjects) - A list of comma-separated names of objects to be expanded in the NETELLER REST API response.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$withdrawal = new NetellerAPI\CreatePayment();
$withdrawal->setPayeeProfileEmail('[email protected]')
->setTransactionAmount(1234)
->setTransactionCurrency('USD')
->setTransactionMerchantRefId('adfiu1i23478172349W2')
->setMessage('sample message');
$result = $withdrawal->doRequest();
var_dump($result);
Returns details about a previous payment request.
- setTransactionId(string $transactionId) - Sets the NETELLER transaction ID of the transaction you want to look up. You can either use this method or use "setMerchantRefId".
- setMerchantRefId(string $merchantRefId) - Sets the merchant reference ID of the transaction you want to look up. You can either use this method or use "setTransactionId".
- setExpand(string $expandObjects) - A list of comma-separated names of objects to be expanded in the NETELLER REST API response.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$lookup = new NetellerAPI\LookupPayment();
$lookup->setTransactionId('850430740226289')
->setExpand('customer');
$result = $lookup->doRequest();
var_dump($result);
Creates a payment order for NETELLERgo! You will need to redirect your customer to the returned URL to initiate the hosted Quick Checkout flow and collect the payment.
- setOrderMerchantRefId(string $orderMerchantRefId) - Sets the merchant reference ID.
- setOrderTotalAmount(int $orderTotalAmount) - Sets the total amount for the order.
- setOrderCurrency(string $orderCurrency) - Sets the currency for the order.
- setOrderLang(string $orderLang) - Sets the language of the hosted payment page.
- setOrderCustomerIp(string $orderCustomerIp) - Sets the IP address of the customer.
- setItems(array $item) - Sets the item you are requesting payment for.
- setFees(array $fee) - Sets the fee for this order.
- setTaxes(array $tax) - Sets the tax for this order.
- setPaymentMethods(array $paymentMethod) - sets the allowed payment methods for this order.
- setRedirectOnSuccess(string $url) - Sets the success redirect URL.
- setRedirectOnCancel(string $url) - Sets the cancel redirect URL.
- setBillingDetailsEmail(string $billingDetailsEmail) - Sets the email address of the customer.
- setBillingDetailsCountry(string $billingDetailsCountry) - Sets the country of residence of the customer (ISO 3166-1 Alpha 2-code)
- setBillingDetailsFirstName(string $billingDetailsFirstName) - Sets the First Name of the customer.
- setBillingDetailsLastName(string $billingDetailsLastName) - Sets the Last Name of the customer.
- setBillingDetailsCity(string $billingDetailsCity) - Sets the city of residence of the customer.
- setBillingDetailsAddress1(string $billingDetailsAddress1) - Sets the address (line 1) of the customer.
- setBillingDetailsAddress2(string $billingDetailsAddress2) - Sets the address (line 2) of the customer.
- setBillingDetailsAddress3(string $billingDetailsAddress3) - Sets the address (line 3) of the customer.
- setBillingDetailsCountrySubDivisionCode(string $countrySubDivisionCode) - Sets the country subdivision code of the customer. The ISO 3166-2 code indicating the state/province/district or other value denoting the clients country subdivision
- setBillingDetailsPostCode(string $billingDetailsPostCode) - Sets the post code of the customer.
- setBillingDetailsLang(string $billingDetailsLang) - Sets the preferred language of communication of the customer.
- setAttributes(array $attribute) - Sets additional attributes for this order.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getOrderId() - Returns the NETELLER order id or null (in case doRequest() not called yet, or error occurred)
- getRedirectUrl() - Returns the URL where the client needs to be redirected to complete the payment.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$order = new NetellerAPI\CreateOrder();
$order->setOrderMerchantRefId('adfiu1i23478172349o1')
->setOrderTotalAmount(2099)
->setOrderCurrency('USD')
->setOrderLang('en_US')
->setItems(array
(
"quantity" => 1,
"name" => "Item A",
"description" => "Lorem ipsum dolor sit amet",
"sku" => "XYZPART1",
"amount" => 1000
)
)
->setItems(array
(
"quantity" => 2,
"name" => "Item B",
"description" => "Consectetur adipiscing elit",
"sku" => "XYZPART2",
"amount" => 200
)
)
->setFees(array
(
"feeName" => "Setup Fee",
"feeAmount" => 500
)
)
->setTaxes(array
(
"taxName" => "VAT",
"taxAmount" => 199
)
)
->setPaymentMethods(array
(
"type" => "onlinebanking",
"value" => "sofortbanking"
)
)
->setRedirectOnSuccess("https://example.com/success.html")
->setRedirectOnCancel("https://example.com/cancel.html")
->setBillingDetailsEmail("[email protected]")
->setBillingDetailsCountry("DE")
->setBillingDetailsFirstName("John")
->setBillingDetailsLastName("Smith")
->setBillingDetailsCity("Calgary")
->setBillingDetailsAddress1("address line 1")
->setBillingDetailsAddress2("address line 2")
->setBillingDetailsAddress3("address line 3")
->setBillingDetailsCountrySubDivisionCode("AB")
->setBillingDetailsPostCode("T8A22J")
->setBillingDetailsLang("en");
$result = $order->doRequest();
$redirectUrl = $order->getRedirectUrl();
var_dump($result);
var_dump($redirectUrl);
Returns details about a previous order request.
- setOrderId(string $orderId) - Sets the order ID.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$lookup = new NetellerAPI\LookupOrder();
$lookup->setOrderId("ORD_1f21ca9d-e647-46bc-9dde-91c70632e587");
$result = $lookup->doRequest();
var_dump($result);
Returns details about an invoice for an order.
- setOrderId(string $orderId) - Sets the order ID.
- setExpand(string $expandObjects) - A list of comma-separated names of objects to be expanded in the NETELLER REST API response.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$lookup = new NetellerAPI\LookupOrderInvoice();
$lookup->setOrderId("ORD_5c0023d3-c928-4771-9016-1fc169283b0f")
->setExpand("customer,order");
$result = $lookup->doRequest();
var_dump($result);
Pre-populate the NETELLER sign-up page with information from your database, so you can speed up the registration process.
- setEmail(string $email) - Sets the email of the customer.
- setFirstName(string $firstName) - Sets the first name of the customer.
- setLastName(string $lastName) - Sets the last name of the customer.
- setAddress1(string $address1) - Sets the address line 1 of the customer.
- setAddress2(string $address2) - Sets the address line 2 of the customer.
- setAddress3(string $address3) - Sets the address line 3 of the customer.
- setCity(string $city) - Sets the city of the customer.
- setCountry(string $country) - Sets the country of the customer. ISO 3166-1 Alpha 2-code.
- setCountrySubDivisionCode(string $countrySubDivisionCode) - Sets the state/province of the customer. ISO 3166-2 code.
- setPostCode(string $postCode) - Sets the post code of the customer.
- setGender(string $gender) - Sets the gender of the customer.
- setDobDay(string $dobDay) - Sets the date of birth day of the customer.
- setDobMonth(string $dobMonth) - Sets the date of birth month of the customer.
- setDobYear(string $dobYear) - Sets the date of birth year of the customer.
- setLanguage(string $language) - Sets the preferred language of the customer.
- setCurrency(string $currency) - Sets the preferred currency of the customer.
- setMobile(string $mobile) - Sets the mobile phone of the customer.
- setLandLine(string $landLine) - Sets the land line phone of the customer.
- setBtag(string $btag) - sets the btag, used for affiliate tracking.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getRedirectUrl() - Returns the URL where the client needs to be redirected to complete the sign-up.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$signup = new NetellerAPI\CreateCustomer();
$signup->setEmail("[email protected]")
->setFirstName("John")
->setLastName("Smith")
->setAddress1("address line 1")
->setAddress2("address line 2")
->setAddress3("address line 3")
->setCity("Calgary")
->setCountry("CA")
->setCountrySubDivisionCode("AB")
->setPostCode("T8A22J")
->setGender("m")
->setDobDay("31")
->setDobMonth("01")
->setDobYear("1975")
->setLanguage("en_US")
->setCurrency("EUR")
->setMobile("14035552333")
->setLandLine("14032332333")
->setLinkBackUrl("https://example.com/")
->setBtag("A_234B_345C_");
$response = $signup->doRequest();
$redirectUrl = $signup->getRedirectUrl();
var_dump($response);
var_dump($redirectUrl);
Lookup details for a specific customer.
- setAccountId(string $accountId) - Sets the account ID of the customer. You can either use this method or "setCustomerId" and "setEmail".
- setCustomerId(string $customerId) - Sets the customer ID of the customer. You can either use this method or "setAccountId" and "setEmail".
- setEmail(string $email) - Sets the email of the customer. You can either use this method or "setAccountId" and "setCustomerId".
- setRefreshToken(string $refreshToken) - Sets the refresh token to be used in order to obtain an access token. You can either use this method or use "setAuthCode". This method is used only when you want to receive customer data outside of the default scope.
- setAuthCode(string $authCode) - Sets the authentication code to be used in order to obtain an access token. You can either use this method or use "setRefreshToken". This method is used only when you want to receive customer data outside of the default scope.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$lookup = new NetellerAPI\LookupCustomer();
$lookup->setCustomerId("453523712313")
->setRefreshToken("0.AgAAAU0yy4sHAAAAB1jwsOC9J7TBAYynTble-g2fdC-d.7xIAyXxQWsDaiLzjY4qimsqfyYU");
$result = $lookup->doRequest();
var_dump($result);
Creates a subscription plan.
- setPlanId(string $planId) - Sets the unique ID for the plan.
- setPlanName(string $planName) - Sets the name of the plan.
- setInterval(int $interval) - Sets the number of intervals between each billing attempt.
- setIntervalType(string $intervalType) - Sets the frequency at which the plan subscriber will be billed (daily, weekly, monthly, yearly).
- setIntervalCount(int $intervalCount) - Sets the length of the contract in intervals.
- setAmount(int $amount) - Sets the amount to bill for each recurring payment.
- setCurrency(string $currency) - Sets the currency in which the customer will be billed.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$plan = new NetellerAPI\CreatePlan();
$plan->setPlanId("MONTHLYGREENPLAN")
->setPlanName("Sample Premier Monthly Membership")
->setInterval(3)
->setIntervalType("monthly")
->setIntervalCount(4)
->setAmount(2995)
->setCurrency("USD");
$result = $plan->doRequest();
var_dump($result);
Returns details about a previously created subscription plan.
- setPlanId(string $planId) - Sets the plan ID.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$lookup = new NetellerAPI\LookupPlan();
$lookup->setPlanId("MONTHLYGREENPLAN");
$result = $lookup->doRequest();
var_dump($result);
Cancels a previously created subscription plan.
- setPlanId(string $planId) - Sets the plan ID.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$plan = new NetellerAPI\CancelPlan();
$plan->setPlanId("MONTHLYGREENPLAN");
$result = $plan->doRequest();
var_dump($result);
Deletes a previously created subscription plan.
- setPlanId(string $planId) - Sets the plan ID.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$plan = new NetellerAPI\DeletePlan();
$plan->setPlanId("MONTHLYGREENPLAN");
$result = $plan->doRequest();
var_dump($result);
Returns a list of all plans.
- setLimit(int $limit) - Sets the number of records to be returned.
- setOffset(int $offset) - Sets the results offset.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$plans = new NetellerAPI\ListPlans();
$plans->setLimit(10)
->setOffset(0);
$result = $plans->doRequest();
var_dump($result);
Enrolls an existing NETELLER account holder in one of your subscription plans.
- setPlanId(string $planId) - Sets the plan ID.
- setCustomerId(string $customerId) - Sets the Customer ID of the customer to be subscribed.
- setStartDate(string $startDate) - Sets the start date for the subscription. The date needs to be in ISO 8601 format (UTC).
- setRefreshToken(string $refreshToken) - Sets the refresh token to be used in order to obtain an access token. You can either use this method or use "setAuthCode".
- setAuthCode(string $authCode) - Sets the authentication code to be used in order to obtain an access token. You can either use this method or use "setRefreshToken".
- setRedirectUri(string $redirectUri) - Sets the redirect URI.
- setExpand(string $expandObjects) - A list of comma-separated names of objects to be expanded in the NETELLER REST API response.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$subscription = new NetellerAPI\CreateSubscription();
$subscription->setPlanId("MONTHLYGREENPLAN")
->setAccountProfileEmail("[email protected]")
->setStartDate("2015-05-09T00:00:00Z")
->setAuthCode("0.AAAAAU0yjMR5AAAAAAAEk-B1A0yk5HA7RZkwz9zQYRFN.eNw8W12CqB06b2Qc2rvr3vUyc-g")
->setRedirectUri("https://example.com/")
->setExpand("plan,customer");
$result = $subscription->doRequest();
var_dump($result);
$subscription = new NetellerAPI\CreateSubscription();
$subscription->setPlanId("MONTHLYGREENPLAN")
->setAccountProfileEmail("[email protected]")
->setStartDate("2015-05-09T00:00:00Z")
->setRefreshToken("0.AgAAAU0yy4sHAAAAB1jwsOC9J7TBAYynTble-g2fdC-d.7xIAyXxQWsDaiLzjY4qimsqfyYU")
->setRedirectUri("https://example.com/")
->setExpand("plan,customer");
$result = $subscription->doRequest();
var_dump($result);
Returns details about a previously created subscription.
- setSubscriptionId(string $subscriptionId) - Sets the subscription ID.
- setExpand(string $expandObjects) - A list of comma-separated names of objects to be expanded in the NETELLER REST API response.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$lookup = new NetellerAPI\LookupSubscription();
$lookup->setSubscriptionId("180")
->setExpand("plan,customer");
$result = $lookup->doRequest();
var_dump($result);
Cancels a previously created subscription.
- setSubscriptionId(string $subscriptionId) - Sets the subscription ID.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$subscription = new NetellerAPI\CancelSubscription();
$subscription->setSubscriptionId("181");
$result = $subscription->doRequest();
var_dump($result);
Lists all previously created subscriptions.
- setLimit(int $limit) - Sets the number of records to be returned.
- setOffset(int $offset) - Sets the results offset.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$subscriptions = new NetellerAPI\ListSubscriptions();
$subscriptions->setLimit(10)
->setOffset(0);
$result = $subscriptions->doRequest();
var_dump($result);
Looks up a subscription invoice.
- setSubscriptionId(string $subscriptionId) - Sets the subscription ID.
- setInvoiceNumber(int $invoiceNumber) - Sets the invoice number.
- setExpand(string $expandObjects) - A list of comma-separated names of objects to be expanded in the NETELLER REST API response.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$lookup = new NetellerAPI\LookupSubscriptionInvoice();
$lookup->setSubscriptionId(166)
->setInvoiceNumber(42)
->setExpand("customer, subscription");
$result = $lookup->doRequest();
var_dump($result);
Looks up all subscription invoices.
- setSubscriptionId(string $subscriptionId) - Sets the subscription ID.
- setLimit(int $limit) - Sets the number of records to be returned.
- setOffset(int $offset) - Sets the results offset.
- doRequest() - Executes the API request. Returns the JSON-decoded object of the NETELLER REST API response, or "(bool)false" if an error has occurred.
- getExecutionErrors() - Returns an array with the error(s) returned by the NETELLER REST API.
$lookup = new NetellerAPI\LookupAllSubscriptionInvoices();
$lookup->setSubscriptionId(166)
->setLimit(10)
->setOffset(0);
$result = $lookup->doRequest();
var_dump($result);
Handles incoming webhook requests.
- handleRequest() - Receives the webhook request and calls a callback function passing through the webhook data. You need to give the callback function(s) the same name as the webhook(s) you are subscribed to. Please refer to the REST API Guide for a list of all webhook names.
$webhook = new NetellerAPI\WebhookHandler();
$webhook->handleRequest();
function payment_succeeded($data){
$api = new NetellerAPI\NetellerAPI();
$result = $api->getUrl($data->links[0]->url);
//do something with the response here
}