Skip to content

Commit

Permalink
Merge pull request #26 from AltaPay/support-agrement-engine
Browse files Browse the repository at this point in the history
Add support for new 'Agreements Engine' parameters
  • Loading branch information
emicha authored Oct 20, 2022
2 parents e2c2bc6 + 84aca8c commit f38e4f9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.2.7] - 2022-10-04
### Added
- Add support for new 'Agreements Engine' parameters

## [3.2.6] - 2022-08-22
### Fixes
- Add Api authentication classes
Expand Down
13 changes: 12 additions & 1 deletion src/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract class AbstractApi
/**
* PHP API version
*/
const PHP_API_VERSION = '3.2.6';
const PHP_API_VERSION = '3.2.7';

/**
* Event dispatcher
Expand Down Expand Up @@ -217,6 +217,7 @@ protected function doConfigureOptions()
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$this->setTransactionResolver($resolver);
$this->setAgreementResolver($resolver);
$this->setOrderLinesResolver($resolver);
$this->setAmountResolver($resolver);
$this->setTerminalResolver($resolver);
Expand Down Expand Up @@ -395,6 +396,16 @@ protected function setTransactionResolver(OptionsResolver $resolver)
{
}

/**
* Resolve agreement info option
*
* @param OptionsResolver $resolver
*
* @return void
*/
protected function setAgreementResolver(OptionsResolver $resolver)
{
}
/**
* Resolve orderlines
*
Expand Down
14 changes: 13 additions & 1 deletion src/Api/Ecommerce/PaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PaymentRequest extends AbstractApi
use Traits\TransactionInfoTrait;
use Traits\CustomerInfoTrait;
use Traits\OrderlinesTrait;

use Traits\AgreementTrait;
/**
* The language of the payment form
*
Expand Down Expand Up @@ -74,7 +74,18 @@ public function setType($type)

return $this;
}

/**
* @param string $agreement
*
* @return $this
*/
public function setAgreement($agreement)
{
$this->unresolvedOptions['agreement'] = $agreement;

return $this;
}
/**
* Use the credit_card_token from a previous payment to allow your customer to buy with the same credit card again
*
Expand Down Expand Up @@ -258,6 +269,7 @@ protected function configureOptions(OptionsResolver $resolver)
'language',
'transaction_info',
'type',
'agreement',
'ccToken',
'sale_reconciliation_identifier',
'sale_invoice_number',
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Payments/Credit.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function configureOptions(OptionsResolver $resolver)
$resolver->setRequired(['terminal', 'shop_orderid', 'amount', 'currency']);

$resolver->setDefined([
'transaction_info', 'payment_source', 'credit_card_token',
'transaction_info', 'agreement', 'payment_source', 'credit_card_token',
'cardnum', 'emonth', 'eyear', 'cvc'
]);

Expand Down
1 change: 1 addition & 0 deletions src/Api/Payments/ReservationOfFixedAmount.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ protected function configureOptions(OptionsResolver $resolver)
'cvc',
'credit_card_token',
'transaction_info',
'agreement',
'fraud_service',
'surcharge',
'customer_info',
Expand Down
56 changes: 56 additions & 0 deletions src/Traits/AgreementTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* Copyright (c) 2016 Martin Aarhof
*
* 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.
*/

namespace Altapay\Traits;

use Symfony\Component\OptionsResolver\OptionsResolver;

trait AgreementTrait
{
/**
* This is a one-dimensional associative array.
* This is where you put any value that you would like to bind to the payment.
*
* @param array<int, string> $agreement
*
* @return $this
*/
public function setAgreement(array $agreement)
{
$this->unresolvedOptions['agreement'] = $agreement;
return $this;
}

/**
* Resolve agreement info option
*
* @param OptionsResolver $resolver
*
* @return void
*/
public function setAgreementResolver(OptionsResolver $resolver)
{
$resolver->setAllowedTypes('agreement', 'array');
}
}

0 comments on commit f38e4f9

Please sign in to comment.