PayPal

Learn how to accept PayPal payments.

PayPal is an online payment service that lets customers use their PayPal account to make online purchases. Customers store their credit or debit cards in their PayPal account and use that account to pay.

Payment typeDirect
MarketsGlobal
Customer currenciesMultiple
Processing currenciesMultiple
RefundYes
ChargebackYes
FraudYes
Recurring paymentsYes

General flow

POST Request -> to /payment_preauthorize
<- Response (direct, synchronous) with status=2000&errormessage=pending and redirect_url
Customer is redirected to redirect_url to complete payment
<- HTML response with status=0 (or decline) to return_url
<- Callback (asynchronous) with errorcode=0 to notification_url

Step 1. Make a transaction request

From your server, make a POST /payment_preauthorize request.

POST https://sandbox.payabl.com/pay/backoffice/payment_preauthorize

Include in request:

ParameterFormatDescription
merchantid40 charactersMerchant identification number assigned during account creation
orderidmax. 40 charactersThe field orderid is optional and exclusively for the merchants' convenience
amountdigits only, either no decimals or two decimal places (e.g. 8 or 8.50)Transaction’s total amount that will be deducted from the customer
currency3 characters. ISO 4217The currency field contains the alpha-3 currency code for the transaction. Links to ISO
payment_method117payabl. Payment methods IDs
signature40 charactersSignature Calculation
country3 charactersCustomer country in ISO 3166-2 alpha-3 format
accountname3-100 charactersCustomer account name
emailmax. 50 charactersCustomer email. An RFC 822 compliant email address
firstnamemax. 50 charactersFirst name of the customer
lastnamemax. 50 charactersLast name of the customer
url_successmax. 255 characters starting with http or httpsSuccessful transaction redirection URL
url_failedmax. 255 characters starting with http or httpsFailed transaction redirection URL
url_returnmax. 255 characters starting with http or httpsURL for customer redirection

You can see a full list of parameters in Pre-Authorization.

Request example:

merchantid=gateway_test&orderid=Payabl-Test&amount=19.99&currency=EUR&payment_method=117&language=en&[email protected]&
firstname=John&lastname=Doe&zip=3035&street=Olympion&house=23&city=Limassol&country=CYP&url_return=https://yourshop.example/thank_you&
notification_url=https://yourshop.example/notification&url_success=https://yourshop.example/payment_successful&url_failed=
https://yourshop.example/payment_failed&customerip=2.22.75.244&accountname=John Doe&signature=d62173e2128012e001ba79bf5791befbc4b7724e

🚧

Public Sandbox information

Do not use your personal email address, Order ID with sensitive information, real customer details and credit card data in the public Sandbox. For email field you may use [email protected].

📘

Redirection to url_return does not confirm that the transaction is successful. Always check the transaction via notification_url or use the diagnose interface to get the final status of the transaction.

Step 2. Handle the redirect

To complete the payment, you need to redirect the customer to the correct URL in the response.

Response example:

transactionid=104576808&transid=104576808&status=2000&errormessage=pending&errmsg=pending&amount=19.99&price=19.99&currency=EUR&
orderid=Payabl-Test&payment_method=117&redirect_url=https%3A%2F%2Fwww.sandbox.paypal.com%2Fcheckoutnow%3Ftoken%3D06R6274230402884S&user_id=504459

Response fields reference:

ParameterDescription
transactionidpayabl. internal transaction id. Please use this transaction id when referring to the transaction in communications with the payabl. team
transidThe same as transactionid
statusTransaction error code
errormessageBrief explanation of transaction decline reason (empty on success)
errmsgThe same as errormessage
amountTransaction amount
priceThe same as amount
currencyTransaction currency
payment_methodPayment method ID
orderidOptional transaction identifier given by the merchant
redirect_urlURL for customer redirection to finalize the payment (URL encoded)
user_idPayment system user identifier

Step 3. Receive the final status

After the customer finishes or cancels the payment, he will be redirected back to url_return, provided by you in the initial request to payment_preauthorize. After that, you will receive a notification, posted to notification_url, with the final transaction status, which you are supposed to use to update your system.

📘

url_return and notification_url should be passed by you in the Pre-authorization request.

Alternatively, you can communicate the notification_url to be used by default to payabl. technical team. By doing so, you won't need to send it in every request.

Notification example:

security=5aca2c2a1267c23565aec6d6891006f726ad0a4b9d0f4ba797c091d5ee1b9f35&errorcode=0&timestamp=1680525177&transactionid=104576808&
type=order&errormessage=&orderid=Payabl-Test

Notification fields reference:

ParameterDescription
transactionidpayabl. internal transaction id. Please use this transaction id when referring to the transaction in communications with the payabl. team
typeTransaction type
errorcodeTransaction error code (0 for success)
errormessageBrief explanation of transaction decline reason (empty on success)
orderidOptional transaction identifier given by the merchant
securitySignature to verify the authenticity of the notification. You can find more information here
timestampNotification timestamp

Recurring payments (Billing agreement)

PayPal integration support billing agreements for recurring payments. To use recurring payments with PayPal the customer first needs to confirm the billing agreement with you and after you can start to utilize recurring payments.

Initial transaction

The first step is to initiate the first transaction so that the customer could approve the billing agreement.
From your server, make a POST /payment_preauthorize request.

https://sandbox.payabl.com/pay/backoffice/payment_preauthorize

Include in request:

