All Projects → amirduran → Duranius Paypal Rest Api Php Library

amirduran / Duranius Paypal Rest Api Php Library

If you need to integrate your website with PayPal REST API, then all you need is to download this library and you are ready to go. There are only two files you need to download and import to your project.

Labels

Projects that are alternatives of or similar to Duranius Paypal Rest Api Php Library

Cartkit
Cartkit - The [quick] starter kit!
Stars: ✭ 39 (+200%)
Mutual labels:  paypal
Jsqlparser
JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern
Stars: ✭ 3,405 (+26092.31%)
Mutual labels:  paypal
Django Payments
Universal payment handling for Django.
Stars: ✭ 575 (+4323.08%)
Mutual labels:  paypal
django ecommerce
Scalable Django E-Commerce, perfect to start one new online shop project.
Stars: ✭ 25 (+92.31%)
Mutual labels:  paypal
solidus braintree
Braintree v.zero support for solidus
Stars: ✭ 19 (+46.15%)
Mutual labels:  paypal
Digota
ecommerce microservice
Stars: ✭ 382 (+2838.46%)
Mutual labels:  paypal
procesa-pagos-con-laravel
Código fuente resultado del curso "Procesa pagos con Laravel y las mejores plataformas de pagos"
Stars: ✭ 38 (+192.31%)
Mutual labels:  paypal
Nopcommerce
The most popular open-source eCommerce shopping cart solution based on ASP.NET Core
Stars: ✭ 6,827 (+52415.38%)
Mutual labels:  paypal
fiber-boilerplate
This is the go boilerplate on the top of fiber web framework. With simple setup you can use many features out of the box
Stars: ✭ 184 (+1315.38%)
Mutual labels:  paypal
Qrpay
五合一收款码在线生成,40个模板 支持微信支付、支付宝支付、手机QQ支付、京东钱包、百度钱包,PayPal五合一收款,将其二维码合并为一个二维码,无需手续费,支持qq头像,昵称判断(HTML单页版多模板免安装) 腾讯云服务器 https://api.isoyu.com/qrpay/ 腾讯云COS https://qrpay.isoyu.com/
Stars: ✭ 477 (+3569.23%)
Mutual labels:  paypal
Nest-Js-Boiler-Plate
Nest Js Boilerplate with JWT authentication, CRUD functions and payment gateways.
Stars: ✭ 14 (+7.69%)
Mutual labels:  paypal
react-smart-payment-buttons
React integration for PayPal Smart Payment Buttons
Stars: ✭ 18 (+38.46%)
Mutual labels:  paypal
Blacklist
Blacklist and Adware Blocking for the Ubiquiti EdgeMax Router
Stars: ✭ 393 (+2923.08%)
Mutual labels:  paypal
titanium-paypal
💰 Use the PayPal iOS-SDK 2.x with Titanium Mobile.
Stars: ✭ 22 (+69.23%)
Mutual labels:  paypal
Django Paypal
A pluggable Django application for integrating PayPal Payments Standard or Payments Pro
Stars: ✭ 602 (+4530.77%)
Mutual labels:  paypal
PayumYiiExtension
Rich payment solutions for Yii framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Stars: ✭ 13 (+0%)
Mutual labels:  paypal
Yclas
Yclas Self Hosted is a powerful script that can transform any domain into a fully customizable classifieds site within a few seconds.
Stars: ✭ 276 (+2023.08%)
Mutual labels:  paypal
Paypal Checkout Components
Javascript Integration for PayPal Button and PayPal Checkout
Stars: ✭ 938 (+7115.38%)
Mutual labels:  paypal
Laravel Paypal
Laravel plugin for processing payments through PayPal. Can be used separately.
Stars: ✭ 658 (+4961.54%)
Mutual labels:  paypal
Braintree ios
Braintree SDK for iOS
Stars: ✭ 469 (+3507.69%)
Mutual labels:  paypal

paypal-rest-api-php-library

If you need to integrate your website with PayPal REST API, then all you need is to download this library and you are ready to go. There are only two files you need to download and import to your project.

IMPORTANT: Read my blog post about "How to integrate your website with PayPal" here http://code-epicenter.com/how-to-integrate-your-website-with-paypal-using-php/

How to install

##Step 1

In the folder called library you will find two files

  1. DPayPal.php
  2. cacert.pem

Copy both files in your project folder, and reference file DPayPal.php using require_once php command

require_once "DPayPal.php"

Please make sure that both files DPayPal.php and cacert.pem are located in the same folder.

If you want to keep the files DPayPal.php and cacert.pem in the different folders, then open the file DPayPal.php and edit the following line

from CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem', //CA cert file

to CURLOPT_CAINFO => "PATH TO YOUR cacert.pem file"

##Step 2

Please enter your PayPal API credentials in the DPayPal.php file

protected $username = ""; //PayPal API username

protected $password = ""; //PayPal API password

