GithubHelp home page GithubHelp logo

recca0120 / laravel-payum Goto Github PK

View Code? Open in Web Editor NEW
75.0 6.0 26.0 291 KB

Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more

License: MIT License

PHP 99.63% HTML 0.37%
laravel payum payment-gateway

laravel-payum's Introduction

Payum for Laravel 5

StyleCI Build Status Total Downloads Latest Stable Version Latest Unstable Version License Monthly Downloads Daily Downloads Scrutinizer Code Quality Code Coverage

Installing

To get the latest version of Laravel Exceptions, simply require the project using Composer:

composer require recca0120/laravel-payum

Instead, you may of course manually update your require block and run composer update if you so choose:

{
    "require": {
        "recca0120/laravel-payum": "^1.0.6"
    }
}

Include the service provider within config/app.php. The service povider is needed for the generator artisan command.

'providers' => [
    ...
    Recca0120\LaravelPayum\LaravelPayumServiceProvider::class,
    ...
];

Config

return [
    'route' => [
        'prefix' => 'payment',
        'as' => 'payment.',
        'middleware' => ['web'],
    ],

    'storage' => [
        // options: eloquent, filesystem
        'token' => 'filesystem',

        // options: eloquent, filesystem
        'gatewayConfig' => 'filesystem',
    ],

    'gatewayConfigs' => [
        // 'customFactoryName' => [
        //     'factory'  => 'FactoryClass',
        //     'username' => 'username',
        //     'password' => 'password',
        //     'sandbox'  => false
        // ],
    ],
];

VerifyCsrfToken

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'payment/*'
    ];
}

Controller

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Payum\Core\GatewayInterface;
use Payum\Core\Model\PaymentInterface;
use Payum\Core\Payum;
use Payum\Core\Request\GetHumanStatus;
use Payum\Core\Security\TokenInterface;
use Payum\Core\Storage\StorageInterface;
use Recca0120\LaravelPayum\Service\PayumService;

class PaymentController extends BaseController
{
    public function capture(PayumService $payumService)
    {
        return $payumService->capture('allpay', function (
            PaymentInterface $payment,
            $gatewayName,
            StorageInterface $storage,
            Payum $payum
        ) {
            $payment->setNumber(uniqid());
            $payment->setCurrencyCode('TWD');
            $payment->setTotalAmount(2000);
            $payment->setDescription('A description');
            $payment->setClientId('anId');
            $payment->setClientEmail('[email protected]');
            $payment->setDetails([
                'Items' => [
                    [
                        'Name' => '歐付寶黑芝麻豆漿',
                        'Price' => (int) '2000',
                        'Currency' => '元',
                        'Quantity' => (int) '1',
                        'URL' => 'dedwed',
                    ],
                ],
            ]);
        });
    }

    public function done(PayumService $payumService, $payumToken)
    {
        return $payumService->done($payumToken, function (
            GetHumanStatus $status,
            PaymentInterface $payment,
            GatewayInterface $gateway,
            TokenInterface $token
        ) {
            return response()->json([
                'status' => $status->getValue(),
                'client' => [
                    'id' => $payment->getClientId(),
                    'email' => $payment->getClientEmail(),
                ],
                'number' => $payment->getNumber(),
                'description' => $payment->getCurrencyCode(),
                'total_amount' => $payment->getTotalAmount(),
                'currency_code' => $payment->getCurrencyCode(),
                'details' => $payment->getDetails(),
            ]);
        });
    }
}

Router

Route::get('payment', [
    'as'   => 'payment',
    'uses' => 'PaymentController@capture',
]);

Route::any('payment/done/{payumToken}', [
    'as'   => 'payment.done',
    'uses' => 'PaymentController@done',
]);

Eloquent

If you want use eloquent you need change config.php and create database

Migrate

publish vendor

artisan vendor:publish --provider="Recca0120\LaravelPayum\LaravelPayumServiceProvider"

migrate

artisan migrate

modify config

return [
    'route' => [
        'prefix' => 'payment',
        'as' => 'payment.',
        'middleware' => ['web'],
    ],

    'storage' => [
        // options: eloquent, eloquent
        'token' => 'filesystem',

        // options: eloquent, filesystem
        'gatewayConfig' => 'filesystem',
    ],

    // 'customFactoryName' => [
    //     'factory'  => 'FactoryClass',
    //     'username' => 'username',
    //     'password' => 'password',
    //     'sandbox'  => false
    // ],
    'gatewayConfigs' => [
        'offline' => []
    ],
];

