Download the PHP package kreative/f3-pypl without Composer
On this page you can find all versions of the php package kreative/f3-pypl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kreative/f3-pypl
More information about kreative/f3-pypl
Files in kreative/f3-pypl
Package f3-pypl
Short Description PayPal Express Checkout integration for the PHP Fat-Free Framework
License GPL-3.0
Homepage https://github.com/kreative/f3-pypl
Informations about the package f3-pypl
F3-PYPL 
F3-PYPL is a Fat Free Framework plugin that helps quickly implement PayPal Express Checkout via the PayPal Classic API.
Express Checkout Shortcut & Mark Demo
Please use a sandbox account to make payments.
Quick Start Config
Add the following custom section to your project config.
- user - Your PayPal API Username
- pass - Your PayPal API Password
- signature - Your PayPal API Signature
- endpoint - API Endpoint, values can be 'sandbox' or 'production'
- apiver - API Version current release is 204.0
- return - The URL that PayPal redirects your buyers to after they have logged in and clicked Continue or Pay
- cancel - The URL that PayPal redirects the buyer to when they click the cancel & return link
- log - logs all API requests & responses to paypal.log
If you prefer you can also pass an array with above values when you instantiate the classes.
Manual Install
Copy the lib/paypal.php
file into your lib/
or your AUTOLOAD folder.
or
Automatic Install via Composer
Quick Start
PayPal Express Checkout
Create a route that will initialize the transaction (SetExpressCheckout API) & redirect the buyer to PayPal.
Once the buyer is returned to your website you can simply complete the transaction (DoExpressCheckoutPayment API) by
$result will contain an associative array of the API response. Store the useful bits like status & transaction ID.
PayPal Pro
$result will contain an associative array of the API response. Store the useful bits like status & transaction ID.
Methods
Setting a Shipping Address
The setShippingAddress() method allows you to pass the shipping address to PayPal before creating the transaction. The address will appear when the buyer logs into PayPal or will be used to populate the address form fields on the Guest Checkout. This address is also used in the DoExpressCheckoutPayment API call so it will appear on the payment receipt & transaction history.
Passing Cart Line Items
The setLineItem() method allows you to pass multiple shopping cart line items to PayPal. This will appear on the order summary when the buyer is redirected to PayPal and is also used in the DoExpressCheckoutPayment API so a detailed breakdown of the order is available on the PayPal receipts & transaction history.
Passing Cart Line Items from Basket
The copyBasket() method allows you to transfer the F3 Basket line items to PayPal and returns a subtotal. If not specified quantity will default to 1.
Setting the Shipping Amount
The setShippingAmt() method allows you to specify an overall shipping amount.
Setting the Tax Amount
The setTaxAmt() method allows you to specify an overall tax amount.
Creating a transaction
The create() method will setup the transaction using the SetExpressCheckout API call. If successful a unique token is returned that identifies your newly created transaction. The buyer should then be redirected to PayPal with the EC-Token appended to the URL where they will be prompted to login or checkout as a guest.
Retrieving details from PayPal
Once the buyer is returned from PayPal to your return URL the getDetails() method can be used to retrieve all the transaction and buyer details via GetExpressCheckoutDetails API before completing the transaction. All details are returned as an array.
Updating the Buyers Shipping Address
The updateShippingAddress() method can be used to update the shipping address the buyer selected or added during the PayPal checkout via the GetExpressCheckoutDetails API. (Use getDetails() to retrieve this info).
The address is either added or updated in the current user session associated with the Express Checkout token. The address is used in the final API call so the address will appear on payment receipts.
Completing the Transaction
The complete() method calls the DoExpressCheckoutPayment API and completes the transaction.
Refunding a Transaction
The refund() method calls the RefundTransaction API and refunds the transaction. There are two types of refunds Full which will refund the full amount or partial which will refund an amount specified.
Express Checkout Mark (ECM)
The following is a quick guide on implementing PayPal Express Checkout as a payment method (Express Checkout Mark) and creating a Sale transaction where funds are immediately captured. In this flow, buyers initiate the Express Checkout flow after you have collected all their information such as name, email, shipping & billing address.
When the buyer chooses to pay with PayPal, the Express Checkout flow commences.
Define a new route that will be used to setup the Express Checkout transaction and redirect the buyer to PayPal.
When we create the transaction a token value will be returned in the response. The buyer is redirected to a specific URL with the token value defined so PayPal knows what transaction to display the buyer.
For simplicity the correct URL is returned from the create() method as the 'redirect' value.
After the buyer logs in or fills out their payment information on the guest checkout flow they will be redirected back to the URL defined in the PayPal section of your project config.
The URL will have two values appended to it, token & PayerID. The token will be the same EC token that is returned when you first created the transaction and the PayerID is a unique identifier for the buyers PayPal account.
At this stage in the checkout you can either show an order review with an option to Complete or simply complete the transaction and display an order receipt/summary.
Order Review Page - optional step
To display an order review page we can request all the transaction details from PayPal using the getDetails() method. This will include everything defined when you created the transaction and if the buyer has changed their shipping address on PayPal we can get the updated address from here.
Complete Transaction / Order Summary
You can simply complete the transaction using the complete() method and display an order summary/receipt page to the buyer.
Express Checkout Shortcut (ECS)
The following is a quick guide on implementing PayPal Express Checkout on the basket and creating a Sale transaction where funds are immediately captured. In this flow, buyers initiate the Express Checkout Shortcut flow from the shopping cart/basket bypassing sign up and address forms as we leverage the API to retrieve those details from PayPal.
When the buyer clicks the Checkout with PayPal, the Express Checkout flow commences.
Define a new route that will be used to setup the Express Checkout transaction and redirect the buyer to PayPal.
When we create the transaction a token value will be returned in the response. The buyer is redirected to a specific URL with the token value defined so PayPal knows what transaction to display the buyer.
For simplicity the correct URL is returned from the create() method as the 'redirect' value.
After the buyer logs in or fills out their payment information on the guest checkout flow they will be redirected back to the URL defined in the PayPal section of your project config.
The URL will have two values appended to it, token & PayerID. The token will be the same EC token that is returned when you first created the transaction and the PayerID is a unique identifier for the buyers PayPal account.
At this stage in the checkout you can either show an order review with an option to Complete or simply complete the transaction and display an order receipt/summary.
Order Review Page
To display an order review page we can request all the transaction details from PayPal using the getDetails() method. This will include everything defined when you created the transaction and if the buyer has changed their shipping address on PayPal we can get the updated address from here.
Complete Transaction / Order Summary
You can simply complete the transaction using the complete() method and display an order summary/receipt page to the buyer.
Recurring Payments
The following is a quick guide on implementing a recurring payment (subscription) via the classic API.
Define a new route that will be used to setup the Recurring Payment and redirect the buyer to PayPal.
Just like Express Checkout (we're leveraging the same API call) when we create the Recurring Payment a token value will be returned in the response. The buyer is redirected to a specific URL with the token value defined so PayPal knows what transaction to display the buyer.
For simplicity the correct URL is returned from the create() method as the 'redirect' value.
After the buyer logs and agree's to the Recurring Payment they will be redirected back to the URL defined in the PayPal section of your project config.
The URL will have one value appended to it token. The token will be the same token that is returned when you first created the recurring payment.
We now setup the terms of the recurring payment and create the profile.
`
Reference Transactions / Billing Agreements
The following is a quick guide on implementing Express Checkout Reference Transactions via the classic API.
Define a new route that will be used to setup the billing agreement and redirect the buyer to PayPal.
When the buyer returns from PayPal we use the EC Token to create the Billing agreement using the CreateBillingAgreement API request. A successful response will contain a ['BILLINGAGREEMENTID'] value. Save this value as it is required to create future reference transactions.
Once you have a valid billing agreement ID for the buyer you can create/complete a transaction on their behalf using the DoReferenceTransaction API.
PayPal Pro
To process credit/debit card numbers directly you can use the dcc() method.
`
License
F3-PYPL is licensed under GPL v.3