PHPackages                             paymentsws/php-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. paymentsws/php-sdk

ActiveLibrary[Payment Processing](/categories/payments)

paymentsws/php-sdk
==================

PaymentsWs PHP-SDK client

08.8k[2 PRs](https://github.com/paymentsws/php-sdk/pulls)PHPCI failing

Since Sep 25Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/paymentsws/php-sdk)[ Packagist](https://packagist.org/packages/paymentsws/php-sdk)[ RSS](/packages/paymentsws-php-sdk/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (3)Used By (0)

PaymentsWs PHP-SDK
==================

[](#paymentsws-php-sdk)

> Official PHP bindings to the PaymentsWs API

SDK Documentation
=================

[](#sdk-documentation)

Introduction
------------

[](#introduction)

Every request happening on our systems are going to return an operationId which represents that the operation has been processed and logged into our systems, you will be able to track each request from our back-office portal.

Requirements
------------

[](#requirements)

- A valid PaymentsWs APIKey provided by our service.
- PHP &gt;= 5.6

Getting Stared
--------------

[](#getting-stared)

Import the PaymentsWs PHP-SDK to your codebase.

Following you will find some examples to integrate your system with PaymentsWs. Additionally you can take a look to the examples provided on the /examples folder of this SDK.

#### Initialize the core PaymentsWs SDK

[](#initialize-the-core-paymentsws-sdk)

Currently PaymentsWsClient object supports 2 different modes:

- Sandbox Mode (To be used when integrating or doing tests) (Sandbox Mode will be used by default if none informed)
- Live Mode (To be used when going live for production)

> To enable Sandbox mode manually initialize PaymentsWsClient with the following parameters:

```
  new PaymentswsClient("YOUR_API_KEY", PaymentswsClientModes::SANDBOX);
```

> To enable Live mode (Production) initialize PaymentsWsClient with the following parameters:

```
  new PaymentswsClient("YOUR_API_KEY", PaymentswsClientModes::LIVE);
```

##### Code Snippet

[](#code-snippet)

```
use PaymentsWs\PaymentswsClient;
use PaymentsWs\PaymentswsClientModes;
use PaymentsWs\TokenService;

$PaymentsWsClient = new PaymentswsClient("YOUR_API_KEY", PaymentswsClientModes::SANDBOX);
$tokenService = new TokenService($PaymentsWsClient);
```

#### Generate a basic tokenization on SandBox environment ($tokenService-&gt;tokenize)

[](#generate-a-basic-tokenization-on-sandbox-environment-tokenservice-tokenize)

This method will tokenize sensible data into PaymentsWs servers.

Tokenize method accepts any kind of data (Integers, Strings, Objects, Arrays, etc).

##### Code Snippet

[](#code-snippet-1)

```
$importantData = [
    'pan' => '4100123412341234',
    'expirationDate' => '12/22',
    'cardHolder' => 'John Doe',
];
$tokenResult = $tokenService->tokenize($importantData);
print_r($tokenResult);

// ----------------------------------------------
// Print $tokenResult example
// ----------------------------------------------
// stdClass Object
// (
//    [statusCode] => 201
//    [message] => success
//    [operationId] => aad8d262-2537-4c8d-a687-95d2928ad67f
//    [items] => stdClass Object
//        (
//            [token] => 317f16a3-1049-44f5-94e2-e9979a7a7322
//        )
//
//)
```

#### Get the data stored by a token ($tokenService-&gt;detokenize)

[](#get-the-data-stored-by-a-token-tokenservice-detokenize)

This method does a request to our system to get the data stored by a given token. A valid and existing token should be passed.

> If a bad formatted token is passed: HTTP 400 Bad Request Error will be returned.

> If the token is valid but not found in our systems: HTTP 404 error will be returned.

##### Code Snippet

[](#code-snippet-2)

```
$result = $tokenService->detokenize("317f16a3-1049-44f5-94e2-e9979a7a7322");
print_r($result);

// ----------------------------------------------
// Print $result example
// ----------------------------------------------
// stdClass Object
// (
//     [statusCode] => 200
//     [message] => success
//     [operationId] => 9b466ce8-1c16-4e13-8871-0a07a2be78ba
//     [items] => stdClass Object
//         (
//             [data] => stdClass Object
//                 (
//                     [pan] => 4100123412341234
//                     [expirationDate] => 12/22
//                     [cardHolder] => John Doe
//                 )
//
//         )
//
// )
```

#### Validate a token ($tokenService-&gt;validate)

[](#validate-a-token-tokenservice-validate)

This method allows the client to know whether a token is in our system or not.

> If the token is valid and found in our systems: HTTP 200 OK will be returned with the data field valid = 1.

> If a bad formatted token is passed: HTTP 400 Bad Request Error will be returned.

##### Code Snippet

[](#code-snippet-3)

```
$result = $tokenService->validate("317f16a3-1049-44f5-94e2-e9979a7a7322");
print_r($result);

// ----------------------------------------------
// Print $result example
// ----------------------------------------------
// stdClass Object
// (
//     [statusCode] => 200
//     [message] => success
//     [operationId] => 55889f50-eff8-4536-888a-6beaeec4c36c
//     [items] => stdClass Object
//         (
//             [valid] => 1
//         )
//
// )
```

#### Delete a token ($tokenService-&gt;delete)

[](#delete-a-token-tokenservice-delete)

This method does a request to our system for a token deletion.

> If the token is valid and found in our systems: HTTP 200 OK will be returned with delete field = 1.

> If a bad formatted token is passed: HTTP 400 Bad Request Error will be returned.

##### Code Snippet

[](#code-snippet-4)

```
$result = $tokenService->delete("317f16a3-1049-44f5-94e2-e9979a7a7322");
print_r($result);

// ----------------------------------------------
// Print $result example
// ----------------------------------------------
// stdClass Object
// (
//     [statusCode] => 200
//     [message] => success
//     [operationId] => e9235437-4517-4140-a419-5ba83f7b71ad
//     [items] => stdClass Object
//         (
//             [deleted] => 1
//         )
//
// )
```

Exceptions
----------

[](#exceptions)

All exception should be handle by statusCode present at failed responses:

##### Code Snippet

[](#code-snippet-5)

```
// stdClass Object
// (
//     [statusCode] => 404
//     [error] => Not Found
//     [message] => Cannot PUT /v1/tokens//validate
// )
```

---

PaymentsWs (c) 2020

###  Health Score

23

—

LowBetter than 25% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3236015?v=4)[Yandy Marrero Morales](/maintainers/fenrirdrk)[@fenrirdrk](https://github.com/fenrirdrk)

---

Top Contributors

[![fenrirdrk](https://avatars.githubusercontent.com/u/3236015?v=4)](https://github.com/fenrirdrk "fenrirdrk (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![emiliojoel](https://avatars.githubusercontent.com/u/3436741?v=4)](https://github.com/emiliojoel "emiliojoel (2 commits)")

### Embed Badge

![Health badge](/badges/paymentsws-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/paymentsws-php-sdk/health.svg)](https://phpackages.com/packages/paymentsws-php-sdk)
```

###  Alternatives

[pagseguro/php

Biblioteca de integração com o PagSeguro

23260.3k6](/packages/pagseguro-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