laravel-payum's People

Contributors

recca0120 avatar roquie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

laravel-payum's Issues

This package not working with Payex at all

I tested this package an try to use it for Payex payment but not working
I have failed response

[status] => failed

this is my configration


return [
    'route' => [
        'prefix'     => 'payment',
        'as'         => 'payment.',
        'middleware' => 'web',
    ],
    'storage' => [
        // optioins: eloquent, filesystem
        'token'         => 'filesystem',
        // optioins: eloquent, filesystem
        'gatewayConfig' => 'filesystem',
    ],
    'gatewayConfigs' => [
        'payex' => [
            'factory'        => Payum\Payex\PayexGatewayFactory::class,
            'account_number' => 'xxxxxxxx',
            'encryption_key' => 'xxxxxxxxxxxxxxxx',
            'sandbox'        => true
        ],
    ],
];

but i have error


        [errorCode] => ValidationError_HashNotValid
        [errorDescription] => Admin.ValidateMerchantLogon:Invalid hash

i think it is the same isuee for @krinkel #5

plese help @recca0120

Bug Cant Use Gateway Config Using Eloquent...

I tried Changing filesystem to eloquent for my Gatewayconfigs in payum.php

<?php

return [
    'router' => [
        'prefix'     => 'payment',
        'as'         => 'payment.',
    ],

    'storage' => [
        // options: eloquent, filesystem
        'token' => 'eloquent',

        // options: eloquent, filesystem
        'gatewayConfig' => 'eloquent',
    ],

    // 'customFactoryName' => [
    //     'factory'  => 'FactoryClass',
    //     'username' => 'username',
    //     'password' => 'password',
    //     'sandbox'  => false
    // ],
    'gatewayConfigs' => [
      'offline' => [
          'factory' =>'offline'
        ],
        'paypal_express_checkout' => [
           'factory'   => 'paypal_express_checkout',
           'username'  => env('PAYPAL_EC_USERNAME'),
           'password'  => env('PAYPAL_EC_PASSWORD'),
           'signature' => env('PAYPAL_EC_SIGNATURE'),
           'sandbox'   => env('PAYPAL_EC_SANDBOX', true),
       ],
    ],
];

Now if i remove this block... the code no longer works

'gatewayConfigs' => [
      'offline' => [
          'factory' =>'offline'
        ],
        'paypal_express_checkout' => [
           'factory'   => 'paypal_express_checkout',
           'username'  => env('PAYPAL_EC_USERNAME'),
           'password'  => env('PAYPAL_EC_PASSWORD'),
           'signature' => env('PAYPAL_EC_SIGNATURE'),
           'sandbox'   => env('PAYPAL_EC_SANDBOX', true),
       ],
    ],

i tried populating my database payum_gateway_configs manually using mysql workbench
with this dummy data instead of using the code that i removed from config/payum.php

id:1    
config:{"factory": "paypal_express_checkout","username": "iyuri305mcmlxxxviii-facilitator_api1.gmail.com","password": "W8XBDAL5THVRKLX2", "signature": "AzWNzYza2cDQ7YutziQHp84-BVdjAefu3.wZw3YYb63AVXU8vHe2pZQh","sandbox": true}  
factoryName: paypal_express_checkout    
gatewayName: paypal_express_checkout    
created_at: 2016-10-15 13:15:31 
updated_at: 2016-10-15 13:15:31

How should my Controller look like now?
Is this the Proper way of doing it? if i intend to use eloquent for my config?
Thanks

redirect loop problem

您好,最近剛好有專案需要使用laravel串綠界及歐付寶的金流
透過網路看到您所提供的套件,但是照著上面的步驟設定卻出現了刷卡後訂單編號重複的問題
目前感覺應該是刷卡完成後引導的頁面又再次連到了原本的付款頁面所致
想請問一下是否有解決方式

環境:
Apache 2.4.35
php 7.2.11
Laravel 5.7

安裝過程

