2017 © Pedro Peláez
 

symfony-bundle paypal-payment

Jjacq Paypal Payment

image

jjacq/paypal-payment

Jjacq Paypal Payment

  • Wednesday, December 21, 2016
  • by jacquelotjeff
  • Repository
  • 1 Watchers
  • 0 Stars
  • 49 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

A Paypal Payment Bundle for Symfony

This plugin creates a smart bridge between your website and Paypal., (*1)

You can also define all parameters in your config file., (*2)

Important

This bundle allows you to send payments to Paypal only via paypal method So you can't use this bundle to send payments via credit_card method, (*3)

Installation

Install with composer

composer require jjacq/paypal-payment

Add this line in your AppKernel

new Jjacq\PaypalPaymentBundle\PaypalPaymentBundle(),

Minimum configuration

Add these lines in your app/config/config.yml file., (*4)

paypal_payment:
    client_id: "your-customer-key"
    client_password: "your-customer-password"
    return_url: http://your-project-url.com/app_dev.php/success
    cancel_url: http://your-project-url.com/app_dev.php/error

Advanced configuration

paypal_payment:
    client_id: "your-customer-key"
    client_password: "your-customer-password"
    return_url: http://your-project-url.com/app_dev.php/success
    cancel_url: http://your-project-url.com/app_dev.php/error
    mode: "live" # Default is 'sandbox'
    verbose_mode: true # Default is false /!\ Not efficient in live mode
    log_dir: "/var/logs/paypal_payments/"
    paypal_class: "Jjacq\PaypalPaymentBundle\Paypal\Paypal"
    auth_class: "Jjacq\PaypalPaymentBundle\Paypal\Auth"
    payment_class: "Jjacq\PaypalPaymentBundle\Paypal\Payment"

Basic usage

<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class DefaultController extends Controller
{

    /**
     * @Route("/", name="payment")
     */
    public function indexAction(Request $request)
    {

        $payment = $this->get('paypal_payment.payment');

        // Send the payment to get approval url
        $paymentSend = $payment->sendPayment([
            'amount' => "20.20",
            'currency' => 'EUR',
            'description' => 'Description of your payment',
            'intent' => 'sale',
            'note_to_payer' => 'Note to payer',
        ]);

        // Redirect to Paypal approval url
        return $this->redirect($paymentSend['redirectPaypalApproval']);
    }

    /**
     * @Route("/success", name="success")
     */
    public function successAction(Request $request)
    {
        $paymentId = $request->get('paymentId');
        $token     = $request->get('token');
        $payerId   = $request->get('PayerID');

        // This url is not accessible if there are no paypal informations
        if (empty($paymentId) || empty($token) || empty($payerId)) {
            return $this->redirectToRoute('homepage');
        }

        $payment = $this->get('paypal_payment.payment');
        // Validate the payment (execution)
        $informationsPayment = $payment->executePayment($paymentId, $token, $payerId);

        // Now, you can access payment informations
        // Check if payment was executed ...
        dump($informationsPayment);

        // You can also Store informations in your database ...
        // If payment was executed

        die('Payment success');
    }

    /**
     * @Route("/error", name="error")
     */
    public function errorAction()
    {
        die('Payment error');
    }
}

The Versions

21/12 2016

dev-master

9999999-dev https://github.com/jacquelotjeff/JjacqPaypalPaymentBundle

Jjacq Paypal Payment

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jeff Jacquelot

21/12 2016

v1.0.4

1.0.4.0 https://github.com/jacquelotjeff/JjacqPaypalPaymentBundle

Jjacq Paypal Payment

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jeff Jacquelot

21/12 2016

dev-fix_readme

dev-fix_readme https://github.com/jacquelotjeff/JjacqPaypalPaymentBundle

Jjacq Paypal Payment

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jeff Jacquelot

04/07 2016

v1.0.3

1.0.3.0 https://github.com/jacquelotjeff/JjacqPaypalPaymentBundle

Jjacq Paypal Payment

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jeff Jacquelot

30/06 2016

v1.0.2

1.0.2.0 https://github.com/jacquelotjeff/JjacqPaypalPaymentBundle

Jjacq Paypal Payment

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jeff Jacquelot

30/06 2016

v1.0.1

1.0.1.0 https://github.com/jacquelotjeff/JjacqPaypalPaymentBundle

Jjacq Paypal Payment

  Sources   Download

proprietary

The Requires

  • php >=5.5.9

 

by Jeff Jacquelot

30/06 2016

v1.0.0

1.0.0.0 https://github.com/jacquelotjeff/JjacqPaypalPaymentBundle

Jjacq Paypal Payment

  Sources   Download

proprietary

The Requires

  • php >=5.5.9

 

by Jeff Jacquelot