sahusoftcom/paypal-expresscheckout-digital-goods

PHP (Laravel) Package for PayPal Express CheckOut of Digital Goods

v2.7 2019-10-18 12:07 UTC

This package is auto-updated.

Last update: 2024-10-21 20:36:40 UTC


README

Service Provider of PayPal ExpressCheckout Digital Goods API for Laravel PHP Framework [ Packagist ]

Installation:

Type the following command in your project directory composer require sahusoftcom/paypal-expresscheckout-digital-goods

OR

Add the following line to the require section of composer.json:

{
    "require": {
        "sahusoftcom/paypal-expresscheckout-digital-goods": "dev-master"
    }
}

How to use:

  • You should use the PayPal class to access its function.
  • Then follow the below example for further assisstance,
<?php
namespace App;
 
use SahusoftCom\PayPal\PaymentRequest;
use SahusoftCom\PayPal\PaymentResponse;

class PaymentController {	

    	public $apiContext;
    
	public function __construct()
	{
	    $apiContext = (object)[];
		
            $apiContext->APIUSERNAME = "YOUR-API-USERNAME";
            $apiContext->APIPASSWORD = "YOUR-API-PASSWORD";
            $apiContext->APISIGNATURE = "YOUR-API-SIGNATURE";
            $apiContext->ENDPOINT = "https://api-3t.sandbox.paypal.com/nvp";
            $apiContext->VERSION = "65.1";
            $apiContext->REDIRECTURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
	    
	    $data = [];
            $data['RETURNURL'] = "http://paypal.local.geekydev.com/getDone";
            $data['CANCELURL'] = "http://paypal.local.geekydev.com/getCancel";
            $data['NOTIFYURL'] = "http://paypal.local.geekydev.com/getNotified";
        
            $data['CURRENCY'] = "USD";
            $data['TOTAL_AMOUNT'] = "100";
            $data['AMOUNT'] = "100";
            $data['TAX_AMOUNT'] = "0";
            $data['DESCRIPTION'] = "Movies";
            $data['PAYMENT_ACTION'] = "SALE";
            $data['NOSHIPPING'] = "1";
        
            $data['ITEM_LIST'] = [];
            $data['ITEM_LIST'][0] = [
            	'NAME'			=> 'First Item Name',
        		'NUMBER'		=> 123,
        		'QUANTITY'		=> 1,
        		'TAX_AMOUNT'	=> 0,
        		'AMOUNT'		=> 100,
        		'URL'           => "Your product's url",
        		'DESCRIPTION'	=> 'First Name Description'
            ];
	}
	
	public function checkOut()
	{
            $object = new PaymentRequest($this->apiContext);
            $object->execute($this->data);
	}
	
	public function getDone()
	{
            $object = new \SahusoftCom\PayPal\PaymentResponse($apiContext);
            $response = $object->handle($this->data);

            echo "<pre>";
            print_r($response);
            echo "</pre>";
	}
	
	public function getCancel()
	{
	   // Do your thing
	}