> laravel new project
> cd project
> php artisan key:generate
> composer require recca0120/laravel-payum
> composer require payum-tw/ecpay
> composer require payum-tw/allpay
> php artisan make:controller PaymentController

接著設定config/app.php中添加providers

Recca0120\LaravelPayum\LaravelPayumServiceProvider::class,

再設定config/payum.php

return [
    'router' => [
        'prefix'     => 'payment',
        'as'         => 'payment.',
    ],

    'storage' => [
        // optioins: eloquent, filesystem
        'token' => 'filesystem',

        // optioins: eloquent, filesystem
        'gatewayConfig' => 'filesystem',
    ],
    'gatewayConfigs' => [
        /*
        'allpay' => [
            'factory' => PayumTW\Allpay\AllpayGatewayFactory::class,
            'MerchantID' => '2000132',
            'HashKey' => '5294y06JbISpM5x9',
            'HashIV' => 'v77hoKGq4kWxNNIS',
            'sandbox' => true,
        ],
        */
        'ecpay' => [
            'factory' => PayumTW\Ecpay\EcpayGatewayFactory::class,
            'MerchantID' => '2000132',
            'HashKey' => '5294y06JbISpM5x9',
            'HashIV' => 'v77hoKGq4kWxNNIS',
            'sandbox' => true,
        ],
    ],
];

設定PaymentController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Payum\Core\GatewayInterface;
use Payum\Core\Model\PaymentInterface;
use Payum\Core\Payum;
use Payum\Core\Request\GetHumanStatus;
use Payum\Core\Security\TokenInterface;
use Payum\Core\Storage\StorageInterface;
use Recca0120\LaravelPayum\Service\PayumService;

class PaymentController extends BaseController
{
    public function capture(PayumService $payumService)
    {
        return $payumService->capture('ecpay', function (
            PaymentInterface $payment,
            $gatewayName,
            StorageInterface $storage,
            Payum $payum
        ) {
            $payment->setNumber(uniqid());
            $payment->setCurrencyCode('TWD');
            $payment->setTotalAmount(2000);
            $payment->setDescription('A description');
            $payment->setClientId('anId');
            $payment->setClientEmail('[email protected]');
            $payment->setDetails([
                'Items' => [
                    [
                        'Name' => '歐付寶黑芝麻豆漿',
                        'Price' => (int) '2000',
                        'Currency' => '元',
                        'Quantity' => (int) '1',
                        'URL' => 'dedwed',
                    ],
                ],
            ]);
        });
    }

    public function done(PayumService $payumService, $payumToken)
    {
        return $payumService->done($payumToken, function (
            GetHumanStatus $status,
            PaymentInterface $payment,
            GatewayInterface $gateway,
            TokenInterface $token
        ) {
            return response()->json([
                'status' => $status->getValue(),
                'client' => [
                    'id' => $payment->getClientId(),
                    'email' => $payment->getClientEmail(),
                ],
                'number' => $payment->getNumber(),
                'description' => $payment->getCurrencyCode(),
                'total_amount' => $payment->getTotalAmount(),
                'currency_code' => $payment->getCurrencyCode(),
                'details' => $payment->getDetails(),
            ]);
        });
    }
}

設定routes/web.php

Route::get('/payment', [
    'as'   => 'payment',
    'uses' => 'PaymentController@capture',
]);

Route::any('/payment/done/{payumToken}', [
    'as'   => 'payment.done',
    'uses' => 'PaymentController@done',
]);

接著執行 http://project_url/payment 會跳轉到綠界的付款頁面,然後使用測試資料刷卡後會再返回http://project_url/payment/capture/XXXXX,然後再導向綠界的付款頁面時顯示交易失敗: 訂單編號已重複 (而歐付寶則是會一直在/capture/XXXXX與付款頁面之間循環)。

想請教一下應該如何修改,或是安裝的過程中出現了錯誤,謝謝。

Support latest version

Hello,
I have reviewed this package and found in it many awesome features. I would like to request an update for this package to the latest versions of Payum and Laravel.

How to Use Properly Recurring Payment For Paypal Express Pro?

I Check the Documentation of Payum... Something i can follow with...

https://github.com/Payum/PaypalExpressCheckoutNvp/blob/master/Resources/docs/recurring-payments-basics.md

