-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #99 Refunds improvements (Zales0123)
This PR was merged into the 1.0-dev branch. Discussion ---------- Refunds system improved to meet PayPal requirements. Added header: `PayPal-Auth-Assertion` - generated with the special algorithm Added request body: `{ "amount": { "value": "XX.XX", "currency_code": "XXX" }, "invoice_number": "XXXXXX" }` Commits ------- 93febc5 Service for PayPal-Auth-Assertion header generation 4eff01c Pass PayPal-Auth-Assertion header during refund 1ff4a26 Get PayPal payment id from API during refund 7508454 Specify refunded amount ddc7033 Generate reference number for refund 6141876 Fix tests
- Loading branch information
Showing
21 changed files
with
405 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Sylius\PayPalPlugin\Generator; | ||
|
||
use Payum\Core\Model\GatewayConfigInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\PaymentMethodInterface; | ||
use Sylius\PayPalPlugin\Generator\PayPalAuthAssertionGeneratorInterface; | ||
|
||
final class PayPalAuthAssertionGeneratorSpec extends ObjectBehavior | ||
{ | ||
function it_implements_pay_pal_auth_assertion_generator_interface(): void | ||
{ | ||
$this->shouldImplement(PayPalAuthAssertionGeneratorInterface::class); | ||
} | ||
|
||
function it_generates_auth_assertion_based_on_payment_method_config( | ||
PaymentMethodInterface $paymentMethod, | ||
GatewayConfigInterface $gatewayConfig | ||
): void { | ||
$paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); | ||
$gatewayConfig->getConfig()->willReturn(['client_id' => 'CLIENT_ID', 'merchant_id' => 'MERCHANT_ID']); | ||
|
||
$this | ||
->generate($paymentMethod) | ||
->shouldReturn('eyJhbGciOiJub25lIn0=.eyJpc3MiOiJDTElFTlRfSUQiLCJwYXllcl9pZCI6Ik1FUkNIQU5UX0lEIn0=.') | ||
; | ||
} | ||
|
||
function it_throws_an_exception_if_gateway_config_does_not_have_proper_values_set( | ||
PaymentMethodInterface $paymentMethod, | ||
GatewayConfigInterface $gatewayConfig | ||
): void { | ||
$paymentMethod->getGatewayConfig()->willReturn($gatewayConfig, $gatewayConfig); | ||
$gatewayConfig->getConfig()->willReturn(['merchant_id' => 'MERCHANT_ID'], ['client_id' => 'CLIENT_ID']); | ||
|
||
$this->shouldThrow(\InvalidArgumentException::class)->during('generate', [$paymentMethod]); | ||
$this->shouldThrow(\InvalidArgumentException::class)->during('generate', [$paymentMethod]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Sylius\PayPalPlugin\Provider; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\PaymentInterface; | ||
use Sylius\PayPalPlugin\Provider\RefundReferenceNumberProviderInterface; | ||
|
||
final class RefundReferenceNumberProviderSpec extends ObjectBehavior | ||
{ | ||
function it_implements_refund_reference_number_provider_interface(): void | ||
{ | ||
$this->shouldImplement(RefundReferenceNumberProviderInterface::class); | ||
} | ||
|
||
function it_provides_reference_number_based_on_payment_id_and_current_date(PaymentInterface $payment): void | ||
{ | ||
$payment->getId()->willReturn(123); | ||
|
||
$this->provide($payment)->shouldReturn('123-' . (new \DateTime())->format('d-m-Y')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.