Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #152 from heidelpay/change/PHPLIB-245/add-sepa-rec…
Browse files Browse the repository at this point in the history
…urring

change/PHPLIB-245/add-sepa-recurring
  • Loading branch information
Simon Gabriel authored Jan 10, 2020
2 parents d8fe6fb + b35a233 commit 2aaa013
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

### Added
* Example for Payment Type `Przelewy24`.
* Enabled recurring payment for SEPA direct debit (guaranteed).

### Fixed
* A bug which led to an error when trying to cancel the initial transaction of a charged invoice.
Expand Down Expand Up @@ -79,6 +80,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
* Refactor deprecation notices.
* Refactored and extended unit tests.
* Test keypair can now be set via environment variables.
* Activate recurring payment for `SEPA Direct Debit (guaranteed)`.

## [1.2.2.0][1.2.2.0]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Please refer to the following documentation for installation instructions and us
* PayPal + Recurring
* Prepayment
* Przelewy24
* SEPA direct debit (guaranteed)
* SEPA direct debit (guaranteed) + Recurring
* SOFORT
* EPS
* FlexiPay® Direct (PIS)
Expand Down
2 changes: 2 additions & 0 deletions src/Constants/ApiResponseCodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class ApiResponseCodes
const API_ERROR_CUSTOMER_CAN_NOT_BE_FOUND = 'API.500.100.100';
const API_ERROR_REQUEST_DATA_IS_INVALID = 'API.500.300.999';
const API_ERROR_RECURRING_PAYMENT_NOT_SUPPORTED = 'API.500.550.004';
const API_ERROR_ACTIVATE_RECURRING_VIA_TRANSACTION = 'API.500.550.005';
const API_ERROR_RECURRING_ALREADY_ACTIVE = 'API.500.550.006';
const API_ERROR_WEBHOOK_EVENT_ALREADY_REGISTERED = 'API.510.310.009';
const API_ERROR_WEBHOOK_CAN_NOT_BE_FOUND = 'API.510.310.008';
const API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL = 'API.600.630.004';
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/PaymentTypes/SepaDirectDebit.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

use heidelpayPHP\Traits\CanDirectCharge;
use heidelpayPHP\Traits\CanPayout;
use heidelpayPHP\Traits\CanRecur;

class SepaDirectDebit extends BasePaymentType
{
use CanDirectCharge;
use CanPayout;
use CanRecur;

/** @var string $iban */
protected $iban;
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/PaymentTypes/SepaDirectDebitGuaranteed.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

use heidelpayPHP\Traits\CanDirectChargeWithCustomer;
use heidelpayPHP\Traits\CanPayoutWithCustomer;
use heidelpayPHP\Traits\CanRecur;

class SepaDirectDebitGuaranteed extends BasePaymentType
{
use CanDirectChargeWithCustomer;
use CanPayoutWithCustomer;
use CanRecur;

/** @var string $iban */
protected $iban;
Expand Down
42 changes: 42 additions & 0 deletions test/integration/RecurringPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use heidelpayPHP\Exceptions\HeidelpayApiException;
use heidelpayPHP\Resources\PaymentTypes\Card;
use heidelpayPHP\Resources\PaymentTypes\Paypal;
use heidelpayPHP\Resources\PaymentTypes\SepaDirectDebit;
use heidelpayPHP\Resources\PaymentTypes\SepaDirectDebitGuaranteed;
use heidelpayPHP\test\BasePaymentTest;
use PHPUnit\Framework\Exception;
use RuntimeException;
Expand Down Expand Up @@ -114,4 +116,44 @@ public function paypalShouldBeAbleToActivateRecurringPayments()
$this->assertPending($recurring);
$this->assertNotEmpty($recurring->getReturnUrl());
}

/**
* Verify sepa direct debit can activate recurring payments.
*
* @test
*
* @throws RuntimeException
* @throws HeidelpayApiException
*/
public function sepaDirectDebitShouldBeAbleToActivateRecurringPayments()
{
/** @var SepaDirectDebit $dd */
$dd = $this->heidelpay->createPaymentType(new SepaDirectDebit('DE89370400440532013000'));
$this->assertFalse($dd->isRecurring());
$dd->charge(10.0, 'EUR', self::RETURN_URL);
$dd = $this->heidelpay->fetchPaymentType($dd->getId());
$this->assertTrue($dd->isRecurring());

$this->expectException(HeidelpayApiException::class);
$this->expectExceptionCode(ApiResponseCodes::API_ERROR_RECURRING_ALREADY_ACTIVE);
$this->heidelpay->activateRecurringPayment($dd, self::RETURN_URL);
}

/**
* Verify sepa direct debit guaranteed can activate recurring payments.
*
* @test
*
* @throws RuntimeException
* @throws HeidelpayApiException
*/
public function sepaDirectDebitGuaranteedShouldBeAbleToActivateRecurringPayments()
{
/** @var SepaDirectDebitGuaranteed $ddg */
$ddg = $this->heidelpay->createPaymentType(new SepaDirectDebitGuaranteed('DE89370400440532013000'));

$this->expectException(HeidelpayApiException::class);
$this->expectExceptionCode(ApiResponseCodes::API_ERROR_ACTIVATE_RECURRING_VIA_TRANSACTION);
$ddg->activateRecurring('https://dev.heidelpay.com');
}
}

0 comments on commit 2aaa013

Please sign in to comment.