This is What i Did...
I ENABLE PAYPAL EXPRESS CHECKOUT
in my payum.php

'gatewayConfigs' => [
        'offline' => [
          'gatewayName' =>'offline'
        ],
        'paypal_ec' => [
          'gatewayName' => 'paypal_ec',
            'config' => [
                'factory' => 'paypal_express_checkout',
                'username' => env('PAYPAL_EC_USERNAME'),
                'password' => env('PAYPAL_EC_PASSWORD'),
                'signature' => env('PAYPAL_EC_SIGNATURE'),
                'sandbox' => env('PAYPAL_EC_SANDBOX', true),
            ],
        ],
    ],

Then in my Controller change offline to paypal_ec

protected $gatewayName = 'paypal_ec';

THEN
FOLLOWED THIS TUTS...

PaypalExpressCheckoutNvp example Establish agreement (prepare.php)

https://github.com/Payum/PaypalExpressCheckoutNvp/blob/master/Resources/docs/recurring-payments-basics.md#establish-agreement-preparephp

AND CHANGE MY ONPREPARE METHOD TO THIS



    public function onPrepare($payment, $gatewayName, $storage, $payum)
    {
        $payment->setNumber(uniqid());
        $payment->setCurrencyCode('USD');
        $payment->setTotalAmount(1000);
        $payment->setDescription('Gold Membership');
        $payment->setClientId('10000000');
        $payment->setClientEmail('[email protected]');
        $payment->setDetails([
            'BRANDNAME' => 'ANYWHERE',
            'L_BILLINGTYPE0' => 'RecurringPayments,
            'L_BILLINGAGREEMENTDESCRIPTION0' => 'Gold Membership 10$ Per Day',
            'NOSHIPPING' => 1,
        ]);

        return $payment;
    }

FOLLOW THIS TUTS...
PaypalExpressCheckoutNvp example for Create recurring payment

https://github.com/Payum/PaypalExpressCheckoutNvp/blob/master/Resources/docs/recurring-payments-basics.md#create-recurring-payment

THEN CHANGE MY ON DONE METHOD LIKE THIS.

 public function onDone($status, $payment, $gateway, $token)
    {
        return response()->json([
            'status' => $status->getValue(),
            'client' => [
                'id'    => $payment->getClientId(),
                'email' => $payment->getClientEmail(),
            ],
            'number'        => $payment->getNumber(),
            'description'   => $payment->getCurrencyCode(),
            'total_amount'  => $payment->getTotalAmount(),
            'currency_code' => $payment->getCurrencyCode(),
            'details'       => $payment->getDetails([
                'DESC' => 'Subscribe DAILY. It is 10$ per Day.',
                'AMT' => 1000,
                'CURRENCYCODE' => 'USD',
                'BILLINGFREQUENCY' => 1,
                'PROFILESTARTDATE' => \Carbon\Carbon::now()->format('Y-m-d\TH:i:s\Z'),
                'BILLINGPERIOD' =>'Day'
            ]),
        ]);
    }

i Get something like this
url

http://payum.sandbox/payment/done/wxiXpvlZVDsRtJEJj57ktua5sOZe-xxOIDwzhVz5Exc

This is the response

