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 type | Direct |
Markets | Global |
Customer currencies | Multiple |
Processing currencies | Multiple |
Refund | Yes |
Chargeback | Yes |
Fraud | Yes |
Recurring payments | Yes |
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:
Parameter | Format | Description |
---|---|---|
merchantid | 40 characters | Merchant identification number assigned during account creation |
orderid | max. 40 characters | The field orderid is optional and exclusively for the merchants' convenience |
amount | digits 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 |
currency | 3 characters. ISO 4217 | The currency field contains the alpha-3 currency code for the transaction. Links to ISO |
payment_method | 117 | payabl. Payment methods IDs |
signature | 40 characters | Signature Calculation |
country | 3 characters | Customer country in ISO 3166-2 alpha-3 format |
accountname | 3-100 characters | Customer account name |
email | max. 50 characters | Customer email. An RFC 822 compliant email address |
firstname | max. 50 characters | First name of the customer |
lastname | max. 50 characters | Last name of the customer |
url_success | max. 255 characters starting with http or https | Successful transaction redirection URL |
url_failed | max. 255 characters starting with http or https | Failed transaction redirection URL |
url_return | max. 255 characters starting with http or https | URL 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¤cy=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 vianotification_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¤cy=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:
Parameter | Description |
---|---|
transactionid | payabl. internal transaction id. Please use this transaction id when referring to the transaction in communications with the payabl. team |
transid | The same as transactionid |
status | Transaction error code |
errormessage | Brief explanation of transaction decline reason (empty on success) |
errmsg | The same as errormessage |
amount | Transaction amount |
price | The same as amount |
currency | Transaction currency |
payment_method | Payment method ID |
orderid | Optional transaction identifier given by the merchant |
redirect_url | URL for customer redirection to finalize the payment (URL encoded) |
user_id | Payment 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
andnotification_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×tamp=1680525177&transactionid=104576808&
type=order&errormessage=&orderid=Payabl-Test
Notification fields reference:
Parameter | Description |
---|---|
transactionid | payabl. internal transaction id. Please use this transaction id when referring to the transaction in communications with the payabl. team |
type | Transaction type |
errorcode | Transaction error code (0 for success) |
errormessage | Brief explanation of transaction decline reason (empty on success) |
orderid | Optional transaction identifier given by the merchant |
security | Signature to verify the authenticity of the notification. You can find more information here |
timestamp | Notification 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:
Parameter | Format | Description |
---|---|---|
merchantid | 40 characters | Merchant identification number assigned during account creation |
orderid | max. 30 characters | The field orderid is optional and exclusively for the merchants' convenience |
amount | digits 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 |
currency | 3 characters. ISO 4217 | The currency field contains the alpha-3 currency code for the transaction. Links to ISO |
payment_method | 117 | payabl. Payment methods IDs |
signature | 40 characters | Signature Calculation2 |
country | 3 characters | Customer country in ISO 3166-2 alpha-3 format |
accountname | 3-100 characters | Customer account name |
email | max. 50 characters | Customer email. An RFC 822 compliant email address |
firstname | max. 50 characters | First name of the customer |
lastname | max. 50 characters | Last name of the customer |
url_return | max. 255 characters starting with http or https | URL for customer redirection |
recurring_id | INIT | Classify 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¤cy=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¬ification_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¤cy=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×tamp=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:
Parameter | Format | Description |
---|---|---|
merchantid | 40 characters | Merchant identification number assigned during account creation |
orderid | max. 30 characters | The field orderid is optional and exclusively for the merchants' convenience |
amount | digits 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 |
currency | 3 characters. ISO 4217 | The currency field contains the alpha-3 currency code for the transaction. Links to ISO |
payment_method | 117 | payabl. Payment methods IDs |
signature | 40 characters | Signature Calculation2 |
country | 3 characters | Customer country in ISO 3166-2 alpha-3 format |
accountname | 3-100 characters | Customer account name |
email | max. 50 characters | Customer email. An RFC 822 compliant email address |
firstname | max. 50 characters | First name of the customer |
lastname | max. 50 characters | Last name of the customer |
url_return | max. 255 characters starting with http or https | URL for customer redirection |
recurring_id | 9 digits | Transaction ID of the INIT recurring transaction |
Request example:
merchantid=gateway_test&orderid=Payabl-Test2&amount=19.99¤cy=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¬ification_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¤cy=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×tamp=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¤cy=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
Updated about 1 year ago