We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm trying to create a new transaction using the SDK but I keep running in to an error:
{ "field": "billing_period.starts_at", "error": "Invalid type. Expected: string, given: object" }, { "field": "billing_period.ends_at", "error": "Invalid type. Expected: string, given: object" }
Here is my transaction logic:
$transactionData = new CreateTransaction( items: $items, customerId: $this->transaction->customer->paddle_id ?? null, addressId: $this->transaction->address->paddle_id ?? null, businessId: $this->transaction->business->paddle_id ?? null, currencyCode: new CurrencyCode( $this->transaction->currency_code ), collectionMode: new CollectionMode( $this->transaction->collection_mode ), discountId: $this->transaction->discount->paddle_id ?? null, billingDetails: new BillingDetails( enableCheckout: $this->transaction->enable_checkout, paymentTerms: new TimePeriod( interval: Interval::from( $this->transaction->terms_interval ), frequency: $this->transaction->terms_frequency, ), purchaseOrderNumber: $this->transaction->purchase_order_number ?? null, additionalInformation: $this->transaction->additional_information ?? '', ), billingPeriod: TransactionTimePeriod::from([ 'starts_at' => new DateTimeImmutable($this->transaction->starts_at), 'ends_at' => new DateTimeImmutable($this->transaction->ends_at) ]), customData: new CustomData([ 'transaction_id' => $this->transaction->id, 'customer_id' => $this->transaction->customer->id, ]) ); // Log the serialized data Log::info('Transaction Data: ' . json_encode($transactionData));
And the output:
{ "items": [ { "quantity": 1, "price_id": "pri_abc" } ], "customer_id": "ctm_abc", "address_id": "add_abc", "business_id": "biz_abc", "custom_data": { "transaction_id": 2, "customer_id": 1 }, "currency_code": "USD", "collection_mode": "manual", "discount_id": null, "billing_details": { "enableCheckout": true, "paymentTerms": { "interval": "day", "frequency": 28 }, "purchaseOrderNumber": "TEST-PO-123", "additionalInformation": "" }, "billing_period": { "startsAt": { "date": "2024-08-23 10:07:00.000000", "timezone_type": 2, "timezone": "Z" }, "endsAt": { "date": "2025-08-23 10:07:00.000000", "timezone_type": 2, "timezone": "Z" } } }
I could be completely missing something but I've trawled through the classes and can't get my head around it.
CreateTransaction
I would expect to be able to access the billingPeriod params like so:
billingPeriod: new TransactionTimePeriod( startsAt: $this->transaction->starts_at, endsAt: $this->transaction->ends_at )
But I can't because the constructor of the TransactionTimePeriod class is private.
TransactionTimePeriod
Instead, I have to use the ::from method which causes the serialization error.
::from
I think the constructor on the TransactionTimePeriod class should be public and if you're in agreement I can submit a PR.
No response
8.3.10
1.1.1
1
If there's an intended usage pattern that I may be missing or another recommended approach to avoid this issue, please let me know.
The text was updated successfully, but these errors were encountered:
Fixes issues: TransactionTimePeriod - should it be public constructor? …
18544b1
…PaddleHQ#60
Hey @dutypro I think you are correct, thank you so much for opening a PR to fix this, I will approve it and bump the version ❤️
Sorry, something went wrong.
92634f6
…#60 (#61)
@dutypro closing this issue, changes got released see v.1.1.2 release, thanks again for your contribution.
vifer
No branches or pull requests
Describe the bug
I'm trying to create a new transaction using the SDK but I keep running in to an error:
Here is my transaction logic:
And the output:
I could be completely missing something but I've trawled through the classes and can't get my head around it.
Steps to reproduce
CreateTransaction
method.Expected behavior
I would expect to be able to access the billingPeriod params like so:
But I can't because the constructor of the
TransactionTimePeriod
class is private.Instead, I have to use the
::from
method which causes the serialization error.I think the constructor on the
TransactionTimePeriod
class should be public and if you're in agreement I can submit a PR.Code snippets
No response
PHP version
8.3.10
SDK version
1.1.1
API version
1
Additional context
If there's an intended usage pattern that I may be missing or another recommended approach to avoid this issue, please let me know.
The text was updated successfully, but these errors were encountered: