diff --git a/CHANGELOG.md b/CHANGELOG.md index 61a3e90..62ff17d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.3.5] - 2023-05-23 +### Fixes +- Add option to use `transaction_info` and `orderLines` for `ChargeSubscription` + ## [3.3.4] - 2023-05-12 ### Fixes - Add missing setters for the Address class diff --git a/docs/request/orderline.md b/docs/request/orderline.md index 0d3f431..cea9d14 100644 --- a/docs/request/orderline.md +++ b/docs/request/orderline.md @@ -1,4 +1,4 @@ -[<](../index.md) Altapay - PHP Api - Customer Info +[<](../index.md) Altapay - PHP Api - Order line ================================================== A order line object requries diff --git a/docs/subscription/charge_subscription.md b/docs/subscription/charge_subscription.md index 4f1cef3..9927575 100644 --- a/docs/subscription/charge_subscription.md +++ b/docs/subscription/charge_subscription.md @@ -1,2 +1,56 @@ [<](../index.md) Altapay - PHP Api - Charge subscription ===================================================== + +Use the chargeSubscription method to capture a single occurrence of a recurring payment, for example a monthly subscription payment. + +- [Request](#request) + + [Required](#required) + + [Optional](#optional) + + [Example](#example) +- [Response](#response) + +# Request + +```php +$request = new \Altapay\Api\Subscription\ChargeSubscription($auth); +// Do the call +try { + $response = $request->call(); + // See Response below +} catch (\Altapay\Exceptions\ClientException $e) { + // Could not connect +} catch (\Altapay\Exceptions\ResponseHeaderException $e) { + // Response error in header + $e->getHeader()->ErrorMessage +} catch (\Altapay\Exceptions\ResponseMessageException $e) { + // Error message + $e->getMessage(); +} +``` + +### Required + +| Method | Description | Type | +|---|---|---| +| setTransaction(string) | The id of the setup agreement transaction. | + +### Optional + +| Method | Description | Type | +|---|---|---| +| setAmount(float) | The amount to capture. | float| +| setTransactionInfo(array) | This is a one-dimensional associative array. This is where you put any value that you would like to bind to the payment. | array +| setOrderLines(array or OrderLine) | Order lines | array of OrderLine objects - [See OrderLine](../request/orderline.md) + +### Example + +```php +$request = new \Altapay\Api\Subscription\ChargeSubscription($auth); +$request->setTransaction('12345678'); +``` + +# Response + +``` +$response = $request->call(); +``` diff --git a/src/AbstractApi.php b/src/AbstractApi.php index 5604437..ffbd12c 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -52,7 +52,7 @@ abstract class AbstractApi /** * PHP API version */ - const PHP_API_VERSION = '3.3.4'; + const PHP_API_VERSION = '3.3.5'; /** * Event dispatcher diff --git a/src/Api/Subscription/ChargeSubscription.php b/src/Api/Subscription/ChargeSubscription.php index 6695623..52ce9cf 100644 --- a/src/Api/Subscription/ChargeSubscription.php +++ b/src/Api/Subscription/ChargeSubscription.php @@ -42,6 +42,8 @@ class ChargeSubscription extends AbstractApi use Traits\TransactionsTrait; use Traits\AmountTrait; use Traits\AgreementTrait; + use Traits\TransactionInfoTrait; + use Traits\OrderlinesTrait; /** * @param array $agreement @@ -78,7 +80,7 @@ public function setReconciliationIdentifier($identifier) protected function configureOptions(OptionsResolver $resolver) { $resolver->setRequired('transaction_id'); - $resolver->setDefined(['amount', 'reconciliation_identifier', 'agreement']); + $resolver->setDefined(['amount', 'reconciliation_identifier', 'agreement', 'transaction_info', 'orderLines']); $resolver->addAllowedTypes('reconciliation_identifier', 'string'); }