{"status":"captured","client":{"id":"10000000","email":"[email protected]"},"number":"578441ad32ea8","description":"USD","total_amount":"1000","currency_code":"USD","details":{"BRANDNAME":"TEST DAILY SUBSCRIPTION!","L_BILLINGTYPE0":"RecurringPayments","L_BILLINGAGREEMENTDESCRIPTION0":"Gold Membership 10$ Per Day","NOSHIPPING":1,"INVNUM":"578441ad32ea8","PAYMENTREQUEST_0_CURRENCYCODE":"USD","PAYMENTREQUEST_0_AMT":"10.00","PAYMENTREQUEST_0_DESC":"Gold Membership","PAYMENTREQUEST_0_PAYMENTACTION":"Sale","AUTHORIZE_TOKEN_USERACTION":"commit","RETURNURL":"http:\/\/payum.sandbox\/payment\/capture\/g_NH0gz1FBdjjgf_-VbLfvPYPMbLAyB5fmSUc4vIm6E","CANCELURL":"http:\/\/payum.sandbox\/payment\/capture\/g_NH0gz1FBdjjgf_-VbLfvPYPMbLAyB5fmSUc4vIm6E?cancelled=1","PAYMENTREQUEST_0_NOTIFYURL":"http:\/\/payum.sandbox\/payment\/notify\/zY4A9JQEcpQg1xhXFyQkL0rRP129uu-SU4s1RTPuh2E","TOKEN":"EC-7M43874039009750U","TIMESTAMP":"2016-07-12T01:03:34Z","CORRELATIONID":"8d3ffa0256ff4","ACK":"Success","VERSION":"65.1","BUILD":"23255924","BILLINGAGREEMENTACCEPTEDSTATUS":"1","CHECKOUTSTATUS":"PaymentActionCompleted","CURRENCYCODE":"USD","AMT":"10.00","SHIPPINGAMT":"0.00","HANDLINGAMT":"0.00","TAXAMT":"0.00","DESC":"Gold Membership","NOTIFYURL":"http:\/\/payum.sandbox\/payment\/notify\/zY4A9JQEcpQg1xhXFyQkL0rRP129uu-SU4s1RTPuh2E","INSURANCEAMT":"0.00","SHIPDISCAMT":"0.00","PAYMENTREQUEST_0_SHIPPINGAMT":"0.00","PAYMENTREQUEST_0_HANDLINGAMT":"0.00","PAYMENTREQUEST_0_TAXAMT":"0.00","PAYMENTREQUEST_0_INSURANCEAMT":"0.00","PAYMENTREQUEST_0_SHIPDISCAMT":"0.00","PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED":"false","PAYMENTREQUESTINFO_0_ERRORCODE":"0","EMAIL":"[email protected]","PAYERID":"8CUQXLYD8LCPJ","PAYERSTATUS":"verified","FIRSTNAME":"test","LASTNAME":"buyer","COUNTRYCODE":"US","SUCCESSPAGEREDIRECTREQUESTED":"false","INSURANCEOPTIONSELECTED":"false","SHIPPINGOPTIONISDEFAULT":"false","PAYMENTINFO_0_TRANSACTIONID":"4JH16593GT4278323","PAYMENTINFO_0_TRANSACTIONTYPE":"expresscheckout","PAYMENTINFO_0_PAYMENTTYPE":"instant","PAYMENTINFO_0_ORDERTIME":"2016-07-12T01:03:32Z","PAYMENTINFO_0_AMT":"10.00","PAYMENTINFO_0_FEEAMT":"0.59","PAYMENTINFO_0_TAXAMT":"0.00","PAYMENTINFO_0_CURRENCYCODE":"USD","PAYMENTINFO_0_PAYMENTSTATUS":"Completed","PAYMENTINFO_0_PENDINGREASON":"None","PAYMENTINFO_0_REASONCODE":"None","PAYMENTINFO_0_PROTECTIONELIGIBILITY":"Ineligible","PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE":"None","PAYMENTINFO_0_ERRORCODE":"0","PAYMENTINFO_0_ACK":"Success","PAYMENTREQUEST_0_TRANSACTIONID":"4JH16593GT4278323","PAYMENTREQUESTINFO_0_TRANSACTIONID":"4JH16593GT4278323","PAYMENTREQUEST_0_TRANSACTIONTYPE":"expresscheckout","PAYMENTREQUEST_0_PAYMENTTYPE":"instant","PAYMENTREQUEST_0_ORDERTIME":"2016-07-12T01:03:32Z","PAYMENTREQUEST_0_FEEAMT":"0.59","PAYMENTREQUEST_0_PAYMENTSTATUS":"Completed","PAYMENTREQUEST_0_PENDINGREASON":"None","PAYMENTREQUEST_0_REASONCODE":"None"}}

USER INTERACTING IN YOUR APP...

1.) i go to http://payum.sandbox/payment/

2.) then i redirect me to paypal...

3.) LOGIN

4.) then ask you

Use PayPal for automatic payments to TEST DAILY SUBSCRIPTION!. Payments will be made with your default payment method unless you select a preferred payment method. To make a change, go to My Preapproved Payments on the Profile page.
Agree and Pay

5.) Click Agree and Pay...

6.) Show me the Return Response

NOW MY QUESTION IS...
if i logged in my tester sandbox account that subscribe and Check PRE APPROVED PAYMENTS

