Skip to content

Commit

Permalink
1.24.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dyd committed Jan 16, 2024
1 parent 02e28ee commit 8fae1c4
Show file tree
Hide file tree
Showing 59 changed files with 1,192 additions and 176 deletions.
3 changes: 3 additions & 0 deletions .phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@
</rule>

<rule ref="rulesets/unusedcode.xml" />

<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/spec/*</exclude-pattern>
</ruleset>
26 changes: 26 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
1.24.2
-----
**Features**:

* Updated Paysafecard transaction type via Web Payment Form with customer_id required parameter
* Improved project README with Web Payment Form transaction request example
* Added Representment Reversed state handling
* Added Payment Account (P) support for Bank Account Type via Online Banking Payout
* Added Return Pending URL support to Sepa Direct Debit Sale (SDD Sale)
* Added Account Owner parameters support to the following transaction requests:
* Authorize
* Authorize 3D
* Credit (Credit Fund Transfer)
* Sale
* Sale 3D
* Payout
* Init Recurring Sale
* Init Recurring Sale 3D
* Web Payment Form
* Added applicationData and wrappedKey parameters support to the Apple Pay token
* Added Smart Router support

**Fixes**:

* Fixed Online Banking Payout validations for BRL currency

1.24.1
-----
**Features**:
Expand Down
147 changes: 144 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ git clone http://github.com/GenesisGateway/genesis_php genesis_php && cd genesis
Getting Started
------------------

### Transactions

```php
<?php
require 'vendor/autoload.php';

try {
// Load the pre-configured ini file...
\Genesis\Config::loadSettings('/path/to/config.ini');

Expand All @@ -78,15 +81,18 @@ $genesis
->setRemoteIp('245.253.2.12')
->setAmount('50')
->setCurrency('USD')

// Customer Details
->setCustomerEmail('emil@example.com')
->setCustomerEmail('travis@example.com')
->setCustomerPhone('1987987987987')

// Credit Card Details
->setCardHolder('Emil Example')
->setCardHolder('Travis Pastrana')
->setCardNumber('4200000000000000')
->setExpirationMonth('01')
->setExpirationYear('2020')
->setCvv('123')

// Billing/Invoice Details
->setBillingFirstName('Travis')
->setBillingLastName('Pastrana')
Expand All @@ -96,7 +102,6 @@ $genesis
->setBillingState('CA')
->setBillingCountry('US');

try {
// Send the request
$genesis->execute();

Expand All @@ -113,17 +118,153 @@ catch (\Genesis\Exceptions\ErrorAPI $api) {
catch (\Genesis\Exceptions\ErrorParameter $parameter) {
error_log($parameter->getMessage());
}
// Log/handle invalid arguments
// Example: invalid value given for accessor
catch (\Genesis\Exceptions\InvalidArgument $parameter) {
error_log($parameter->getMessage());
}
// Log/handle network (transport) errors
// Example: SSL verification errors, Timeouts
catch (\Genesis\Exceptions\ErrorNetwork $network) {
error_log($network->getMessage());
}
// Upon invalid accessor is used
catch (\Genesis\Exceptions\InvalidMethod $error) {
error_log($error->getMessage());
}

?>
```

Note: the file ```vendor/autoload.php``` is located inside the directory where you cloned the repo and it is auto-generated by [Composer]. If the file is missing, just run ```php composer.phar update``` inside the root directory

### Web Payment Form

```php
<?php
require 'vendor/autoload.php';

try {
// Load the pre-configured ini file...
\Genesis\Config::loadSettings('/path/to/config.ini');

// ...OR, optionally, you can set the credentials manually
\Genesis\Config::setEndpoint(\Genesis\API\Constants\Endpoints::EMERCHANTPAY);
\Genesis\Config::setEnvironment(\Genesis\API\Constants\Environments::STAGING);
\Genesis\Config::setUsername('<enter_your_username>');
\Genesis\Config::setPassword('<enter_your_password>');

// Create a new Genesis instance with Web Payment Form transaction request
/** @var \Genesis\Genesis $genesis */
$genesis = new Genesis('WPF\Create');

