Download the PHP package devinweb/laravel-youcan-pay without Composer

On this page you can find all versions of the php package devinweb/laravel-youcan-pay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-youcan-pay

Latest Version on Packagist Total Downloads GitHub Actions Psalm

Laravel YouCayPay

Introduction

Laravel YouCanPay provides an easy experience, to generate the payment form, and process all the operations related to the payment.

Installation

You can install the package via composer:

Database Migrations

LaravelYouCanPay package provides its own database to manage the user transactions in different steps, the migrations will create a new transactions table to hold all your user's transactions.

If you need to overwrite the migrations that ship with LaravelYouCanPay, you can publish them using the vendor:publish Artisan command:

Configuration

To publish the config file you can use the command

then you can find the config file in config/youcanpay.php

Billable Model

If you want the package to manage the transactions based on the user model, add the Billable trait to your user model. This trait provides various methods to perform transaction tasks, such as creating a transaction, getting paid, failed and pending transactions.

LaravelYouCanPay assumes your user model will be App\Models\User, if you use a different user model namespace you should specify it using the method useCustomerModel method. This method should typically be called in the boot method of your AppServiceProvider class

If you need in each transaction the package uses the billing data for each user, make sure to include a getCustomerInfo() method in your user model, which returns an array that contains all the data we need.

YouCanPay Keys

Next, you should configure your environment in your application's .env

Customers

Retrieving Customers

You can retrieve a customer by their YouCanPay ID using the findBillable method. This method will return an instance of the billable model:

Generate Token

If you need to generate the token form the user model the cutomer info will be attached directly from getCustomerInfo method

If you need to add the metadata you can use

If you need to get the payment url as well from the user model you can use getPaymentURL method with the same parameters below.

Generate Payment URL

Usage

Before starting using the package make sure to update your config/youcanpay.php with the correct values provided by YouCanPay.

Tokenization

Get Token id

The first step we need is to create a token based on the credentails get it from YouCanPay dashboard using getId() method.

Note
The amount should be 100, Exemple if your Product price=20$ you should send
amount = 20
100 = 200 with currency='USD'

Get payment url

Standalone Integration, you can generate the payment url using the method getPaymentUrl()

Then you can put that url in your html page

Customer info

If you need to add the customer data during the tokenization, Please keep these array keys(name, address, zip_code, city, state, country_code, phone and email). you can use

Metadata

You can use the metadata to send data that can be retrieved after the response or in the webhook.

Generate Payment form

At this point we receive the token from our backend, so in our blade or any other html page, you can put at the head this script

Then to display the form your logic it's will be looks like the code below

To start the payment you need an action, you can use a button

For more information please check this link.

Handling YouCanPay Webhooks

YouCan Pay uses webhooks to notify your application when an event happens in your account. Webhooks are useful for handling reactions to asynchronous events on your backend, such as successful payments, failed payments, successful refunds, and many other real time events. A webhook enables YouCan Pay to push real-time notifications to your application by delivering JSON payloads over HTTPS.

Webhooks and CSRF Protection

YouCanPay webhooks need to reach your URI without any obstacle, so you need to disable CSRF protection for the webhook URI, to do that make sure to add your path to the exception array in your application's App\Http\Middleware\VerifyCsrfToken middleware.

Webhooks URL

To ensure your application can handle YouCanPay webhooks, be sure to configure the webhook URL in the YouCanPay control panel. By default the package comes with a webhook build-in using the URL youcanpay/webhook you can find it by listing all the routes in your app using php artisan route:list, This webhook validates the signature related to the payload received, and dispatches an event.

Webhooks Middleware

If you need to attempt the webhook signature validation before processing any action, you can use the middleware verify-youcanpay-webhook-signature, that validates the signature related to the payload received from YouCanPay.

Webhook Events

LaravelYouCanPay handles the common YouCanPay webhook events, if you need to handle the webhook events that you need you can listen to the event that is dispatched by the package.

You need to register a listener that can handle the event:

Once your listener has been defined, you may register it within your application's EventServiceProvider

Verify webhook signature Manually

The webhook data received from YouCanPay looks like

But the interesting part is in the header request you can find the signature value using the key x-youcanpay-signature.

To verify the webhook signature before processing any logic or action.

Validate webhook signature Manually

The validation has the same impact as the verification, but the validation throws an exception that you can inspect it in the log file.

Commands

If you need to clean the pending transactions, there's a command

You can add it to the scheduler that can run the command every single time, so the clean will be automatic and depend on the tolerance value that is defined in the youcanpay config file.

Testing and test cards

CARD CVV DATE BEHAVIOUR
4242 4242 4242 4242 112 10/24 No 3DS - Success
4000 0000 0000 3220 112 10/24 3DS - Success
4000 0084 0000 1629 112 10/24 3DS - Card Rejected
4000 0000 0000 0077 112 10/24 No 3DS - No Funds

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email imad@devinweb.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel YouCanPay Boilerplate

This package was generated using the Laravel YouCanPay Boilerplate.


All versions of laravel-youcan-pay with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
illuminate/support Version ^7.0|^8.0|^9.0|^10.0
laravel/framework Version 8.*|9.*|10.*
youcanpay/payment-sdk Version *
spatie/laravel-enum Version ^2.0|^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package devinweb/laravel-youcan-pay contains the following files

Loading the files please wait ....