Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
asrorbekh committed Jan 12, 2024
0 parents commit 7317a62
Show file tree
Hide file tree
Showing 8 changed files with 1,055 additions and 0 deletions.
105 changes: 105 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
### PHPUnit template
# Covers PHPUnit
# Reference: https://phpunit.de/

# Generated files
.phpunit.result.cache
.phpunit.cache

# PHPUnit
/app/phpunit.xml
/phpunit.xml

# Build data
/build/

### Example user template template
### Example user template

# IntelliJ project files
.idea
*.iml
out
gen
### PhpStorm template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

# root
*.lock
vendor
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Asrorbek Sultanov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# CloudPayments PHP Client

This PHP library provides a convenient interface for interacting with the CloudPayments API. The CloudPayments API operates at `api.cloudpayments.ru` and supports various functions for payment processing, including making a payment, canceling a payment, returning money, completing payments made using a two-stage scheme, creating and canceling subscriptions for recurring payments, as well as sending invoices by mail.

## Principle of Operation

Parameters are passed using the POST method in the body of the request in either the "key=value" format or in JSON. The API can accept a maximum of 150,000 fields in a single request, and the timeout for receiving a response from the API is set to 5 minutes. It's important to note that if a number with a fractional part is passed into an integer field, mathematical rounding will occur without triggering an error.

The API enforces limits on the maximum number of simultaneous requests for test terminals (5) and combat terminals (30). If the number of requests to the site currently being processed exceeds the limit, the API will return a response with HTTP code 429 (Too Many Requests) until processing is completed. For a review of these restrictions, contact your personal manager.

The choice of parameter transfer format is determined on the client side and is controlled through the `Content-Type` request header:
- For `key=value` parameters: `Content-Type: application/x-www-form-urlencoded`
- For JSON parameters: `Content-Type: application/json`

The system issues a response in JSON format, including at least two parameters: `Success` and `Message`:

```json
{
"Success": false,
"Message": "Invalid Amount value"
}
```

### Request Authentication

To authenticate the request, HTTP Basic Auth is used. The login and password are sent in the HTTP request header. The Public ID serves as the login, and the API Secret serves as the password. Both values can be obtained in your personal account. If a header with authentication data is not sent in the request or incorrect data is provided, the system will return HTTP status 401 – Unauthorized. It's crucial to securely store the API secret.

### Requires

- php ^8.1

```bash
composer require asrorbek/cloudpayments-php-client
```

## Example usage

```php
<?php

use CloudPaymentsSDK\Client\CloudPayments;

require_once __DIR__ . '/vendor/autoload.php';

// .ru - CloudPayments::CLOUD_PAYMENTS_RU_URL
// .uz - CloudPayments::CLOUD_PAYMENTS_UZ_URL

$cloudPayments = new CloudPayments(publicKey: 'your_public_key', apiSecret: 'your_api_secret', apiUrl: CloudPayments::CLOUD_PAYMENTS_RU_URL, enableSSL: true);

$response = $cloudPayments->sendTestRequest(array(
'Name' => 'Foo Baz',
));

print_r($response);


// Process the response as needed

```

- Replace 'your_public_key' and 'your_api_secret' with the actual Public ID and API Secret obtained from your personal account.
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "asrorbek/cloudpayments-php-client",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Asrorbek Sultanov",
"email": "asrorbek0325@gmail.com"
}
],
"require": {
"php": "^8.1",
"php-curl-class/php-curl-class": "^9.18",
"ext-curl": "*"
},
"autoload": {
"psr-4": {
"CloudPaymentsSDK\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"CloudPaymentsSDK\\Tests\\": "tests/"
}
},
"require-dev": {
"phpunit/phpunit": "^10.5"
}
}
Loading

0 comments on commit 7317a62

Please sign in to comment.