<?php
namespace Srmklive\PayPal\Tests\Unit\Client;
use GuzzleHttp\Utils;
use PHPUnit\Framework\TestCase;
use Srmklive\PayPal\Tests\MockClientClasses;
use Srmklive\PayPal\Tests\MockRequestPayloads;
use Srmklive\PayPal\Tests\MockResponsePayloads;
class InvoicesTest extends TestCase
{
use MockClientClasses;
use MockRequestPayloads;
use MockResponsePayloads;
/** @test */
public function it_can_generate_unique_invoice_number()
{
$expectedResponse = $this->mockGenerateInvoiceNumberResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/generate-next-invoice-number';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_create_a_draft_invoice()
{
$expectedResponse = $this->mockCreateInvoicesResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->createInvoiceParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_list_current_invoices()
{
$expectedResponse = $this->mockListInvoicesResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices?total_required=true';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_delete_an_invoice()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_update_an_invoice()
{
$expectedResponse = $this->mockUpdateInvoicesResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->updateInvoiceParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'put');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_show_details_for_an_invoice()
{
$expectedResponse = $this->mockGetInvoicesResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_cancel_an_invoice()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/cancel';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->cancelInvoiceParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_generate_qr_code_for_invoice()
{
$expectedResponse = $this->mockGenerateInvoiceNumberResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/generate-qr-code';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->generateQRCodeInvoiceParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_register_payment_for_invoice()
{
$expectedResponse = $this->mockInvoiceRegisterPaymentResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/payments';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->registerInvoicePaymentParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_delete_payment_for_invoice()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/payments/EXTR-86F38350LX4353815';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_refund_payment_for_invoice()
{
$expectedResponse = $this->mockInvoiceRefundPaymentResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/refunds';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->refundInvoicePaymentParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_delete_refund_for_invoice()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-333R-YUQL-YNNN-D7WF/refunds/EXTR-2LG703375E477444T';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_send_an_invoice()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-EHNV-LJ5S-A7DZ-V6NJ/send';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->sendInvoiceParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_send_reminder_for_an_invoice()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/remind';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->sendInvoiceReminderParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
}
At NFC Pay, your privacy is of utmost importance to us. This Privacy Policy outlines how we collect, use, share, and protect your personal information when you use our services, including our website and mobile applications.
1. Information We Collect
2. How We Use Your Information
We use the information we collect for the following purposes:
3. Sharing Your Information
We may share your personal information in the following circumstances:
4. Security of Your Information
We take the security of your personal information seriously and implement a variety of security measures, including encryption, secure servers, and access controls, to protect your data from unauthorized access, disclosure, alteration, or destruction. However, no method of transmission over the internet or electronic storage is completely secure, and we cannot guarantee its absolute security.
5. Your Privacy Rights
Depending on your location, you may have certain rights regarding your personal information, such as:
6. Third-Party Links
Our services may contain links to third-party websites or services. We are not responsible for the privacy practices or the content of these third-party sites. We encourage you to review the privacy policies of those third parties.
7. Children’s Privacy
Our services are not intended for individuals under the age of 13. We do not knowingly collect personal information from children under 13. If we become aware that we have collected personal information from a child under 13, we will take steps to delete that information.
8. Changes to This Privacy Policy
We may update this Privacy Policy from time to time to reflect changes in our practices or for other operational, legal, or regulatory reasons. We will notify you of any significant changes by posting the new Privacy Policy on our website and updating the effective date.
9. Contact Us
If you have any questions or concerns about this Privacy Policy or our data practices, please contact us at:
Email: support@nfcpay.com