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
[Backend Receipts] Network layer for receipt
endpoint
#11837
[Backend Receipts] Network layer for receipt
endpoint
#11837
Conversation
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
|
/// | ||
public func retrieveReceipt(siteID: Int64, | ||
orderID: Int64, | ||
forceRegenerate: Bool = true, |
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.
For the time being we intend to always force receipt regeneration when calling the endpoint, this might change later (specially if we end calling it upon view load or refresh control), but for the moment we'll pass true
as default parameter.
import Foundation | ||
|
||
public struct Receipt: Decodable { | ||
public let receiptURL: String |
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'm 50/50 about renaming this parameter from receiptURL
to receiptURLString
or similar. I went ahead with receiptURL
for consistency with the API, but I can see the case for being consistent with the data type on the client instead.
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 suppose the client will need to create URL
object from it? If we always need to create URL
on the client maybe we can do it when initializing Receipt
. Or we have receiptURLString
and have a computed property var receiptURL: URL?
?
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, at some point we'll create the URL object from it, but from my exploration we might not need it until the last moment in the presentation layer when we're actually invoking the WKWebView initializer with an URL(string: <url-goes-here>)
.
Since we also won't do any validation regarding the contents of the URL through the business layer, the rest of the app shouldn't care if this is a valid URL or not, the web view will either return a receipt or a 404/other messages when needed, so I think I'm happy to keep it as a simple String
while the data flows through the app, but the model can also map this to a different type as needed later on.
Only one reviewer is needed 🙇 |
Closes: #11825
Description
This PR adds the necessary network layer for the new
wc/v3/orders/<order-id>/receipt
endpoint, part of the Backend Receipts project ( pfoUAQ-b9-p2 ).The endpoint has not yet landed in WooCommerce core, but it's being worked on a development branch: woocommerce/woocommerce#43502 using
WooCommerce Version 8.6.0-dev-7625495467-gf50cc6b
From the app, we intend to submit a POST request to the endpoint, such as:
And expect a response that contains a
receipt_url
with an URL to the order receipt, as well as anexpiration_date
.Testing instructions
Still not being used. Unit tests should pass.