https://www.sandbox.paypal.com/?cmd=_ap-manage-preapprovals

I see NOTHING...

WHAT IS WRONG... ???

Supposedly I will see a Pre Approved Payments that U allowed but i cant see any...

Please kindly check my CODE

Klarna is deprecated?

is payum klarna deprecated?

The BASE_URI_LIVE and BASE_URI_SANDBOX are changed with klarna v.3 and v.4

is klarna plugin still working ?

May be change hardcoded storages models?

Hello,

I use eloquent storage for my payments and my tables have another name, another columns titles but fully compatible with Payum. I implement my models like as Recca0120\LaravelPayum\Model\Payment::class and I attempted to redeclare in my service provider
(loaded after your):

use Recca0120\LaravelPayum\Storage\EloquentStorage;

 /** @var PayumBuilder $builder */
$builder = $this->app->make(PayumBuilder::class);
$builder
      ->setTokenStorage(new EloquentStorage(\App\Token::class))
      ->addStorage(Payment::class, new EloquentStorage(\App\Payment::class))
      // add gateway factories
;

then I tried run this payment and receive that error: "table [payum_payments] not found in database". That speaks about this fact - models are hardcoded into library and I can't use custom.

Solution:

  1. LaravelPayumServiceProvider Add method, where I can set my $builder settings, and if they are not set, use by default from library. Then I extend ServiceProvider class and overwrite there him.
  2. Method getStorage of PayumService class hardcoded library EloquentPayment model. Change it.

What do you think? Maybe I create PR?

Error: Gateway factory "offline" does not exist.

I followed the documentation, but i am getting an error. I am also not sure where to add the config file, currently i have a file called config/payum.php which has the content described in the docs. here is the error i am recieving

InvalidArgumentException in AbstractRegistry.php line 117:
Gateway factory "offline" does not exist.

Thanks

I Manage to Make Recurring Work... Now How to Cancel Recurring Subscription and Reactivate?

Your Code is Great But Lacks Sample...

I manage to Successfully make a Recurring payment...
With a Little Tweak from your Code example ....

Here i Plan to Create 1 Week Free Trial Then Do Monthly Subscription Until Cancelled
This is How i Do it...

As shown ... That my Code Example Below will work...
recurring profile
recurring

This is How i Do it...

I Imported Sync ,CreateRecurringPaymentProfile ,Api From Payum\Paypal\ExpressCheckout\Nvp

<?php

namespace App\Http\Controllers\Gateway;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Payum\Core\GatewayInterface;
use Payum\Core\Model\PaymentInterface;
use Payum\Core\Payum;
use Payum\Core\Request\GetHumanStatus;
use Payum\Core\Security\TokenInterface;
use Payum\Core\Storage\StorageInterface;
use Recca0120\LaravelPayum\Service\Payment;
use Payum\Paypal\ExpressCheckout\Nvp\Api;
use Payum\Core\Request\Sync;
use Payum\Paypal\ExpressCheckout\Nvp\Request\Api\CreateRecurringPaymentProfile;

prepare method ( Added Here All Needed Properties for Recurring)

public function prepare(Payment $payment)
  {
      return $payment->prepare('paypal_express_checkout', function (PaymentInterface $payment, $gatewayName, StorageInterface $storage, Payum $payum) {
          $payment->setNumber(uniqid());
          $payment->setCurrencyCode('PHP');// Needed For Payum to Work
          $payment->setClientId('customer-001'); // Auth User ID
          $payment->setClientEmail('[email protected]'); // Auth User Email
          $payment->setDetails([
            'BRANDNAME' => 'My Company', // Provide name for cancel and return url
            'LOGOIMG' => 'https://profugo.org/wp-content/uploads/2013/08/logo-190x60.png', // Show at Top
            'SOLUTIONTYPE' => 'Mark', //Buyer must have a PayPal account to check out
            'LANDINGPAGE' => 'Login', // Billing(Credit Card) or Login Type Pages
            'CARTBORDERCOLOR' => '009688', // Border Color
            'CHANNELTYPE' => 'Merchant',
            'L_BILLINGTYPE0' => Api::BILLINGTYPE_RECURRING_PAYMENTS, // Enables Recurring
            'L_BILLINGAGREEMENTDESCRIPTION0' => '1 Week Free Trial then PREMIUM Membership ₱500 PHP Per Month', // Billing Agreement
            'PAYMENTREQUEST_0_AMT' => 0, // Zero Transaction
            'NOSHIPPING' => 1, // Enable no Shipping Fee for Digital Products
          ]);
      });
  }