ParameterFormatDescription
merchantid40 charactersMerchant identification number assigned during account creation
orderidmax. 30 charactersThe field orderid is optional and exclusively for the merchants' convenience
amountdigits only, either no decimals or two decimal places (e.g. 8 or 8.50)Transaction’s total amount that will be deducted from the customer
currency3 characters. ISO 4217The currency field contains the alpha-3 currency code for the transaction. Links to ISO
payment_method117payabl. Payment methods IDs
signature40 charactersSignature Calculation2
country3 charactersCustomer country in ISO 3166-2 alpha-3 format
accountname3-100 charactersCustomer account name
emailmax. 50 charactersCustomer email. An RFC 822 compliant email address
firstnamemax. 50 charactersFirst name of the customer
lastnamemax. 50 charactersLast name of the customer
url_returnmax. 255 characters starting with http or httpsURL for customer redirection
recurring_idINITClassify the first recurring transaction with INIT.

📘

Please note that order ID must be unique for PayPal billing agreement transactions, otherwise they will be declined.

Request example:

merchantid=gateway_test&orderid=Payabl-Test&amount=19.99&currency=EUR&payment_method=117&language=en&[email protected]&firstname=John&
lastname=Doe&zip=3035&street=Olympion&house=23&city=Limassol&country=CYP&customerip=2.22.75.244&accountname=John Doe&
url_return=https://yourshop.example/thank_you&notification_url=https://yourshop.example/notification&url_success=
https://yourshop.example/payment_successful&url_failed=https://yourshop.example/payment_failed&recurring_id=INIT&signature=42d899267ab0478bbf9ae148b60987d56ccffa12

Response will contain a redirect_url to PayPal

Response example:

transactionid=105108236&transid=105108236&status=2000&errormessage=pending&errmsg=pending&amount=0&price=0&currency=EUR&
orderid=Payabl-Test&redirect_url=https%3A%2F%2Fwww.sandbox.paypal.com%2Fagreements%2Fapprove%3Fba_token%3DBA-0B4764702F8639649&user_id=504459

After the customer redirects to the PayPal payment page, they need to login into their account and confirm the billing agreement. The customer confirms the billing agreement and the initial transaction will have the status ACTIVE.

Response for recurring initiation will contain type = Order, Error code =145006 and Error message =Billing Agreement has been activated.

❗️

There will be no Capture type for recurring initiation for PayPal. Successful Authorization (error code = 145006) is the final successful result for activated subscription.

Notification example:

security=b23a9680dbce751785d650346576cb3c1575c95f9cd56144478141df3714915d&errorcode=145006&timestamp=1680525177&transactionid=105108236&type=order&errormessage=Billing+Agreement+has+been+activated&orderid=Payabl-Test

Subsequent recurring request

To initiate subsequent recurring transactions, you need to send POST /payment_authorize request.

https://sandbox.payabl.com/pay/backoffice/payment_authorize

Include in request:

ParameterFormatDescription
merchantid40 charactersMerchant identification number assigned during account creation
orderidmax. 30 charactersThe field orderid is optional and exclusively for the merchants' convenience
amountdigits only, either no decimals or two decimal places (e.g. 8 or 8.50)Transaction’s total amount that will be deducted from the customer
currency3 characters. ISO 4217The currency field contains the alpha-3 currency code for the transaction. Links to ISO
payment_method117payabl. Payment methods IDs
signature40 charactersSignature Calculation2
country3 charactersCustomer country in ISO 3166-2 alpha-3 format
accountname3-100 charactersCustomer account name
emailmax. 50 charactersCustomer email. An RFC 822 compliant email address
firstnamemax. 50 charactersFirst name of the customer
lastnamemax. 50 charactersLast name of the customer
url_returnmax. 255 characters starting with http or httpsURL for customer redirection
recurring_id9 digitsTransaction ID of the INIT recurring transaction

Request example:

merchantid=gateway_test&orderid=Payabl-Test2&amount=19.99&currency=EUR&payment_method=117&language=en&[email protected]&firstname=John&
lastname=Doe&zip=3035&street=Olympion&house=23&city=Limassol&country=CYP&customerip=2.22.75.244&accountname=John Doe&url_return=https://yourshop.
example/thank_you&notification_url=https://yourshop.example/notification&url_success=https://yourshop.example/payment_successful&
url_failed=https://yourshop.example/payment_failed&recurring_id=105108236&signature=8930b63712247a7d5bbda601029ee21568e95af8

Response example:

transactionid=105108251&transid=105108251&status=0&errormessage=&errmsg=&amount=19.99&price=19.99&currency=EUR&
orderid=Payabl-Test2&user_id=504459

Recurring cancellation

The customer is allowed to cancel the billing agreement at any time through PayPal application or web portal. In case the billing agreement was canceled by the customer, you will receive a notification.

Response example

transactionid=105108257&errorcode=145005&security=6265c72ed0317bbf105022c60ba1f5d92aa2f808d6eaa5b207148f6c98eb2214&
type=order&orderid=Payabl-Test&errormessage=A+billing+agreement+with+description+"Reference+Transaction+Sample"+has+
been+canceled+by+the+buyer&timestamp=1662384778" 

If you did request when the billing agreement was canceled, you will receive the following notification:

Response example

transactionid=105108297&transid=105108297&status=145001&errormessage=Billing%20Agreement%20not%20active&
errmsg=Billing%20Agreement%20not%20active&amount=19.99&price=19.99&currency=EUR&orderid=Payabl-Test&
payment_method=117&user_id=264604&error_codes=145001&error_messages=Billing%20Agreement%20not%20active

Refunds

PayPal supports refunds and can be initiated only on a successful captured transaction.
The request will send a credit note to the authorization system after the customer has already been charged. The refund amount will be credited to the customer, and the merchant’s account will be charged.

The refund can be done in two ways:

  • Through API integration
  • Through payabl. dashboard

If you have API integration, you can check more in our documentation Refund.


Our Technical Support team is there to help you:
Email: [email protected]
Available Monday – Friday between 09:00 and 17:00 CET/CEST