PHPackages                             youcanpay/payment-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. youcanpay/payment-sdk

ActiveLibrary[Payment Processing](/categories/payments)

youcanpay/payment-sdk
=====================

YouCan Pay SDK

v0.1.23(2y ago)3244.3k↓13.3%8[7 issues](https://github.com/youcan-shop/youcan-payment-php-sdk/issues)[1 PRs](https://github.com/youcan-shop/youcan-payment-php-sdk/pulls)1MITPHP

Since Sep 30Pushed 2y ago11 watchersCompare

[ Source](https://github.com/youcan-shop/youcan-payment-php-sdk)[ Packagist](https://packagist.org/packages/youcanpay/payment-sdk)[ RSS](/packages/youcanpay-payment-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (26)Used By (1)

[![](https://camo.githubusercontent.com/eed427ff696192c0e7c87ac505bf684020f73c190748c92807707bc86867185f/68747470733a2f2f796f7563616e7061792e636f6d2f696d616765732f79637061792d6c6f676f2e737667)](https://youcanpay.com)

[![Tests](https://github.com/NextmediaMa/youcan-payment-php-sdk/actions/workflows/tests.yml/badge.svg)](https://youcanpay.com)[![Total Downloads](https://camo.githubusercontent.com/bbb6ec942b84b05bf1b8737cd8b525c41cfa32302fa472ca83abf10321a6eb99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796f7563616e7061792f7061796d656e742d73646b)](https://packagist.org/packages/youcanpay/payment-sdk)[![Latest Version](https://camo.githubusercontent.com/d0d306cbefdc2c3a34fc09e05382dee365892cbd1789053ed4da4ca4ee3102cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796f7563616e7061792f7061796d656e742d73646b)](https://packagist.org/packages/youcanpay/payment-sdk)[![License](https://camo.githubusercontent.com/1ebd4bfd4b9e4d63b46bbbe1e6ae5031e7a804f4ae7fc5b43fb2eb702bf7fadf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f796f7563616e7061792f7061796d656e742d73646b)](https://packagist.org/packages/youcanpay/payment-sdk)

This package allows the developer to interact easily with the [YouCan Pay API](https://youcanpay.com/docs).

This documentation is separated in two integrations: **Default Integration** and the **Standalone Integration**. you have the choice to do one integration or both integrations in your checkout page.

YouCan Pay SDK Setup
--------------------

[](#youcan-pay-sdk-setup)

Instructions for adding the YouCan Pay SDK to your PHP Applications.

### Step 1. Requirements

[](#step-1-requirements)

- YouCan Pay Account.
- Your YouCan Pay `private_key` and `public_key` available in Settings &gt; API Keys.
- Visual Studio Code or Sublime Text or any IDE.
- Website with SSL, required only if you want to use the **default mode** for your payments.
- Composer installed in your development environment.

### Step 2. Add YouCan Pay SDK

[](#step-2-add-youcan-pay-sdk)

Open your PHP project, add the following.

- Run this command to download and include YouCan Pay PHP SDK in your project. If you can't install composer, you can manually download the SDK from GitHub `https://github.com/NextmediaMa/youcan-payment-php-sdk/archive/refs/heads/master.zip`.

```
composer require youcanpay/payment-sdk
```

### Step 2.1 YouCan Pay: Default Integration

[](#step-21-youcan-pay-default-integration)

The following is a quick guide to get up and started with YouCan Pay JS integration, you can view the full documentation by following [this link](https://youcanpay.com/docs).

You can make payments directly on your site, with the possibility of choosing the position in the DOM.

If you choose to use JS integration, you must have an SSL certificate to run in production mode.

2.1.1: Copy this JS script between `...`

```

```

2.1.2: Choose where you want to display payment information (Full Name, Card Numbers, CCV...), must be placed between the `...` tags.

```

Pay
```

2.1.3: Add this code just before the end of the `...` tag.

```

  // Create a YouCan Pay instance.
  const ycPay = new YCPay(
    // String public_key (required): Login to your account.
    // Go to Settings and open API Keys and copy your key.
    "public_key",
    // Optional options object
    {
      formContainer: "#payment-card",
      // Defines what language the form should be rendered in, supports EN, AR, FR.
      locale: "en",

      // Whether the integration should run in sandbox (test) mode or live mode.
      isSandbox: false,

      // A DOM selector representing which component errors should be injected into.
      // If you omit this option, you may alternatively handle errors by chaining a .catch()
      // On the pay method.
      errorContainer: "#error-container",
    }
  );

  // Select which gateways to render
  ycPay.renderAvailableGateways(["CashPlus", "CreditCard"]);

  // Alternatively, you may use gateway specific render methods if you only need one.
  ycPay.renderCreditCardForm();

```

2.1.4: Tokenization step: this token contains all the order information.

```
