OrderPaypalPaymentDetailsTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. use Webkul\Paypal\Helpers\PaypalPaymentDetails;
  3. use Webkul\Sales\Models\Order;
  4. use Webkul\Sales\Models\OrderPayment;
  5. use function Pest\Laravel\get;
  6. it('maps magento paypal additional labels for the admin order view', function () {
  7. $rows = PaypalPaymentDetails::rows([
  8. 'paypal' => [
  9. 'Payer ID' => 'S856CN296A3NY',
  10. 'Payer Email' => 'ms.karlotta@gmail.com',
  11. 'Payer Status' => 'unverified',
  12. 'Payer Address Status' => 'confirmed',
  13. 'Merchant Protection Eligibility' => 'Eligible',
  14. 'Last Correlation ID' => '4daa479620025',
  15. 'Last Transaction ID' => '9L903472H6583463Y',
  16. ],
  17. ]);
  18. expect($rows)->toHaveCount(7)
  19. ->and($rows[0])->toMatchArray([
  20. 'label' => trans('paypal::app.order.payer-id'),
  21. 'value' => 'S856CN296A3NY',
  22. ])
  23. ->and($rows[1]['value'])->toBe('ms.karlotta@gmail.com')
  24. ->and($rows[6]['value'])->toBe('9L903472H6583463Y');
  25. });
  26. it('falls back to paypal_* keys when the labeled paypal map is missing', function () {
  27. $rows = PaypalPaymentDetails::rows([
  28. 'paypal_payer_id' => 'S856CN296A3NY',
  29. 'paypal_payer_email' => 'ms.karlotta@gmail.com',
  30. 'last_trans_id' => '9L903472H6583463Y',
  31. 'asteria_payment_id' => 99,
  32. ]);
  33. expect(collect($rows)->pluck('value')->all())->toBe([
  34. 'S856CN296A3NY',
  35. 'ms.karlotta@gmail.com',
  36. '9L903472H6583463Y',
  37. ]);
  38. });
  39. it('should display paypal additional payment details on the admin order view', function () {
  40. $order = Order::factory()->create();
  41. OrderPayment::factory()->create([
  42. 'order_id' => $order->id,
  43. 'method' => 'paypal_standard',
  44. 'additional' => [
  45. 'magento_method' => 'paypal_express',
  46. 'last_trans_id' => '9L903472H6583463Y',
  47. 'paypal' => [
  48. 'Payer ID' => 'S856CN296A3NY',
  49. 'Payer Email' => 'ms.karlotta@gmail.com',
  50. 'Payer Status' => 'unverified',
  51. 'Payer Address Status' => 'confirmed',
  52. 'Merchant Protection Eligibility' => 'Eligible',
  53. 'Last Correlation ID' => '4daa479620025',
  54. 'Last Transaction ID' => '9L903472H6583463Y',
  55. ],
  56. ],
  57. ]);
  58. $this->loginAsAdmin();
  59. get(route('admin.sales.orders.view', $order->id))
  60. ->assertOk()
  61. ->assertSeeText(trans('paypal::app.order.payer-id'))
  62. ->assertSeeText('S856CN296A3NY')
  63. ->assertSeeText('ms.karlotta@gmail.com')
  64. ->assertSeeText('unverified')
  65. ->assertSeeText('Eligible')
  66. ->assertSeeText('4daa479620025')
  67. ->assertSeeText('9L903472H6583463Y');
  68. });