mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Do not send Paypal-Request-Id
The current usage is incorrect and only causes issues without solving any problems (we don't implement any way to retry requests).
This commit is contained in:
parent
d23a33e4c2
commit
2f6240bfb4
9 changed files with 18 additions and 312 deletions
|
@ -24,7 +24,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PatchCollectionFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\ErrorResponse;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayPalRequestIdRepository;
|
||||
use Mockery;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
|
@ -67,9 +66,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldNotReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order_id')->with($orderId)->andReturn('uniqueRequestId');
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
@ -82,7 +78,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -128,9 +123,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order_id')->with($orderId)->andReturn('uniqueRequestId');
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
@ -143,7 +135,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -182,9 +173,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order_id')->with($orderId)->andReturn('uniqueRequestId');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = new OrderEndpoint(
|
||||
|
@ -195,7 +183,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -248,9 +235,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldNotReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order')->with($orderToCapture)->andReturn('uniqueRequestId');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = new OrderEndpoint(
|
||||
|
@ -261,7 +245,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -317,7 +300,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('log');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = new OrderEndpoint(
|
||||
|
@ -328,7 +310,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -360,9 +341,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order')->with($orderToCapture)->andReturn('uniqueRequestId');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = new OrderEndpoint(
|
||||
|
@ -373,7 +351,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
|
@ -412,9 +389,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order')->with($orderToCapture)->andReturn('uniqueRequestId');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = new OrderEndpoint(
|
||||
|
@ -425,7 +399,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -466,9 +439,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldNotReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order')->with($orderToCapture)->andReturn('uniqueRequestId');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = Mockery::mock(
|
||||
|
@ -481,7 +451,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper,
|
||||
]
|
||||
)->makePartial();
|
||||
|
@ -546,9 +515,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldNotReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order')->with($orderToUpdate)->andReturn('uniqueRequestId');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = Mockery::mock(
|
||||
|
@ -561,7 +527,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper,
|
||||
]
|
||||
)->makePartial();
|
||||
|
@ -588,9 +553,6 @@ class OrderEndpointTest extends TestCase
|
|||
if ($args['headers']['Prefer'] !== 'return=representation') {
|
||||
return false;
|
||||
}
|
||||
if ($args['headers']['PayPal-Request-Id'] !== 'uniqueRequestId') {
|
||||
return false;
|
||||
}
|
||||
$body = json_decode($args['body']);
|
||||
if (! is_array($body) || $body[0] !== 'patch-1' || $body[1] !== 'patch-2') {
|
||||
return false;
|
||||
|
@ -651,9 +613,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order')->with($orderToUpdate)->andReturn('uniqueRequestId');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = new OrderEndpoint(
|
||||
|
@ -664,7 +623,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -686,9 +644,6 @@ class OrderEndpointTest extends TestCase
|
|||
if ($args['headers']['Prefer'] !== 'return=representation') {
|
||||
return false;
|
||||
}
|
||||
if ($args['headers']['PayPal-Request-Id'] !== 'uniqueRequestId') {
|
||||
return false;
|
||||
}
|
||||
$body = json_decode($args['body']);
|
||||
if (! is_array($body) || $body[0] !== 'patch-1' || $body[1] !== 'patch-2') {
|
||||
return false;
|
||||
|
@ -750,9 +705,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldReceive('debug');
|
||||
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('get_for_order')->with($orderToUpdate)->andReturn('uniqueRequestId');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = Mockery::mock(
|
||||
|
@ -765,7 +717,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
]
|
||||
)->makePartial();
|
||||
|
@ -788,9 +739,6 @@ class OrderEndpointTest extends TestCase
|
|||
if ($args['headers']['Prefer'] !== 'return=representation') {
|
||||
return false;
|
||||
}
|
||||
if ($args['headers']['PayPal-Request-Id'] !== 'uniqueRequestId') {
|
||||
return false;
|
||||
}
|
||||
$body = json_decode($args['body']);
|
||||
if (! is_array($body) || $body[0] !== 'patch-1' || $body[1] !== 'patch-2') {
|
||||
return false;
|
||||
|
@ -828,7 +776,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('log');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$testee = new OrderEndpoint(
|
||||
|
@ -839,7 +786,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -889,15 +835,6 @@ class OrderEndpointTest extends TestCase
|
|||
->expects('current_context')
|
||||
->with(Matchers::identicalTo(ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING))
|
||||
->andReturn($applicationContext);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('set_for_order')->andReturnUsing(function ($order, $id) use ($expectedOrder) : bool {
|
||||
if ($order !== $expectedOrder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strpos($id, 'ppcp') !== false;
|
||||
});
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
$subscription_helper->shouldReceive('cart_contains_subscription')->andReturn(true);
|
||||
|
||||
|
@ -909,7 +846,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -998,15 +934,6 @@ class OrderEndpointTest extends TestCase
|
|||
->expects('current_context')
|
||||
->with(Matchers::identicalTo(ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE))
|
||||
->andReturn($applicationContext);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$paypalRequestIdRepository
|
||||
->expects('set_for_order')->andReturnUsing(function ($order, $id) use ($expectedOrder) : bool {
|
||||
if ($order !== $expectedOrder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strpos($id, 'ppcp') !== false;
|
||||
});
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
$subscription_helper->shouldReceive('cart_contains_subscription')->andReturn(true);
|
||||
|
||||
|
@ -1018,7 +945,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -1084,7 +1010,6 @@ class OrderEndpointTest extends TestCase
|
|||
->expects('current_context')
|
||||
->with(Matchers::identicalTo(ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING))
|
||||
->andReturn($applicationContext);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
$subscription_helper->shouldReceive('cart_contains_subscription')->andReturn(true);
|
||||
|
||||
|
@ -1096,7 +1021,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -1173,7 +1097,6 @@ class OrderEndpointTest extends TestCase
|
|||
->expects('current_context')
|
||||
->with(Matchers::identicalTo(ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE))
|
||||
->andReturn($applicationContext);
|
||||
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
$subscription_helper->shouldReceive('cart_contains_subscription')->andReturn(true);
|
||||
|
||||
|
@ -1185,7 +1108,6 @@ class OrderEndpointTest extends TestCase
|
|||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$paypalRequestIdRepository,
|
||||
$subscription_helper
|
||||
);
|
||||
|
||||
|
@ -1229,3 +1151,4 @@ class OrderEndpointTest extends TestCase
|
|||
$testee->create([$purchaseUnit], ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE, $payer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue