PayPal
Our PayPal Component renders PayPal in your payment page. When a customer selects PayPal, the Component presents a PayPal overlay, where a customer can log in with their PayPal account details to complete the payment process.
#
Before you beginThis page explains how to add PayPal to your custom payment page. If you don't need custom a checkout experience we recommend using our prebuilt payment page. It already supports all available payment methods and does not require coding.
To accept PayPal payments you need to connect your PayPal business account. To connect your PayPal business account go to MONEI Dashboard → Settings → Payment Methods.
To test your integration:
- Use your test mode Account ID and API Key.
- Connect test PayPal Business account in your MONEI Dashboard (in test mode)
- Use the test PayPal Personal account for payments.
- You can check the status of a test payment in your MONEI Dashboard → Payments (in test mode).
#
IntegrationServer-side
#
1. Create a Payment Create a Payment on your server with an amount and currency. Always decide how much to charge on the server side, a trusted environment, as opposed to the client. This prevents malicious customers from being able to choose their own prices.
- cURL
- Node.js
- PHP
The following parameters are required:
- amount
positive integer
- Amount intended to be collected by this payment. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge 1.00 USD) - currency
string
- Three-letter ISO currency code, in uppercase. Must be a supported currency. - orderId
string
- An order ID from your system. A unique identifier that can be used to reconcile the payment with your internal system. - callbackUrl
string
- The URL to which a payment result should be sent asynchronously.
Check all available request parameters.
Included in the returned Payment object is a payment id
, which is used on the client side to securely complete the payment process instead of passing the entire Payment object.
Client-side
#
2. Add PayPal to your payment page Include monei.js
on your checkout page by adding the script tag to the head
of your HTML file.
Add MONEI PayPal Component to your payment page. Create empty DOM node (container) with unique ID in your payment form.
Initialize PayPal Component
Check MONEI JS Reference for more options.
Client-side
#
3. Confirm the payment To complete the payment you need to confirm it using monei.js confirmPayment function
You need to provide a paymentId
(obtained in step 1) and paymentToken
generated with PayPal Component. You can also provide additional parameters like customer.email
. Check all available parameters.
note
As an alternative process you can submit generated paymentToken
to your sever and then confirm payment on the server-side.
#
4. An asynchronous request is sent to your server.MONEI will notify you about a payment status by sending an HTTP POST request to the callbackUrl
. The request body will contain full payment object in JSON format.
This ensures that you get the payment status even when customer closed the browser window or lost internet connection.
The request also contains a MONEI-Signature
header. Verify this signature to confirm that received request is sent from MONEI.
To acknowledge receipt of the request, your endpoint must return a 200
HTTP status code to MONEI. All other response codes, including 3xx
codes, indicate to MONEI that you did not receive the event.
If MONEI does not receive a 200
HTTP status code, the notification attempt is repeated. After multiple failures to send the notification over multiple days, MONEI marks the request as failed and stops trying to send it to your endpoint.
#
Before you go live- Make sure that you are using live (production) mode Account ID and API Key.
- Make sure that you have connected your PayPal business account in MONEI Dashboard.