done method ( with CreateRecurringPaymentProfile)


public function done(Payment $payment, Request $request, $payumToken)
    {
      return $payment->done($request, $payumToken, function (GetHumanStatus $status, PaymentInterface $payment, GatewayInterface $gateway, TokenInterface $token) {
        $agreement = $status->getModel();
        $payment->setClientEmail($agreement['EMAIL']);
        $payment->setDetails([
          'TOKEN' => $agreement['TOKEN'], // EC_SOMERANDOMESTRING
          'SUBSCRIBERNAME' => $agreement['SUBSCRIBERNAME'], // Paypal Name Used for Payment
          'DESC' =>  '1 Week Free Trial then PREMIUM Membership ₱500 PHP Per Month', // MUST BE THE SAME AS L_BILLINGAGREEMENTDESCRIPTION0
          'EMAIL' =>  $agreement['EMAIL'], // Paypal Email used for payment Useful if user uses different Email for Subscription
          'AMT' =>  500, // The Amount they Will pay per month
          'TAXAMT' => 60,
          'CURRENCYCODE' =>  'PHP',
          'BILLINGFREQUENCY' =>  1, // 1 per month
          'PROFILESTARTDATE' => date(DATE_ATOM), // Current Date
          'BILLINGPERIOD' => Api::BILLINGPERIOD_MONTH, // Per Month
          'MAXFAILEDPAYMENTS' => 3,
          'PROFILEREFERENCE' => 'order#1', // My Reference For That Order No#
          'TRIALBILLINGPERIOD' => Api::BILLINGPERIOD_WEEK, // Per Week
          'TRIALBILLINGFREQUENCY' => 1, // 1 Week
          'TRIALTOTALBILLINGCYCLES' => 1, // x1 Week
          'TRIALAMT' => 0 // FREE TRIAL at 0
        ]);

        $gateway->execute(new CreateRecurringPaymentProfile($payment));
        $gateway->execute(new Sync($payment));
          // Add Role or permission
          // Return RedirectTo Dashboard.
          // Check if Active, Pending, Cancelled , Suspended ,Expired
          return response()->json([
              'status' => $status->getValue(),
              'client' => [
                  'id'    => $payment->getClientId(),
                  'email' => $payment->getClientEmail(),
              ],
              'number'        => $payment->getNumber(),
              'description'   => $payment->getCurrencyCode(),
              'total_amount'  => $payment->getTotalAmount(),
              'currency_code' => $payment->getCurrencyCode(),
              'details'       => $payment->getDetails(),
          ]);
      });
    }

In My Routes File

Route::get('payment/paypal', [
    'uses' => 'Gateway\PaypalController@prepare',
    'as' => 'payment.paypal',
]);
Route::any('payment/paypal/done/{payumToken}', [
    'uses' => 'Gateway\PaypalController@done',
    'as' => 'payment.done',
]);

This Code Works to make Recuring Payment...

My Problem Now is

1.) How Can I Catch if a User Cancel it From Inside Paypal Site....?

2.) How Can a User Reactivate a Recurring Payment in Dashboard?

3.) How Can a User Cancel Recurring Payment In Dashboard...?

Can You Show me or Point me to the Right Path thanks

Also Please Also Make A Wiki For Examples, U can use mine for Recurring thanks

get response without fill visa information

i used payum, it has a bug with payex, but when use your package it work successfully :) grate work, thank you.
my problem now when i visit prepare page:
http://project.dev:8000/en/payment/payex
it is redirect me directly to:
http://project.dev:8000/en/payment/done/6ZSqW2986XZZGKlvuImyuA2QV38MsQlj9Br6wjGCK4A
without fill any visa information, so the response get failed!!
the first and second time i test the payment it redirect me to fill visa and the payment successfully done, but now after tow or three times i can’t test more, it same that the service cached my request and get failed response, i don’t know why .. but is it can be fix?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.