PHPackages                             samir-hussein/2checkout - 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. samir-hussein/2checkout

ActiveLibrary[Payment Processing](/categories/payments)

samir-hussein/2checkout
=======================

2checkout payment gateway

1.0(5y ago)1111MITPHP

Since Feb 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/samir-hussein/2checkout)[ Packagist](https://packagist.org/packages/samir-hussein/2checkout)[ RSS](/packages/samir-hussein-2checkout/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

2checkout
=========

[](#2checkout)

2checkout payment gateway

Installation
------------

[](#installation)

```
composer require samir-hussein/2checkout
```

Usage in php native
-------------------

[](#usage-in-php-native)

###### Step 1 : create token create index.php file like this

[](#step-1--create-token-create-indexphp-file-like-this)

```
>

    Document

                Card Number

                Cardplaceholder Name

                Expiration Date (MM/YYYY)

             /

                CVC

        // Called when token created successfully.
        var successCallback = function(data) {
            var myForm = document.getElementById('myCCForm');

            // Set the token as the value for the token input
            myForm.token.value = data.response.token.token;

            // IMPORTANT: Here we call `submit()` on the form element directly instead of using jQuery to prevent and infinite token request loop.
            myForm.submit();
        };

        // Called when token creation fails.
        var errorCallback = function(data) {
            if (data.errorCode === 200) {
                tokenRequest();
            } else {
                alert(data.errorMsg);
            }
        };

        var tokenRequest = function() {
            // Setup token request arguments
            var args = {
                sellerId: "your_merchantCode",
                publishableKey: "your_publishableKey",
                ccNo: $("#ccNo").val(),
                cvv: $("#cvv").val(),
                expMonth: $("#expMonth").val(),
                expYear: $("#expYear").val()
            };

            // Make the token request
            TCO.requestToken(successCallback, errorCallback, args);
        };

        $(function() {
            // Pull in the public encryption key for our environment
            TCO.loadPubKey();

            $("#myCCForm").submit(function(e) {
                // Call our token request function
                tokenRequest();

                // Prevent form from submitting
                return false;
            });
        });

```

###### Step 2 : create payment.php file like this

[](#step-2--create-paymentphp-file-like-this)

```