protected $apiSignature = ""; //PayPal API signature

##Step 3

Set your PayPal working environment. Open DPayPal.php and set PayPal API URL:

If you are going to work with live PayPal API then use the following URL: https://api-3t.paypal.com/nvp

If you are going to work with test PayPal API (sandbox) then use the following URL: https://api-3t.sandbox.paypal.com/nvp

For example, if you want to work with Sandbox API set attribute $payPalAPIUrl located in DPayPal.php file to the https://api-3t.sandbox.paypal.com/nvp like it is demonstrated below:

protected $payPalAPIUrl = "https://api-3t.sandbox.paypal.com/nvp";

#How to use the library

Anywhere in your code create DPayPal object:

require_once 'DPayPal.php'; //Import library
$paypal = new DPayPal(); //Create an object

Now if you want to call SetExpressCheckout PayPal API operation, just call SetExpressCheckout on the $paypal object like it is demonstrated here:

$response = $paypal->SetExpressCheckout($requestParams);

where $requestParams is array which contains key=>value pairs, and $response is response object received by PayPal.

###Advanced example:

IMPORTANT - Before we proceed with an example, please have a look at this PayPal payment flow in order to understand how things are working: https://www.paypalobjects.com/webstatic/en_US/developer/docs/ec/sandboxEC.gif

This example explains how to obtain TOKEN from Paypal (steps 1, 2 and 3 from the image above):

$paypal = new DPayPal(); //Create an object

//Generating request parameters for API operation SetExpressCheckout
//All available parameters for this method are available here
//https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/

$requestParams = array(
    'RETURNURL' => "", //Enter your webiste URL here
    'CANCELURL' => ""//Enter your website URL here
);

$orderParams = array(
    'LOGOIMG' => "", //You can paste here your website logo image which will be displayed to the customer on the PayPal chechout page
    "MAXAMT" => "100", //Set max transaction amount
    "NOSHIPPING" => "1", //I do not want shipping
    "ALLOWNOTE" => "0", //I do not want to allow notes
    "BRANDNAME" => "Here enter your brand name",
    "GIFTRECEIPTENABLE" => "0",
    "GIFTMESSAGEENABLE" => "0"
);
$item = array(
    'PAYMENTREQUEST_0_AMT' => "20",
    'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP',
    'PAYMENTREQUEST_0_ITEMAMT' => "20",
    'L_PAYMENTREQUEST_0_NAME0' => 'Item name',
    'L_PAYMENTREQUEST_0_DESC0' => 'Item description',
    'L_PAYMENTREQUEST_0_AMT0' => "20",
    'L_PAYMENTREQUEST_0_QTY0' => '1',
        //"PAYMENTREQUEST_0_INVNUM" => $transaction->id - This field is useful if you want to send your internal transaction ID
);

 //Send request and wait for response
 //Now we will call SetExpressCheckout API operation. 

$response = $paypal->SetExpressCheckout($requestParams + $orderParams + $item);

//Response is aslo accessible by calling  $paypal->getLastServerResponse()

//Now you will be redirected to the PayPal to enter your customer data
//After that, you will be returned to the RETURN URL
if (is_array($response) && $response['ACK'] == 'Success') { //Request successful
    //Now we have to redirect user to the PayPal
    $token = $response['TOKEN'];

    header('Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . urlencode($token));
} else if (is_array($response) && $response['ACK'] == 'Failure') {
    var_dump($response);
    exit;
} 

#Other notes

To call GetExpressCheckoutDetails just type:

$paypal->GetExpressCheckoutDetails($requestParameters);

####To call DoExpressCheckoutPayment just type:

$paypal->DoExpressCheckoutPayment($requestParameters);

####List of available methods

SetExpressCheckout
GetExpressCheckoutDetails
DoExpressCheckoutPayment
DoAuthorization
DoCapture
DoReauthorization
DoVoid
UpdateAuthorization
BAUpdate
BillOutstandingAmount
CreateBillingAgreement
CreateRecurringPaymentsProfile
DoReferenceTransaction
GetRecurringPaymentsProfileDetails
ManageRecurringPaymentsProfileStatus
UpdateRecurringPaymentsProfile
RefundTransaction

####To call any other PayPal API operation use method sendRequest.

For example let's say we want to call CreateRecurringPaymentsProfile API operation, then we could do it like this:

$paypal->sendRequest($requestParameters,"CreateRecurringPaymentsProfile");

or more generally

$paypal->sendRequest($requestParameters,"MethodName");

####To see errors just type:

$paypal->showErrors();

####To see last response from PayPal just type:

$response=$paypal->getLastServerResponse();

####You can set new credentials by calling set methods:

$paypal->setUsername("new username");

$paypal->setPassword("new pass");

$paypal->setApiSignature("new signature");

####You can disable or enable error reporting by calling:

$paypal->enableErrorReporting();

$paypal->disableErrorReporting();

Hope I helped :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].