Completed
Pull Request — master (#1166)
by wiese
102:03 queued 37:00
created
app/RouteHandlers/PayPalNotificationHandler.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\App\RouteHandlers;
6 6
 
@@ -24,117 +24,117 @@  discard block
 block discarded – undo
24 24
 
25 25
 	private $ffFactory;
26 26
 
27
-	public function __construct( FunFunFactory $ffFactory ) {
27
+	public function __construct(FunFunFactory $ffFactory) {
28 28
 		$this->ffFactory = $ffFactory;
29 29
 	}
30 30
 
31
-	public function handle( Request $request ): Response {
31
+	public function handle(Request $request): Response {
32 32
 		$post = $request->request;
33 33
 
34 34
 		try {
35
-			$this->ffFactory->getPayPalPaymentNotificationVerifier()->verify( $post->all() );
36
-		} catch ( PayPalPaymentNotificationVerifierException $e ) {
37
-			$this->ffFactory->getPaypalLogger()->log( LogLevel::ERROR, $e->getMessage(), [
35
+			$this->ffFactory->getPayPalPaymentNotificationVerifier()->verify($post->all());
36
+		} catch (PayPalPaymentNotificationVerifierException $e) {
37
+			$this->ffFactory->getPaypalLogger()->log(LogLevel::ERROR, $e->getMessage(), [
38 38
 				'post_vars' => $request->request->all()
39
-			] );
40
-			return $this->createErrorResponse( $e );
39
+			]);
40
+			return $this->createErrorResponse($e);
41 41
 		}
42 42
 
43
-		if ( !$this->requestIsForPaymentCompletion( $post ) ) {
44
-			$this->ffFactory->getPaypalLogger()->log( LogLevel::INFO, self::MSG_NOT_HANDLED, [ 'post_vars' => $post->all() ] );
45
-			return new Response( '', Response::HTTP_OK );
43
+		if (!$this->requestIsForPaymentCompletion($post)) {
44
+			$this->ffFactory->getPaypalLogger()->log(LogLevel::INFO, self::MSG_NOT_HANDLED, ['post_vars' => $post->all()]);
45
+			return new Response('', Response::HTTP_OK);
46 46
 		}
47 47
 
48
-		$useCase = $this->ffFactory->newHandlePayPalPaymentCompletionNotificationUseCase( $this->getUpdateToken( $post ) );
48
+		$useCase = $this->ffFactory->newHandlePayPalPaymentCompletionNotificationUseCase($this->getUpdateToken($post));
49 49
 
50
-		$response = $useCase->handleNotification( $this->newUseCaseRequestFromPost( $post ) );
51
-		$this->logResponseIfNeeded( $response, $request );
50
+		$response = $useCase->handleNotification($this->newUseCaseRequestFromPost($post));
51
+		$this->logResponseIfNeeded($response, $request);
52 52
 
53
-		return new Response( '', Response::HTTP_OK ); # PayPal expects an empty response
53
+		return new Response('', Response::HTTP_OK); # PayPal expects an empty response
54 54
 	}
55 55
 
56
-	private function getUpdateToken( ParameterBag $postRequest ): string {
57
-		return $this->getValueFromCustomVars( $postRequest->get( 'custom', '' ), 'utoken' );
56
+	private function getUpdateToken(ParameterBag $postRequest): string {
57
+		return $this->getValueFromCustomVars($postRequest->get('custom', ''), 'utoken');
58 58
 	}
59 59
 
60
-	private function getValueFromCustomVars( string $customVars, string $key ): string {
61
-		$vars = json_decode( $customVars, true );
62
-		return !empty( $vars[$key] ) ? $vars[$key] : '';
60
+	private function getValueFromCustomVars(string $customVars, string $key): string {
61
+		$vars = json_decode($customVars, true);
62
+		return !empty($vars[$key]) ? $vars[$key] : '';
63 63
 	}
64 64
 
65
-	private function requestIsForPaymentCompletion( ParameterBag $post ): bool {
66
-		if ( !$this->isSuccessfulPaymentNotification( $post ) ) {
65
+	private function requestIsForPaymentCompletion(ParameterBag $post): bool {
66
+		if (!$this->isSuccessfulPaymentNotification($post)) {
67 67
 			return false;
68 68
 		}
69
-		if ( $this->isForRecurringPayment( $post ) && !$this->isRecurringPaymentCompletion( $post ) ) {
69
+		if ($this->isForRecurringPayment($post) && !$this->isRecurringPaymentCompletion($post)) {
70 70
 			return false;
71 71
 		}
72 72
 
73 73
 		return true;
74 74
 	}
75 75
 
76
-	private function isSuccessfulPaymentNotification( ParameterBag $post ): bool {
77
-		return $post->get( 'payment_status', '' ) === 'Completed' || $post->get( 'payment_status' ) === 'Processed';
76
+	private function isSuccessfulPaymentNotification(ParameterBag $post): bool {
77
+		return $post->get('payment_status', '') === 'Completed' || $post->get('payment_status') === 'Processed';
78 78
 	}
79 79
 
80
-	private function isRecurringPaymentCompletion( ParameterBag $post ): bool {
81
-		return $post->get( 'txn_type', '' ) === 'subscr_payment';
80
+	private function isRecurringPaymentCompletion(ParameterBag $post): bool {
81
+		return $post->get('txn_type', '') === 'subscr_payment';
82 82
 	}
83 83
 
84
-	private function isForRecurringPayment( ParameterBag $post  ): bool {
85
-		return strpos( $post->get( 'txn_type', '' ), 'subscr_' ) === 0;
84
+	private function isForRecurringPayment(ParameterBag $post): bool {
85
+		return strpos($post->get('txn_type', ''), 'subscr_') === 0;
86 86
 	}
87 87
 
88
-	private function newUseCaseRequestFromPost( ParameterBag $postRequest ): PayPalPaymentNotificationRequest {
89
-		return ( new PayPalPaymentNotificationRequest() )
90
-			->setTransactionType( $postRequest->get( 'txn_type', '' ) )
91
-			->setTransactionId( $postRequest->get( 'txn_id', '' ) )
92
-			->setPayerId( $postRequest->get( 'payer_id', '' ) )
93
-			->setSubscriptionId( $postRequest->get( 'subscr_id', '' ) )
94
-			->setPayerEmail( $postRequest->get( 'payer_email', '' ) )
95
-			->setPayerStatus( $postRequest->get( 'payer_status', '' ) )
96
-			->setPayerFirstName( $postRequest->get( 'first_name', '' ) )
97
-			->setPayerLastName( $postRequest->get( 'last_name', '' ) )
98
-			->setPayerAddressName( $postRequest->get( 'address_name', '' ) )
99
-			->setPayerAddressStreet( $postRequest->get( 'address_street', '' ) )
100
-			->setPayerAddressPostalCode( $postRequest->get( 'address_zip', '' ) )
101
-			->setPayerAddressCity( $postRequest->get( 'address_city', '' ) )
102
-			->setPayerAddressCountryCode( $postRequest->get( 'address_country_code', '' ) )
103
-			->setPayerAddressStatus( $postRequest->get( 'address_status', '' ) )
104
-			->setInternalId( (int)$postRequest->get( 'item_number', 0 ) )
105
-			->setCurrencyCode( $postRequest->get( 'mc_currency', '' ) )
106
-			->setTransactionFee( $postRequest->get( 'mc_fee', '0' ) ) // No Euro class to avoid exceptions on fees < 0
107
-			->setAmountGross( Euro::newFromString( $postRequest->get( 'mc_gross', '0' ) ) )
108
-			->setSettleAmount( Euro::newFromString( $postRequest->get( 'settle_amount', '0' ) ) )
109
-			->setPaymentTimestamp( $postRequest->get( 'payment_date', '' ) )
110
-			->setPaymentStatus( $postRequest->get( 'payment_status', '' ) )
111
-			->setPaymentType( $postRequest->get( 'payment_type', '' ) );
88
+	private function newUseCaseRequestFromPost(ParameterBag $postRequest): PayPalPaymentNotificationRequest {
89
+		return (new PayPalPaymentNotificationRequest())
90
+			->setTransactionType($postRequest->get('txn_type', ''))
91
+			->setTransactionId($postRequest->get('txn_id', ''))
92
+			->setPayerId($postRequest->get('payer_id', ''))
93
+			->setSubscriptionId($postRequest->get('subscr_id', ''))
94
+			->setPayerEmail($postRequest->get('payer_email', ''))
95
+			->setPayerStatus($postRequest->get('payer_status', ''))
96
+			->setPayerFirstName($postRequest->get('first_name', ''))
97
+			->setPayerLastName($postRequest->get('last_name', ''))
98
+			->setPayerAddressName($postRequest->get('address_name', ''))
99
+			->setPayerAddressStreet($postRequest->get('address_street', ''))
100
+			->setPayerAddressPostalCode($postRequest->get('address_zip', ''))
101
+			->setPayerAddressCity($postRequest->get('address_city', ''))
102
+			->setPayerAddressCountryCode($postRequest->get('address_country_code', ''))
103
+			->setPayerAddressStatus($postRequest->get('address_status', ''))
104
+			->setInternalId((int)$postRequest->get('item_number', 0))
105
+			->setCurrencyCode($postRequest->get('mc_currency', ''))
106
+			->setTransactionFee($postRequest->get('mc_fee', '0')) // No Euro class to avoid exceptions on fees < 0
107
+			->setAmountGross(Euro::newFromString($postRequest->get('mc_gross', '0')))
108
+			->setSettleAmount(Euro::newFromString($postRequest->get('settle_amount', '0')))
109
+			->setPaymentTimestamp($postRequest->get('payment_date', ''))
110
+			->setPaymentStatus($postRequest->get('payment_status', ''))
111
+			->setPaymentType($postRequest->get('payment_type', ''));
112 112
 	}
113 113
 
114
-	private function createErrorResponse( PayPalPaymentNotificationVerifierException $e ): Response {
115
-		switch ( $e->getCode() ) {
114
+	private function createErrorResponse(PayPalPaymentNotificationVerifierException $e): Response {
115
+		switch ($e->getCode()) {
116 116
 			case PayPalPaymentNotificationVerifierException::ERROR_WRONG_RECEIVER:
117
-				return new Response( $e->getMessage(), Response::HTTP_FORBIDDEN );
117
+				return new Response($e->getMessage(), Response::HTTP_FORBIDDEN);
118 118
 			case PayPalPaymentNotificationVerifierException::ERROR_VERIFICATION_FAILED:
119
-				return new Response( $e->getMessage(), Response::HTTP_FORBIDDEN );
119
+				return new Response($e->getMessage(), Response::HTTP_FORBIDDEN);
120 120
 			case PayPalPaymentNotificationVerifierException::ERROR_UNSUPPORTED_CURRENCY:
121
-				return new Response( $e->getMessage(), Response::HTTP_NOT_ACCEPTABLE );
121
+				return new Response($e->getMessage(), Response::HTTP_NOT_ACCEPTABLE);
122 122
 			default:
123
-				return new Response( $e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR );
123
+				return new Response($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
124 124
 		}
125 125
 	}
126 126
 
127
-	private function logResponseIfNeeded( PaypalNotificationResponse $response, Request $request ) {
128
-		if ( $response->notificationWasHandled() ) {
127
+	private function logResponseIfNeeded(PaypalNotificationResponse $response, Request $request) {
128
+		if ($response->notificationWasHandled()) {
129 129
 			return;
130 130
 		}
131 131
 
132 132
 		$context = $response->getContext();
133 133
 		$message = $context['message'] ?? self::MSG_NOT_HANDLED;
134 134
 		$logLevel = $response->hasErrors() ? LogLevel::ERROR : LogLevel::INFO;
135
-		unset( $context['message'] );
135
+		unset($context['message']);
136 136
 		$context['post_vars'] = $request->request->all();
137
-		$this->ffFactory->getPaypalLogger()->log( $logLevel, $message, $context );
137
+		$this->ffFactory->getPaypalLogger()->log($logLevel, $message, $context);
138 138
 	}
139 139
 
140 140
 }
Please login to merge, or discard this patch.
tests/EdgeToEdge/Routes/HandlePayPalPaymentNotificationRouteTest.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\Tests\EdgeToEdge\Routes;
6 6
 
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
 	private const PATH = '/handle-paypal-payment-notification';
37 37
 
38 38
 	public function testGivenValidRequest_applicationIndicatesSuccess(): void {
39
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
40
-			$factory->setDonationTokenGenerator( new FixedTokenGenerator(
39
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
40
+			$factory->setDonationTokenGenerator(new FixedTokenGenerator(
41 41
 				self::UPDATE_TOKEN,
42
-				\DateTime::createFromFormat( 'Y-m-d H:i:s', '2039-12-31 23:59:59' )
43
-			) );
42
+				\DateTime::createFromFormat('Y-m-d H:i:s', '2039-12-31 23:59:59')
43
+			));
44 44
 
45
-			$factory->getDonationRepository()->storeDonation( ValidDonation::newIncompletePayPalDonation() );
45
+			$factory->getDonationRepository()->storeDonation(ValidDonation::newIncompletePayPalDonation());
46 46
 
47 47
 			$factory->setPayPalPaymentNotificationVerifier(
48
-				$this->newNonNetworkUsingNotificationVerifier( $this->newHttpParamsForPayment() )
48
+				$this->newNonNetworkUsingNotificationVerifier($this->newHttpParamsForPayment())
49 49
 			);
50 50
 
51 51
 			$client->request(
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 				$this->newHttpParamsForPayment()
55 55
 			);
56 56
 
57
-			$this->assertSame( 200, $client->getResponse()->getStatusCode() );
58
-			$this->assertPayPalDataGotPersisted( $factory->getDonationRepository(), $this->newHttpParamsForPayment() );
57
+			$this->assertSame(200, $client->getResponse()->getStatusCode());
58
+			$this->assertPayPalDataGotPersisted($factory->getDonationRepository(), $this->newHttpParamsForPayment());
59 59
 		} );
60 60
 	}
61 61
 
62
-	private function newNonNetworkUsingNotificationVerifier( array $requestParams ): PayPalPaymentNotificationVerifier {
62
+	private function newNonNetworkUsingNotificationVerifier(array $requestParams): PayPalPaymentNotificationVerifier {
63 63
 		return new PayPalPaymentNotificationVerifier(
64
-			$this->newGuzzleClientMock( self::VALID_VERIFICATION_RESPONSE, $requestParams ),
64
+			$this->newGuzzleClientMock(self::VALID_VERIFICATION_RESPONSE, $requestParams),
65 65
 			self::BASE_URL,
66 66
 			self::EMAIL_ADDRESS
67 67
 		);
@@ -69,72 +69,72 @@  discard block
 block discarded – undo
69 69
 
70 70
 	private function newFailingNotifierMock(): PayPalPaymentNotificationVerifier {
71 71
 		return new PayPalPaymentNotificationVerifier(
72
-			$this->newGuzzleClientMock( self::FAILING_VERIFICATION_RESPONSE, $this->newHttpParamsForPayment() ),
72
+			$this->newGuzzleClientMock(self::FAILING_VERIFICATION_RESPONSE, $this->newHttpParamsForPayment()),
73 73
 			self::BASE_URL,
74 74
 			self::EMAIL_ADDRESS
75 75
 		);
76 76
 	}
77 77
 
78
-	private function newGuzzleClientMock( string $responseBody, array $requestParams ): GuzzleClient {
79
-		$body = $this->getMockBuilder( Stream::class )
78
+	private function newGuzzleClientMock(string $responseBody, array $requestParams): GuzzleClient {
79
+		$body = $this->getMockBuilder(Stream::class)
80 80
 			->disableOriginalConstructor()
81
-			->setMethods( [ 'getContents' ] )
81
+			->setMethods(['getContents'])
82 82
 			->getMock();
83 83
 
84
-		$body->expects( $this->any() )
85
-			->method( 'getContents' )
86
-			->willReturn( $responseBody );
84
+		$body->expects($this->any())
85
+			->method('getContents')
86
+			->willReturn($responseBody);
87 87
 
88
-		$response = $this->getMockBuilder( Response::class )
88
+		$response = $this->getMockBuilder(Response::class)
89 89
 			->disableOriginalConstructor()
90
-			->setMethods( [ 'getBody' ] )
90
+			->setMethods(['getBody'])
91 91
 			->getMock();
92 92
 
93
-		$response->expects( $this->any() )
94
-			->method( 'getBody' )
95
-			->willReturn( $body );
93
+		$response->expects($this->any())
94
+			->method('getBody')
95
+			->willReturn($body);
96 96
 
97
-		$client = $this->getMockBuilder( GuzzleClient::class )
97
+		$client = $this->getMockBuilder(GuzzleClient::class)
98 98
 			->disableOriginalConstructor()
99
-			->setMethods( [ 'post' ] )
99
+			->setMethods(['post'])
100 100
 			->getMock();
101 101
 
102
-		$client->expects( $this->any() )
103
-			->method( 'post' )
102
+		$client->expects($this->any())
103
+			->method('post')
104 104
 			->with(
105 105
 				self::BASE_URL,
106
-				[ 'form_params' => array_merge( $requestParams, [ 'cmd' => '_notify-validate' ] ) ]
106
+				['form_params' => array_merge($requestParams, ['cmd' => '_notify-validate'])]
107 107
 			)
108
-			->willReturn( $response );
108
+			->willReturn($response);
109 109
 
110 110
 		return $client;
111 111
 	}
112 112
 
113
-	private function assertPayPalDataGotPersisted( DonationRepository $donationRepo, array $request ): void {
114
-		$donation = $donationRepo->getDonationById( self::DONATION_ID );
113
+	private function assertPayPalDataGotPersisted(DonationRepository $donationRepo, array $request): void {
114
+		$donation = $donationRepo->getDonationById(self::DONATION_ID);
115 115
 
116 116
 		/** @var PayPalPayment $paymentMethod */
117 117
 		$paymentMethod = $donation->getPayment()->getPaymentMethod();
118 118
 		$pplData = $paymentMethod->getPayPalData();
119 119
 
120
-		$this->assertSame( $request['payer_id'], $pplData->getPayerId() );
121
-		$this->assertSame( $request['subscr_id'], $pplData->getSubscriberId() );
122
-		$this->assertSame( $request['payer_status'], $pplData->getPayerStatus() );
123
-		$this->assertSame( $request['first_name'], $pplData->getFirstName() );
124
-		$this->assertSame( $request['last_name'], $pplData->getLastName() );
125
-		$this->assertSame( $request['address_name'], $pplData->getAddressName() );
126
-		$this->assertSame( $request['address_status'], $pplData->getAddressStatus() );
127
-		$this->assertSame( $request['mc_currency'], $pplData->getCurrencyCode() );
128
-		$this->assertSame( $request['mc_fee'], $pplData->getFee()->getEuroString() );
129
-		$this->assertSame( $request['mc_gross'], $pplData->getAmount()->getEuroString() );
130
-		$this->assertSame( $request['settle_amount'], $pplData->getSettleAmount()->getEuroString() );
131
-
132
-		$this->assertSame( $request['txn_id'], $pplData->getPaymentId() );
133
-		$this->assertSame( $request['payment_type'], $pplData->getPaymentType() );
134
-		$this->assertSame( $request['payment_status'] . '/' . $request['txn_type'], $pplData->getPaymentStatus() );
135
-		$this->assertSame( $request['payer_id'], $pplData->getPayerId() );
136
-		$this->assertSame( $request['payment_date'], $pplData->getPaymentTimestamp() );
137
-		$this->assertSame( $request['subscr_id'], $pplData->getSubscriberId() );
120
+		$this->assertSame($request['payer_id'], $pplData->getPayerId());
121
+		$this->assertSame($request['subscr_id'], $pplData->getSubscriberId());
122
+		$this->assertSame($request['payer_status'], $pplData->getPayerStatus());
123
+		$this->assertSame($request['first_name'], $pplData->getFirstName());
124
+		$this->assertSame($request['last_name'], $pplData->getLastName());
125
+		$this->assertSame($request['address_name'], $pplData->getAddressName());
126
+		$this->assertSame($request['address_status'], $pplData->getAddressStatus());
127
+		$this->assertSame($request['mc_currency'], $pplData->getCurrencyCode());
128
+		$this->assertSame($request['mc_fee'], $pplData->getFee()->getEuroString());
129
+		$this->assertSame($request['mc_gross'], $pplData->getAmount()->getEuroString());
130
+		$this->assertSame($request['settle_amount'], $pplData->getSettleAmount()->getEuroString());
131
+
132
+		$this->assertSame($request['txn_id'], $pplData->getPaymentId());
133
+		$this->assertSame($request['payment_type'], $pplData->getPaymentType());
134
+		$this->assertSame($request['payment_status'] . '/' . $request['txn_type'], $pplData->getPaymentStatus());
135
+		$this->assertSame($request['payer_id'], $pplData->getPayerId());
136
+		$this->assertSame($request['payment_date'], $pplData->getPaymentTimestamp());
137
+		$this->assertSame($request['subscr_id'], $pplData->getSubscriberId());
138 138
 	}
139 139
 
140 140
 	private function newHttpParamsForPayment(): array {
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	}
164 164
 
165 165
 	public function testGivenInvalidReceiverEmail_applicationReturnsError(): void {
166
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
166
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
167 167
 			$factory->setPayPalPaymentNotificationVerifier(
168
-				$this->newNonNetworkUsingNotificationVerifier( $this->newHttpParamsForPayment() )
168
+				$this->newNonNetworkUsingNotificationVerifier($this->newHttpParamsForPayment())
169 169
 			);
170 170
 
171 171
 			$client->request(
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
 				]
178 178
 			);
179 179
 
180
-			$this->assertSame( 'Payment receiver address does not match', $client->getResponse()->getContent() );
181
-			$this->assertSame( 403, $client->getResponse()->getStatusCode() );
180
+			$this->assertSame('Payment receiver address does not match', $client->getResponse()->getContent());
181
+			$this->assertSame(403, $client->getResponse()->getStatusCode());
182 182
 		} );
183 183
 	}
184 184
 
185 185
 	/**
186 186
 	 * @dataProvider unsupportedPaymentStatusProvider
187 187
 	 */
188
-	public function testGivenUnsupportedPaymentStatus_applicationReturnsOK( array $params ): void {
189
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) use ( $params ): void {
188
+	public function testGivenUnsupportedPaymentStatus_applicationReturnsOK(array $params): void {
189
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) use ($params): void {
190 190
 			$factory->setPayPalPaymentNotificationVerifier(
191
-				$this->newNonNetworkUsingNotificationVerifier( $params )
191
+				$this->newNonNetworkUsingNotificationVerifier($params)
192 192
 			);
193 193
 
194 194
 			$client->request(
@@ -197,24 +197,24 @@  discard block
 block discarded – undo
197 197
 				$params
198 198
 			);
199 199
 
200
-			$this->assertSame( '', $client->getResponse()->getContent() );
201
-			$this->assertSame( 200, $client->getResponse()->getStatusCode() );
200
+			$this->assertSame('', $client->getResponse()->getContent());
201
+			$this->assertSame(200, $client->getResponse()->getStatusCode());
202 202
 		} );
203 203
 	}
204 204
 
205 205
 	public function unsupportedPaymentStatusProvider(): \Iterator {
206
-		yield [ $this->newPendingPaymentParams() ];
207
-		yield [ $this->newCancelPaymentParams() ];
206
+		yield [$this->newPendingPaymentParams()];
207
+		yield [$this->newCancelPaymentParams()];
208 208
 	}
209 209
 
210 210
 	public function testGivenUnsupportedPaymentStatus_requestDataIsLogged(): void {
211
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
211
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
212 212
 			$factory->setPayPalPaymentNotificationVerifier(
213
-				$this->newNonNetworkUsingNotificationVerifier( $this->newPendingPaymentParams() )
213
+				$this->newNonNetworkUsingNotificationVerifier($this->newPendingPaymentParams())
214 214
 			);
215 215
 
216 216
 			$logger = new LoggerSpy();
217
-			$factory->setPaypalLogger( $logger );
217
+			$factory->setPaypalLogger($logger);
218 218
 
219 219
 			$client->request(
220 220
 				Request::METHOD_POST,
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			);
224 224
 
225 225
 			$this->assertSame(
226
-				[ 'PayPal request not handled' ],
226
+				['PayPal request not handled'],
227 227
 				$logger->getLogCalls()->getMessages()
228 228
 			);
229 229
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	}
236 236
 
237 237
 	public function testGivenFailingVerification_applicationReturnsError(): void {
238
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
238
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
239 239
 			$factory->setPayPalPaymentNotificationVerifier(
240 240
 				$this->newFailingNotifierMock()
241 241
 			);
@@ -246,15 +246,15 @@  discard block
 block discarded – undo
246 246
 				$this->newHttpParamsForPayment()
247 247
 			);
248 248
 
249
-			$this->assertSame( 'An error occurred while trying to confirm the sent data', $client->getResponse()->getContent() );
250
-			$this->assertSame( 403, $client->getResponse()->getStatusCode() );
249
+			$this->assertSame('An error occurred while trying to confirm the sent data', $client->getResponse()->getContent());
250
+			$this->assertSame(403, $client->getResponse()->getStatusCode());
251 251
 		} );
252 252
 	}
253 253
 
254 254
 	public function testGivenUnsupportedCurrency_applicationReturnsError(): void {
255
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
255
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
256 256
 			$factory->setPayPalPaymentNotificationVerifier(
257
-				$this->newNonNetworkUsingNotificationVerifier( $this->newHttpParamsForPayment() )
257
+				$this->newNonNetworkUsingNotificationVerifier($this->newHttpParamsForPayment())
258 258
 			);
259 259
 
260 260
 			$requestData = $this->newHttpParamsForPayment();
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
 				$requestData
266 266
 			);
267 267
 
268
-			$this->assertSame( 'Unsupported currency', $client->getResponse()->getContent() );
269
-			$this->assertSame( 406, $client->getResponse()->getStatusCode() );
268
+			$this->assertSame('Unsupported currency', $client->getResponse()->getContent());
269
+			$this->assertSame(406, $client->getResponse()->getStatusCode());
270 270
 		} );
271 271
 	}
272 272
 
273 273
 	public function testGivenTransactionTypeForSubscriptionChanges_requestDataIsLogged(): void {
274
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
274
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
275 275
 			$factory->setPayPalPaymentNotificationVerifier(
276
-				$this->newNonNetworkUsingNotificationVerifier( $this->newSubscriptionModificationParams() )
276
+				$this->newNonNetworkUsingNotificationVerifier($this->newSubscriptionModificationParams())
277 277
 			);
278 278
 			$logger = new LoggerSpy();
279
-			$factory->setPaypalLogger( $logger );
279
+			$factory->setPaypalLogger($logger);
280 280
 
281 281
 			$client->request(
282 282
 				Request::METHOD_POST,
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
 				$this->newSubscriptionModificationParams()
285 285
 			);
286 286
 
287
-			$this->assertSame( 200, $client->getResponse()->getStatusCode() );
287
+			$this->assertSame(200, $client->getResponse()->getStatusCode());
288 288
 
289 289
 			$this->assertSame(
290
-				[ 'PayPal request not handled' ],
290
+				['PayPal request not handled'],
291 291
 				$logger->getLogCalls()->getMessages()
292 292
 			);
293 293
 
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 	}
375 375
 
376 376
 	public function testGivenNegativeTransactionFee_exceptionIsThrown(): void {
377
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
378
-			$factory->setPayPalPaymentNotificationVerifier( $this->newSucceedingNotificationVerifier() );
377
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
378
+			$factory->setPayPalPaymentNotificationVerifier($this->newSucceedingNotificationVerifier());
379 379
 
380 380
 			$logger = new LoggerSpy();
381
-			$factory->setPaypalLogger( $logger );
381
+			$factory->setPaypalLogger($logger);
382 382
 
383 383
 			$client->request(
384 384
 				Request::METHOD_POST,
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			);
388 388
 
389 389
 			$this->assertSame(
390
-				[ 'PayPal request not handled' ],
390
+				['PayPal request not handled'],
391 391
 				$logger->getLogCalls()->getMessages()
392 392
 			);
393 393
 		} );
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 	}
402 402
 
403 403
 	private function newSucceedingNotificationVerifier(): PaymentNotificationVerifier {
404
-		$verifier = $this->createMock( PaymentNotificationVerifier::class );
404
+		$verifier = $this->createMock(PaymentNotificationVerifier::class);
405 405
 
406
-		$verifier->expects( $this->any() )->method( 'verify' )->willReturn( true );
406
+		$verifier->expects($this->any())->method('verify')->willReturn(true);
407 407
 
408 408
 		return $verifier;
409 409
 	}
Please login to merge, or discard this patch.