// Assign $request variable. In some editors, auto-completion will guide you with the request building
/** @var \Genesis\API\Request\WPF\Create $request */
$request = $genesis->request();

// Set request parameters
$request
->setTransactionId('43671')
->setUsage('40208 concert tickets')
->setDescription('You are buying concert tickets!')
->setAmount('50')
->setCurrency('USD')

// Notification parameters
->setNotificationUrl('https://www.example.com/notification')

// Asynchronous parameters
->setReturnSuccessUrl('http://www.example.com/success')
->setReturnFailureUrl('http://www.example.com/failure')
->setReturnCancelUrl('http://www.example.com/cancel')
->setReturnPendingUrl('http://www.example.com/pending')

// Customer Details
->setCustomerEmail('travis@example.com')
->setCustomerPhone('1987987987987')

// Billing/Invoice Details
->setBillingFirstName('Travis')
->setBillingLastName('Pastrana')
->setBillingAddress1('Muster Str. 12')
->setBillingZipCode('10178')
->setBillingCity('Los Angeles')
->setBillingState('CA')
->setBillingCountry('US')

// Web Payment Form language, default is EN if no language is provided
->setLanguage(\Genesis\API\Constants\i18n::EN)

// Set the Web Payment Form time to live, default value 30 minutes if no value is provided
->setLifetime(30)

// Transaction Type without Custom Attribute
->addTransactionType(\Genesis\API\Constants\Transaction\Types::SALE_3D)
->addTransactionType(\Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D)

// Transaction Type with Custom Attribute
->addTransactionType(\Genesis\API\Constants\Transaction\Types::PAYSAFECARD, ['customer_id' => '123456']);

// Send the request
$genesis->execute();

// Successfully completed the transaction - redirect the customer to the provided URL
echo $genesis->response()->getResponseObject()->redirect_url;
}
// Log/handle API errors
// Example: Invalid data, Invalid configuration
catch (\Genesis\Exceptions\ErrorAPI $api) {
error_log($api->getMessage());
}
// Log/handle invalid parameters
// Example: Empty (required) parameter
catch (\Genesis\Exceptions\ErrorParameter $parameter) {
error_log($parameter->getMessage());
}
// Log/handle invalid arguments
// Example: invalid value given for accessor
catch (\Genesis\Exceptions\InvalidArgument $parameter) {
error_log($parameter->getMessage());
}
// Log/handle network (transport) errors
// Example: SSL verification errors, Timeouts
catch (\Genesis\Exceptions\ErrorNetwork $network) {
error_log($network->getMessage());
}
// Upon invalid accessor is used
catch (\Genesis\Exceptions\InvalidMethod $error) {
error_log($error->getMessage());
}

