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

default_invoice_memo should be an Option #47

Closed
sjmiller609 opened this issue Aug 30, 2024 · 0 comments
Closed

default_invoice_memo should be an Option #47

sjmiller609 opened this issue Aug 30, 2024 · 0 comments

Comments

@sjmiller609
Copy link
Contributor

On a Subscription, the default_invoice_memo should be an Option. It will use the Subscription's memo if that exists, otherwise use the Plan's memo if that exists, otherwise the server returns null.

pub default_invoice_memo: String,

This problem does not occur when Subscriptions include memos or when Plans include memos. When neither includes a memo, then the client will fail to deserialize the response, for example in the case of create_subscription it will fail to deserialize and error out, but the request works.

pub async fn create_subscription(
&self,
subscription: &CreateSubscriptionRequest<'_>,
) -> Result<Subscription, Error> {
let mut req = self.build_request(Method::POST, SUBSCRIPTIONS_PATH);
if let Some(key) = subscription.idempotency_key {
req = req.header("Idempotency-Key", key);
}
let req = req.json(subscription);
let res = self.send_request(req).await?;
Ok(res)
}

I noticed this while adding my test for cancel subscription because in the test file, it assumes the existence of a plan in Orb.

plan_id: orb_billing::PlanId::External("test"),

I did not have that plan, so I created it. That reproduced this issue. Since this issue is not related to adding cancel subscription to this SDK, I just added a memo on my Plan to avoid the issue in that PR.

@sjmiller609 sjmiller609 changed the title Billing memo should be Option default_invoice_memo should be an Option Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant