-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,267 additions
and
1,157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,67 @@ | ||
|
||
# Direct Pay Online API Wrapper for PHP | ||
Unofficial PHP wrapper for [Direct Pay Online API](https://directpayonline.atlassian.net/wiki/spaces/API/overview) | ||
|
||
Inspired by [cy6erlion/direct-pay-online](https://github.com/cy6erlion/direct-pay-online) | ||
|
||
## Installation | ||
You can install via [Composer](https://getcomposer.org/). | ||
# Direct Pay Online API Wrapper for PHP | ||
Unofficial PHP wrapper for [Direct Pay Online API](https://directpayonline.atlassian.net/wiki/spaces/API/overview) | ||
Inspired by [cy6erlion/direct-pay-online](https://github.com/cy6erlion/direct-pay-online) | ||
## Installation | ||
You can install via [Composer](https://getcomposer.org/). | ||
|
||
composer require dipnot/direct-pay-online-php | ||
|
||
## Usage | ||
### createToken | ||
Create a token to start payment process. | ||
```php | ||
use Dipnot\DirectPayOnline; | ||
use Dipnot\Service; | ||
use Dipnot\Transaction; | ||
|
||
require_once("./../vendor/autoload.php"); | ||
|
||
$directPayOnline = new DirectPayOnline("9F416C11-127B-4DE2-AC7F-D5710E4C5E0A"); | ||
$transaction = new Transaction(100, "USD"); | ||
$service1 = new Service("Test Product", 3854, "2020/02/12 11:21"); | ||
$service2 = new Service("Test Service", 5525, "2020/02/12 11:21"); | ||
|
||
## Usage | ||
You can see the full example in [examples/index.php](https://github.com/dipnot/direct-pay-online-php/tree/main/examples/index.php). | ||
### Config | ||
All request are needs a Config. | ||
```php | ||
use Dipnot\DirectPayOnline\Config; | ||
|
||
$createToken = $directPayOnline->createToken( | ||
$transaction, | ||
[$service1, $service2] | ||
); | ||
|
||
print_r($createToken); // You can access the token with $createToken["TransToken"] | ||
``` | ||
|
||
### getPaymentLink | ||
Get the payment link with the created token to redirect the user to the payment page. | ||
```php | ||
... | ||
// You will get the payment URL | ||
$directPayOnline->getPaymentUrl($createToken["TransToken"]); | ||
... | ||
$config = new Config(); | ||
$config->setCompanyToken("9F416C11-127B-4DE2-AC7F-D5710E4C5E0A"); | ||
$config->setTestMode(true); | ||
``` | ||
### Transaction | ||
```php | ||
use Dipnot\DirectPayOnline\Model\Transaction; | ||
|
||
### Test mode | ||
You can use test API for testing purpose. Just pass `true` as second parameter. | ||
```php | ||
$directPayOnline = new DirectPayOnline("COMPANY_TOKEN", true); | ||
``` | ||
$transaction = new Transaction(100, "USD"); | ||
``` | ||
|
||
## Test values | ||
You can fill the personal info randomly in the payment page. | ||
### Service | ||
```php | ||
use Dipnot\DirectPayOnline\Model\Service; | ||
|
||
||Value| | ||
|--|--| | ||
|Company token|9F416C11-127B-4DE2-AC7F-D5710E4C5E0A| | ||
|Card number|5436886269848367| | ||
|Card expiry date (Month/Year)|12/22| | ||
|Card CVV|123| | ||
$service = new Service("Test Product", 3854, "2020/02/12 11:21"); | ||
``` | ||
### createToken Request | ||
Create a token to start payment process. | ||
```php | ||
use Dipnot\DirectPayOnline\Request\CreateTokenRequest; | ||
|
||
## License | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-%232fdcff)](https://github.com/dipnot/direct-pay-online-php/blob/main/LICENSE) | ||
$createTokenRequest = new CreateTokenRequest($config); | ||
$createTokenRequest->setTransaction($transaction); | ||
$createTokenRequest->setServices([$service1, $service2]); | ||
$createToken = $createTokenRequest->execute(); | ||
print_r($createToken); | ||
``` | ||
|
||
### getPaymentLink | ||
Get the payment link with the created token to redirect the user to the payment page. | ||
```php | ||
$paymentUrl = $createTokenRequest->getPaymentUrl($createToken["TransToken"]); | ||
print_r($paymentUrl); | ||
``` | ||
|
||
## Test values | ||
You can fill the personal info randomly in the payment page. | ||
|
||
||Value| | ||
|--|--| | ||
|Company token|9F416C11-127B-4DE2-AC7F-D5710E4C5E0A| | ||
|Card number|5436886269848367| | ||
|Card expiry date (Month/Year)|12/22| | ||
|Card CVV|123| | ||
|
||
## License | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-%232fdcff)](https://github.com/dipnot/direct-pay-online-php/blob/main/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
use Dipnot\DirectPayOnline\Config; | ||
use Dipnot\DirectPayOnline\Model\Service; | ||
use Dipnot\DirectPayOnline\Model\Transaction; | ||
use Dipnot\DirectPayOnline\Request\CreateTokenRequest; | ||
|
||
require_once("./../vendor/autoload.php"); | ||
|
||
// Config | ||
$config = new Config(); | ||
$config->setCompanyToken("9F416C11-127B-4DE2-AC7F-D5710E4C5E0A"); | ||
$config->setTestMode(true); | ||
|
||
// Transaction | ||
$transaction = new Transaction(100, "USD"); | ||
|
||
// Service | ||
$service1 = new Service("Test Product", 3854, "2020/02/12 11:21"); | ||
$service2 = new Service("Test Service", 5525, "2020/02/12 11:21"); | ||
|
||
// createToken Request | ||
$createTokenRequest = new CreateTokenRequest($config); | ||
$createTokenRequest->setTransaction($transaction); | ||
$createTokenRequest->setServices([$service1, $service2]); | ||
$createToken = $createTokenRequest->execute(); | ||
print_r($createToken); | ||
|
||
// Get payment URL with created token | ||
$paymentUrl = $createTokenRequest->getPaymentUrl($createToken["TransToken"]); | ||
print_r($paymentUrl); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
namespace Dipnot\DirectPayOnline; | ||
|
||
/** | ||
* Class Config | ||
* @package Dipnot\DirectPayOnline | ||
*/ | ||
class Config | ||
{ | ||
private $_companyToken; | ||
private $_testMode; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCompanyToken() | ||
{ | ||
return $this->_companyToken; | ||
} | ||
|
||
/** | ||
* @param string $companyToken | ||
*/ | ||
public function setCompanyToken($companyToken) | ||
{ | ||
$this->_companyToken = $companyToken; | ||
} | ||
|
||
/** | ||
* @return boolean | ||
*/ | ||
public function isTestMode() | ||
{ | ||
return $this->_testMode; | ||
} | ||
|
||
/** | ||
* @param boolean $testMode | ||
*/ | ||
public function setTestMode($testMode) | ||
{ | ||
$this->_testMode = $testMode; | ||
} | ||
} |
46 changes: 23 additions & 23 deletions
46
src/Dipnot/Curl.php → src/Dipnot/DirectPayOnline/Curl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
<?php | ||
namespace Dipnot; | ||
|
||
/** | ||
* Class Curl | ||
* @package Dipnot | ||
*/ | ||
class Curl | ||
{ | ||
/** | ||
* Creates and executes cURL | ||
* | ||
* @param string $url | ||
* @param array $options | ||
* | ||
* @return bool|string | ||
*/ | ||
function execute($url, $options) | ||
{ | ||
$curl = curl_init($url); | ||
curl_setopt_array($curl, $options); | ||
return curl_exec($curl); | ||
} | ||
<?php | ||
namespace Dipnot\DirectPayOnline; | ||
|
||
/** | ||
* Class Curl | ||
* @package Dipnot\DirectPayOnline | ||
*/ | ||
class Curl | ||
{ | ||
/** | ||
* Creates and executes cURL | ||
* | ||
* @param string $url | ||
* @param array $options | ||
* | ||
* @return bool|string | ||
*/ | ||
function execute($url, $options) | ||
{ | ||
$curl = curl_init($url); | ||
curl_setopt_array($curl, $options); | ||
return curl_exec($curl); | ||
} | ||
} |
Oops, something went wrong.