|
33 | 33 | use Adyen\Model\TokenizationWebhooks\TokenizationUpdatedDetailsNotificationRequest; |
34 | 34 | use Adyen\Model\TransactionWebhooks\TransactionNotificationRequestV4; |
35 | 35 | use Adyen\Model\BalanceWebhooks\BalanceAccountBalanceNotificationRequest; |
| 36 | +use Adyen\Model\RelayedAuthorizationWebhooks\RelayedAuthorisationRequest; |
36 | 37 | use Adyen\Service\BankingWebhookParser; |
37 | 38 | use Adyen\Service\ManagementWebhookParser; |
38 | 39 | use Adyen\Service\TokenizationWebhookParser; |
@@ -513,4 +514,172 @@ public function testTokenizationWebhookRecurringTokenAlreadyExisting() |
513 | 514 | self::assertEquals("recurring.token.alreadyExisting", $result->getType()); |
514 | 515 | self::assertEquals("test", $result->getEnvironment()); |
515 | 516 | } |
| 517 | + |
| 518 | + public function testBankingWebhookParserRelayedAuthorisationRequest() |
| 519 | + { |
| 520 | + $jsonString = '{ |
| 521 | + "accountHolder": { |
| 522 | + "description": "Account holder description", |
| 523 | + "id": "AH123ABCDEFGHIJKLMN456789" |
| 524 | + }, |
| 525 | + "amount": { |
| 526 | + "currency": "EUR", |
| 527 | + "value": -2700 |
| 528 | + }, |
| 529 | + "authCode": "123456", |
| 530 | + "authorisationDecision": { |
| 531 | + "reasonCode": "APPROVED", |
| 532 | + "status": "Authorised", |
| 533 | + "statusCode": "APPROVED" |
| 534 | + }, |
| 535 | + "authorisationType": "finalAuthorisation", |
| 536 | + "balanceAccount": { |
| 537 | + "description": "Balance Account Description", |
| 538 | + "id": "BA123ABCDEFGHIJKLMN456789" |
| 539 | + }, |
| 540 | + "balanceMutations": [ |
| 541 | + { |
| 542 | + "balanceAfter": { |
| 543 | + "currency": "EUR", |
| 544 | + "value": 221163 |
| 545 | + }, |
| 546 | + "balanceBefore": { |
| 547 | + "currency": "EUR", |
| 548 | + "value": 221190 |
| 549 | + }, |
| 550 | + "currency": "EUR", |
| 551 | + "mutationAmount": { |
| 552 | + "currency": "EUR", |
| 553 | + "value": -2700 |
| 554 | + }, |
| 555 | + "type": "AuthorisedOutgoing" |
| 556 | + } |
| 557 | + ], |
| 558 | + "balancePlatform": "TestBalancePlatform", |
| 559 | + "entryMode": "contactless", |
| 560 | + "id": "2ABCBA13456ABCDE", |
| 561 | + "merchantData": { |
| 562 | + "acquirerId": "012345", |
| 563 | + "mcc": "5813", |
| 564 | + "merchantId": "000123450000123", |
| 565 | + "nameLocation": { |
| 566 | + "city": "Amsterdam", |
| 567 | + "country": "NLD", |
| 568 | + "name": "Tea Shop NLD", |
| 569 | + "rawData": "TeaShop_NLD" |
| 570 | + }, |
| 571 | + "postalCode": "3333AB" |
| 572 | + }, |
| 573 | + "originalAmount": { |
| 574 | + "currency": "EUR", |
| 575 | + "value": -2700 |
| 576 | + }, |
| 577 | + "paymentInstrument": { |
| 578 | + "balanceAccountId": "BA123ABCDEFGHIJKLMN456789", |
| 579 | + "description": "PaymentInstrument Description", |
| 580 | + "issuingCountryCode": "NL", |
| 581 | + "paymentInstrumentGroupId": "PG3123ABCDEFGHIJKLMN456789", |
| 582 | + "reference": "123456789", |
| 583 | + "status": "active", |
| 584 | + "type": "card", |
| 585 | + "card": { |
| 586 | + "authentication": { |
| 587 | + "email": "john.doe @provider.com" |
| 588 | + }, |
| 589 | + "brand": "mc", |
| 590 | + "brandVariant": "mc_debit_bpd", |
| 591 | + "cardholderName": "John Doe", |
| 592 | + "formFactor": "virtual", |
| 593 | + "bin": "555555", |
| 594 | + "expiration": { |
| 595 | + "month": "09", |
| 596 | + "year": "2027" |
| 597 | + }, |
| 598 | + "lastFour": "0000", |
| 599 | + "number": "12345ABCDE" |
| 600 | + }, |
| 601 | + "id": "PI123ABCDEFGHIJKLMN456789" |
| 602 | + }, |
| 603 | + "processingType": "token", |
| 604 | + "reference": "ABCDEFGHIJ", |
| 605 | + "schemeUniqueTransactionId": "ABCDEFU2B1305", |
| 606 | + "transactionRulesResult": { |
| 607 | + "allHardBlockRulesPassed": true, |
| 608 | + "score": 80 |
| 609 | + }, |
| 610 | + "validationResult": [ |
| 611 | + { |
| 612 | + "result": "valid", |
| 613 | + "type": "TransactionValidation" |
| 614 | + }, |
| 615 | + { |
| 616 | + "result": "valid", |
| 617 | + "type": "PaymentInstrumentExpirationCheck" |
| 618 | + }, |
| 619 | + { |
| 620 | + "result": "valid", |
| 621 | + "type": "BalanceCheck" |
| 622 | + }, |
| 623 | + { |
| 624 | + "result": "valid", |
| 625 | + "type": "Screening" |
| 626 | + }, |
| 627 | + { |
| 628 | + "result": "valid", |
| 629 | + "type": "RealBalanceAvailable" |
| 630 | + }, |
| 631 | + { |
| 632 | + "result": "notValidated", |
| 633 | + "type": "MITAllowedMerchant" |
| 634 | + }, |
| 635 | + { |
| 636 | + "result": "valid", |
| 637 | + "type": "PaymentInstrumentFound" |
| 638 | + }, |
| 639 | + { |
| 640 | + "result": "valid", |
| 641 | + "type": "TransactionRules" |
| 642 | + }, |
| 643 | + { |
| 644 | + "result": "valid", |
| 645 | + "type": "AccountLookup" |
| 646 | + }, |
| 647 | + { |
| 648 | + "result": "valid", |
| 649 | + "type": "PaymentInstrumentActive" |
| 650 | + }, |
| 651 | + { |
| 652 | + "result": "valid", |
| 653 | + "type": "CardholderAuthentication" |
| 654 | + }, |
| 655 | + { |
| 656 | + "result": "valid", |
| 657 | + "type": "PaymentInstrument" |
| 658 | + }, |
| 659 | + { |
| 660 | + "result": "valid", |
| 661 | + "type": "CardAuthentication" |
| 662 | + }, |
| 663 | + { |
| 664 | + "result": "valid", |
| 665 | + "type": "PartyScreening" |
| 666 | + }, |
| 667 | + { |
| 668 | + "result": "valid", |
| 669 | + "type": "InputExpiryDateCheck" |
| 670 | + } |
| 671 | + ], |
| 672 | + "environment": "test", |
| 673 | + "type": "balancePlatform.authorisation.relayed" |
| 674 | +}'; |
| 675 | + |
| 676 | + $webhookParser = new BankingWebhookParser($jsonString); |
| 677 | + $result = $webhookParser->getRelayedAuthorisationRequest(); |
| 678 | + self::assertEquals(RelayedAuthorisationRequest::class, get_class($result)); |
| 679 | + self::assertEquals("2ABCBA13456ABCDE", $result->getId()); |
| 680 | + self::assertEquals("ABCDEFGHIJ", $result->getReference()); |
| 681 | + self::assertEquals("Authorised", $result->getAuthorisationDecision()->getStatus()); |
| 682 | + self::assertEquals("balancePlatform.authorisation.relayed", $result->getType()); |
| 683 | + self::assertEquals("test", $result->getEnvironment()); |
| 684 | + } |
516 | 685 | } |
0 commit comments