?>
```

Full list with the available Custom Attributes for every Transaction Type can be found [here](https://emerchantpay.github.io/gateway-api-docs/#wpf-transaction-types).

Smart Router
-------------

The Smart Routing API is a higher-level abstraction that allows for simpler and more efficient gateway Processing API integration.
It does not require the terminal token. This by itself minimizes the need for complex customer-level manual routing to terminals set up on the gateway platform configuration layer.

By default the Smart Router is disabled. Contact your account manager to use the functionality.

Smart Router global definition for all requests
* PHP Config File
```php
\Genesis\Config::setForceSmartRouting(true);
```
* Ini Config File
```ini
[Genesis]
force_smart_routing = on
```

Smart Router definition per request
```php
$genesis->request()->setUseSmartRouter(true);
```

Example 3DSv2 Request
-------------
Sample request including all the conditionally required/optional params for initiating a 3DS transaction with the 3DSv2-Method authentication protocol.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.24.1
1.24.2
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "genesisgateway/genesis_php",
"description": "PHP Client for Genesis Payment Processing Gateway",
"version": "1.24.1",
"version": "1.24.2",
"license": "MIT",
"keywords": [
"3ds_v2",
Expand Down
17 changes: 10 additions & 7 deletions settings_sample.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[Genesis]
# Setup
environment = sandbox
endpoint = ENTER_YOUR_ENDPOINT
environment = sandbox
endpoint = ENTER_YOUR_ENDPOINT

# Credentials
username = ENTER_YOUR_USERNAME
password = ENTER_YOUR_PASSWORD
username = ENTER_YOUR_USERNAME
password = ENTER_YOUR_PASSWORD
# Optional for WPF requests
token = ENTER_YOUR_TOKEN
token = ENTER_YOUR_TOKEN
# Smart Router endpoint for Financial Transactions
# Doesn't require token
force_smart_routing = off

[Interfaces]
# Options:
# - xml
# - json
builder = xml
builder = xml
# Options:
# - curl
# - stream
network = curl
network = curl
7 changes: 7 additions & 0 deletions spec/Genesis/API/Constants/Transaction/StatesSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ public function it_should_have_magic_is_represented()
$this->{$this->buildMethod(States::REPRESENTED)}()->shouldBe(true);
}

public function it_should_have_magic_is_representment_reversed()
{
$this->beConstructedWith(States::REPRESENTMENT_REVERSED);

$this->{$this->buildMethod(States::REPRESENTMENT_REVERSED)}()->shouldBe(true);
}

public function it_should_compare_properly_statuses()
{
$this->beConstructedWith(States::NEW_STATUS);
Expand Down
93 changes: 93 additions & 0 deletions spec/Genesis/API/Request/Base/FinancialSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace spec\Genesis\API\Request\Base;

use Genesis\API\Constants\Endpoints;
use Genesis\API\Constants\Environments;
use Genesis\Config;
use spec\Genesis\API\Stubs\Base\Request\FinancialStub;
use spec\SharedExamples\Faker;

class FinancialSpec extends \PhpSpec\ObjectBehavior
{
private $faker_uuid;

private $faker_usage;

private $faker_remote_ip;

public function __construct()
{
$this->faker_uuid = Faker::getInstance()->uuid;
$this->faker_usage = Faker::getInstance()->sentence;
$this->faker_remote_ip = Faker::getInstance()->ipv4;
}

public function let()
{
$this->beAnInstanceOf(FinancialStub::class);
}

public function it_when_use_smart_routing_with_getter()
{
$this->getUseSmartRouter()->shouldBe(false);
}

public function it_should_not_throw_when_use_smart_routing_with_setter()
{
$this->shouldNotThrow()->during('setUseSmartRouter', [true]);
}

public function it_when_use_smart_routing_with_proper_return_value()
{
$this->setUseSmartRouter(true)->shouldBe($this);
}

public function it_when_use_smart_routing_with_proper_setter()
{
$this->setUseSmartRouter('on');

$this->getUseSmartRouter()->shouldBe(true);
}

public function it_should_init_proper_xml_configuration_without_smart_router()
{
Config::setToken($this->faker_uuid);
Config::setEndpoint(Endpoints::EMERCHANTPAY);

$this->getDocument();

$this->getApiConfig('url')->shouldBe(
"https://staging.gate.emerchantpay.net:443/process/{$this->faker_uuid}/"
);
}

public function it_should_init_proper_xml_configuration_with_smart_router()
{
Config::setToken(Faker::getInstance()->uuid);
Config::setEndpoint(Endpoints::EMERCHANTPAY);
$this->setUseSmartRouter(true);

$this->getDocument();

$this->getApiConfig('url')->shouldBe("https://staging.api.emerchantpay.net:443/transactions");
}

public function it_should_populate_proper_base_financial_structure()
{
$this->setTransactionId($this->faker_uuid);
$this->setUsage($this->faker_usage);
$this->setRemoteIp($this->faker_remote_ip);

$this->getDocument()->shouldContain('<payment_transaction>');
$this->getDocument()->shouldContain('<transaction_type>transaction_type</transaction_type>');
$this->getDocument()->shouldContain("<transaction_id>{$this->faker_uuid}</transaction_id>");
$this->getDocument()->shouldContain("<usage>{$this->faker_usage}</usage>");
$this->getDocument()->shouldContain("<remote_ip>{$this->faker_remote_ip}</remote_ip>");
}

public function it_should_populate_proper_transaction_structure()
{
$this->getDocument()->shouldContain('<stub>financial</stub>');
}
}
Loading

0 comments on commit 8fae1c4

Please sign in to comment.