-
Notifications
You must be signed in to change notification settings - Fork 43
Implement Subscriptions #364
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
base: 9.3.x
Are you sure you want to change the base?
Conversation
+ Created subscription related models + Integrated subscription actions into the main Client class + Added a convenience const to Env class for BitPay's datetime format + Added functional Subscription tests + Updated dependencies
+ Created subscription related models + Integrated subscription actions into the main Client class + Added a convenience const to Env class for BitPay's datetime format + Added functional Subscription tests + Updated dependencies
Thank you for the submission! We'll take a look and get this scheduled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can remove this file in favor of src/BitPaySDK/Model/Bill/Bill.php
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexstewartja I've taken a deeper look and I see that Bill
and BillData
won't be 1:1, however there's a lot of overlap. It could be worth considering extracting certain types to reduce duplication.
For example, they both have:
- currency
- items (which are
Bill/Item
) - number
- name
- address1
- address2
- city
- state
- zip
- country
- cc
- phone
- dueDate
- passProcessingFee
We could think about extracting these into an class such as CoreBill
and then extending it for Bill
and using it as a type in Subscription
for $billData
. I'm not sure that it's worth it, but wanted to see what folks think.
If that won't work, it's OK, just thinking it through and sharing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'm all for composition and adherence to DRY principles. We should definitely abstract away those repetitive fields. I'll put your suggestion into action later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @bobbrodie, there is no need for another class. All missing fields can be added to Bill\Bill or you can create a class that extends it to eliminate duplicates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can use src/BitPaySDK/Model/Bill/Bill.php
, we'll carry the reference to src/BitPaySDK/Model/Bill/Item.php
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexstewartja to clarify the above, Subscription/Item carries the same properties as Bill/Item, and fundamentally represent the same thing, so even if we don't extract core bill properties and extend, I think we can still consider using Bill/Item instead of Subscription/Item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support using Bill\Item instead of a separate class.
{ | ||
protected ?string $id = null; | ||
protected ?string $status = null; | ||
protected BillData $billData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's consider src/BitPaySDK/Model/Bill/Bill.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that they appear identical, but if this package is to be a pure abstraction over the API endpoints, then we have to account for the subtle differences in the structure/shape of Subscriptions vs Bills.
For example, the Create a Bill response data is unwrapped and relatively one-dimensional. On the other hand the Create a Subscription response data is wrapped in the billData
field, one level deep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'm sorry for not clarifying this a bit, @alexstewartja. This comment was for line 22. Currently, $billData
is typed to BillData
. We could keep $billData
of course, but maybe have it typed to a new type with just the core bill fields that are shared between Bill and Subscription. I think there are ~15 common fields.
Since a subscription is just a recurring bill, so BillData represents a Bill, albeit with fewer properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks for the clarification. I'll create a base/core model then inherit/extend from it to implement the specifics of Subscriptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @bobbrodie, there is no need for another class. All missing fields can be added to Bill\Bill or you can create a class that extends it to eliminate duplicates.
$this->number = $number; | ||
$this->currency = $currency ?: Currency::USD; | ||
$this->email = $email; | ||
$this->setEmailBill(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good idea to force emailBill in the constructor? Shouldn't this be controlled by the developer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support using Bill\Item instead of a separate class.
@@ -576,7 +578,7 @@ public function getBill(string $billId, string $facade = Facade::MERCHANT, bool | |||
* | |||
* @see https://developer.bitpay.com/reference/retrieve-bills-by-status Retrieve Bills by Status | |||
* | |||
* @param string|null The status to filter the bills. | |||
* @param $status string|null The status to filter the bills. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name should be after the type.
* | ||
* @see https://developer.bitpay.com/reference/retrieve-a-subscription Retrieve a Subscription | ||
* | ||
* @param $subscriptionId string The ID of the subscription to retrieve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
* | ||
* @see https://developer.bitpay.com/reference/retrieve-subscriptions-by-status Retrieve Subscriptions by Status | ||
* | ||
* @param $status string|null The status on which to filter the subscriptions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect order of type and var name
Core Changes
Subscription
related models and API clientAuxiliary Changes
SettlementStatus
class