| @@ -12,8 +12,9 @@ | ||
| 12 | 12 | use Give\Framework\PaymentGateways\Contracts\Subscription\SubscriptionPausable; |
| 13 | 13 | use Give\Framework\PaymentGateways\Contracts\Subscription\SubscriptionPaymentMethodEditable; |
| 14 | 14 | use Give\Framework\PaymentGateways\Contracts\Subscription\SubscriptionTransactionsSynchronizable; |
| 15 | 15 | use Give\Framework\PaymentGateways\Contracts\WebhookNotificationsListener; |
| 16 | +use Give\Framework\PaymentGateways\DataTransferObjects\GatewayRouteData; | |
| 16 | 17 | use Give\Framework\PaymentGateways\Routes\RouteSignature; |
| 17 | 18 | use Give\Framework\PaymentGateways\Traits\HandleHttpResponses; |
| 18 | 19 | use Give\Framework\PaymentGateways\Traits\HasRouteMethods; |
| 19 | 20 | use Give\Framework\PaymentGateways\Webhooks\Webhook; |
| @@ -353,8 +354,10 @@ | ||
| 353 | 354 | |
| 354 | 355 | /** |
| 355 | 356 | * Generate secure gateway route url |
| 356 | 357 | * |
| 358 | + * @since 4.16.8 put the signed values on the URL encoded, so a raw value with an ampersand round-trips | |
| 359 | + * @since 4.16.8 cover $args with the signature | |
| 357 | 360 | * @since 2.19.5 replace nonce with hash and expiration |
| 358 | 361 | * @since 2.19.4 replace RouteSignature args with unique donationId |
| 359 | 362 | * @since 2.19.0 |
| 360 | 363 | */ |
| @@ -359,17 +362,22 @@ | ||
| 359 | 362 | * @since 2.19.0 |
| 360 | 363 | */ |
| 361 | 364 | public function generateSecureGatewayRouteUrl(string $gatewayMethod, int $donationId, array $args = []): string |
| 362 | 365 | { |
| 363 | - $signature = new RouteSignature(static::id(), $gatewayMethod, $donationId); | |
| 366 | + $args = RouteSignature::normalizeArgs(array_diff_key($args, array_flip(GatewayRouteData::ROUTE_PARAMS))); | |
| 364 | 367 | |
| 368 | + $signature = new RouteSignature(static::id(), $gatewayMethod, $donationId, null, $args); | |
| 369 | + | |
| 365 | 370 | return (new GenerateGatewayRouteUrl())( |
| 366 | 371 | static::id(), |
| 367 | 372 | $gatewayMethod, |
| 368 | - array_merge($args, [ | |
| 373 | + array_merge(RouteSignature::encodeArgs($args), [ | |
| 369 | 374 | 'give-route-signature' => $signature->toHash(), |
| 370 | 375 | 'give-route-signature-id' => $donationId, |
| 371 | 376 | 'give-route-signature-expiration' => $signature->expiration, |
| 377 | + // Named here so the route knows which args to rebuild the signature from, and so a gateway | |
| 378 | + // appending its own on the way back does not break it. The list is itself signed. | |
| 379 | + 'give-route-signature-args' => implode(',', $signature->argKeys), | |
| 372 | 380 | ]) |
| 373 | 381 | ); |
| 374 | 382 | } |
| 375 | 383 | |