Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove import_meta from transaction #76

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx
### Added

- Added `product` to `subscription.items[]`, see [related changelog](https://developer.paddle.com/changelog/2024/subscription-items-product?utm_source=dx&utm_medium=paddle-php-sdk)
- Added `import_meta` to `transaction`
- Support for `createdAt` and `updatedAt` on Subscription notification prices
- Support custom prices when updating and previewing subscriptions, see [related changelog](https://developer.paddle.com/changelog/2024/add-custom-items-subscription)
- `TransactionsClient::getInvoicePDF` now supports `disposition` parameter, see [related changelog](https://developer.paddle.com/changelog/2024/invoice-pdf-open-in-browser)
Expand Down
3 changes: 0 additions & 3 deletions src/Entities/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Paddle\SDK\Entities\Shared\CollectionMode;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\ImportMeta;
use Paddle\SDK\Entities\Shared\TransactionOrigin;
use Paddle\SDK\Entities\Shared\TransactionPaymentAttempt;
use Paddle\SDK\Entities\Shared\TransactionStatus;
Expand Down Expand Up @@ -65,7 +64,6 @@ private function __construct(
public Customer|null $customer,
public Discount|null $discount,
public array $availablePaymentMethods,
public ImportMeta|null $importMeta,
) {
}

Expand Down Expand Up @@ -102,7 +100,6 @@ public static function from(array $data): self
customer: isset($data['customer']) ? Customer::from($data['customer']) : null,
discount: isset($data['discount']) ? Discount::from($data['discount']) : null,
availablePaymentMethods: array_map(fn (string $item): AvailablePaymentMethods => AvailablePaymentMethods::from($item), $data['available_payment_methods'] ?? []),
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,11 @@ public static function cancelOperationsProvider(): \Generator
* @dataProvider getPaymentMethodChangeTransactionRequestProvider
*/
public function get_payment_method_change_transaction_hits_expected_uri(
string $id,
ResponseInterface $response,
string $expectedUri,
): void {
$this->mockClient->addResponse($response);
$this->client->subscriptions->getPaymentMethodChangeTransaction($id);
$this->client->subscriptions->getPaymentMethodChangeTransaction('sub_01h7zcgmdc6tmwtjehp3sh7azf');
$request = $this->mockClient->getLastRequest();

self::assertInstanceOf(RequestInterface::class, $request);
Expand All @@ -461,28 +460,11 @@ public function get_payment_method_change_transaction_hits_expected_uri(
public static function getPaymentMethodChangeTransactionRequestProvider(): \Generator
{
yield 'Basic' => [
'sub_01h7zcgmdc6tmwtjehp3sh7azf',
new Response(200, body: self::readRawJsonFixture('response/get_payment_method_change_transaction_entity')),
sprintf('%s/subscriptions/sub_01h7zcgmdc6tmwtjehp3sh7azf/update-payment-method-transaction', Environment::SANDBOX->baseUrl()),
];
}

/**
* @test
*/
public function get_payment_method_change_transaction_has_import_meta(): void
{
$this->mockClient->addResponse(
new Response(200, body: self::readRawJsonFixture('response/get_payment_method_change_transaction_entity_with_import_meta')),
);

$transaction = $this->client->subscriptions->getPaymentMethodChangeTransaction('sub_01h7zcgmdc6tmwtjehp3sh7azf');

self::assertNotNull($transaction->importMeta);
self::assertSame('billing_platform', $transaction->importMeta->importedFrom);
self::assertSame('9b95b0b8-e10f-441a-862e-1936a6d818ab', $transaction->importMeta->externalId);
}

/**
* @test
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -382,27 +382,6 @@ public static function listOperationsProvider(): \Generator
];
}

/**
* @test
*/
public function list_has_import_meta(): void
{
$this->mockClient->addResponse(
new Response(200, body: self::readRawJsonFixture('response/list_default')),
);

$transactionCollection = $this->client->transactions->list(new ListTransactions());
$transactions = array_values(iterator_to_array($transactionCollection));

$transactionWithoutImportMeta = $transactions[0];
self::assertNull($transactionWithoutImportMeta->importMeta);

$transactionWithImportMeta = $transactions[1];
self::assertNotNull($transactionWithImportMeta->importMeta);
self::assertSame('billing_platform', $transactionWithImportMeta->importMeta->importedFrom);
self::assertSame('9b95b0b8-e10f-441a-862e-1936a6d818ab', $transactionWithImportMeta->importMeta->externalId);
}

/**
* @test
*
Expand Down Expand Up @@ -439,34 +418,6 @@ public static function getRequestProvider(): \Generator
];
}

/**
* @test
*/
public function get_has_import_meta(): void
{
$this->mockClient->addResponse(
new Response(200, body: self::readRawJsonFixture('response/full_entity_with_import_meta')),
);
$transaction = $this->client->transactions->get('txn_01hen7bxc1p8ep4yk7n5jbzk9r');

self::assertNotNull($transaction->importMeta);
self::assertSame('billing_platform', $transaction->importMeta->importedFrom);
self::assertSame('9b95b0b8-e10f-441a-862e-1936a6d818ab', $transaction->importMeta->externalId);
}

/**
* @test
*/
public function get_has_no_import_meta(): void
{
$this->mockClient->addResponse(
new Response(200, body: self::readRawJsonFixture('response/full_entity')),
);
$transaction = $this->client->transactions->get('txn_01hen7bxc1p8ep4yk7n5jbzk9r');

self::assertNull($transaction->importMeta);
}

/**
* @test
*
Expand Down
Loading
Loading