Skip to content

Commit

Permalink
Merge pull request #36 from AltaPay/charge-subscription-transaction-info
Browse files Browse the repository at this point in the history
Charge subscription transaction info
  • Loading branch information
emicha authored May 24, 2023
2 parents e73bbc5 + 4d6e496 commit a79f23d
Show file tree
Hide file tree
Showing 5 changed files with 63 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.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
Expand Down
2 changes: 1 addition & 1 deletion docs/request/orderline.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[<](../index.md) Altapay - PHP Api - Customer Info
[<](../index.md) Altapay - PHP Api - Order line
==================================================

A order line object requries
Expand Down
54 changes: 54 additions & 0 deletions docs/subscription/charge_subscription.md
Original file line number Diff line number Diff line change
@@ -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();
```
2 changes: 1 addition & 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.3.4';
const PHP_API_VERSION = '3.3.5';

/**
* Event dispatcher
Expand Down
4 changes: 3 additions & 1 deletion src/Api/Subscription/ChargeSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> $agreement
Expand Down Expand Up @@ -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');
}

Expand Down

0 comments on commit a79f23d

Please sign in to comment.