-
Notifications
You must be signed in to change notification settings - Fork 22
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
Bexio fixes #1119
Bexio fixes #1119
Conversation
PR 1119 with branch
|
} from './bexio-errors' | ||
import {addToStringReplaceMap, mapBexioStatusToPaymentStatus, searchForContact} from './bexio-utils' | ||
import fetch from 'node-fetch' |
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.
why is this imported here? I can't see it used in your changes
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 see it on line 150.
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.
it was added by me, but starting with node 18 there's no longer need to import fetch from node-fetch (it's included). But I think it's still ok, it can still be imported as a "fallback" if older version of node is used
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.
WePublish is no node 16 not 18...
paymentData: JSON.stringify(bexioResponse.data), | ||
customerID: bexioResponse.data.contact_id ? bexioResponse.data.contact_id.toString() : '' | ||
paymentID: payment.id, | ||
paymentData: JSON.stringify(bexioResponse), |
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.
are you sure that you don't want to dive into data
, just return response?
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.
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.
good
libs/payment/api/src/lib/payment-provider/bexio/bexio-payment-provider.ts
Show resolved
Hide resolved
Also please fix tests for bexio |
@@ -40,11 +40,18 @@ class NoSubscriptionIdInInvoice extends Error { | |||
} | |||
} | |||
|
|||
class PaymentNotFound extends Error { | |||
constructor(message = 'While checking intent, payment not found!') { |
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.
Looking at the error class name its message should not determine the reason why it's thrown.
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.
What is your proposal here?
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.
@tomaszdurka Can you give me more datails here?
} from './bexio-errors' | ||
import {addToStringReplaceMap, mapBexioStatusToPaymentStatus, searchForContact} from './bexio-utils' | ||
import fetch from 'node-fetch' |
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 see it on line 150.
@@ -232,7 +249,7 @@ export class BexioPaymentProvider extends BasePaymentProvider { | |||
|
|||
return { | |||
intentID: newInvoice.id.toString(), | |||
intentSecret: '', | |||
intentSecret: successURL, |
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.
Questions @elias-summermatter:
- Why are we storing things like
successUrl
in theintentSecret
? - Btw I understand this is something used by frontend website, right?
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 have a call about that. It's faster that way, just call me when you got time.
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.
Can we have a summary here? I guess it's for the redirect on the frontend?
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.
Sure. Intent is where the frontend is redirected to do the payment (for payrexx and stripe checkout). In case of Bexio the invoice is already created, so we just redirect the UI to the success url because in case of Bexio there is no extra action required on a bexio page. It allows bexio integration in the fronted without any significant changes.
const bexioInvoice: InvoicesStatic.InvoiceCreate = { | ||
title: isRenewal ? this.invoiceTitleRenewalMembership : this.invoiceTitleNewMembership, | ||
contact_id: contact.id, | ||
user_id: this.userId, | ||
mwst_type: 0, | ||
mwst_is_net: false, | ||
// Override for wrong library implementation! | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore |
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.
We hardly want to use ts-ignore so let's change add special type like:
type InvoiceCreate = Omit<InvoicesStatic.InvoiceCreate, 'api_reference'> & { "api_reference"?: string | null };
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 made a pr to the bexio library to fix that, as soon as the fix is deployed we can remove this hack but it was needed to be able to deploy and test it on hauptstadt site. Was never intended to stay in there:
mathewmeconry/bexio#61
@@ -122,7 +124,7 @@ export class BexioPaymentProvider extends BasePaymentProvider { | |||
* @returns {Promise<void>} Resolves when the remote invoice is successfully created. | |||
*/ | |||
async createRemoteInvoice(props: CreateRemoteInvoiceProps) { | |||
await this.bexioCreate(props.invoice.id, true) | |||
await this.bexioCreate('', props.invoice.id, 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.
Let's make successUrl
optional and not pass it here.
paymentData: JSON.stringify(bexioResponse.data), | ||
customerID: bexioResponse.data.contact_id ? bexioResponse.data.contact_id.toString() : '' | ||
paymentID: payment.id, | ||
paymentData: JSON.stringify(bexioResponse), |
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.
.env
Outdated
@@ -61,10 +61,11 @@ ENABLE_ANONYMOUS_COMMENTS=false | |||
|
|||
MAX_AUTO_RENEW_SUBSCRIPTION_BATCH=false | |||
|
|||
BEXIO_API_KEY=secret | |||
BEXIO_USER_ID=1 | |||
BEXIO_API_KEY=eyJraWQiOiI2ZGM2YmJlOC1iMjZjLTExZTgtOGUwZC0wMjQyYWMxMTAwMDIiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJtYXRoaWFzLnN0cmVpdEBoYXVwdHN0YWR0LmJlIiwibG9naW5faWQiOiI5ZmNlMTNkOS1hN2ZhLTRiZmItOWFhNy03ZmI0NjY1ZTMxOTMiLCJjb21wYW55X2lkIjoiam41ZXlmejF2dmV1IiwidXNlcl9pZCI6MzE0MDMzLCJhenAiOiJldmVybGFzdC10b2tlbi1vZmZpY2UtY2xpZW50Iiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCBhbGwgdGVjaG5pY2FsIiwiaXNzIjoiaHR0cHM6XC9cL2lkcC5iZXhpby5jb20iLCJleHAiOjMyNzg2NjQ4NDksImlhdCI6MTcwMTg2NDg0OSwiY29tcGFueV91c2VyX2lkIjoyLCJqdGkiOiI0OGM5ODg1ZS1hOTI2LTRlZTQtOTU0Zi02YTI1NGFiMDIwMGEifQ.ByaZmYhguwjFmzvkAXABwr4sFzMEPKID4clV7ygdpRNKbQ8FkoGmk0XWkyjW6q2pWOAeOQcwmw5p3uxkUtqMN8QsycW2Q4kFSlRxAu4SH69OqqypcaSmeBCI4UmewYjZykBEBpgBy0Ex9n9hkz9ty96Me-eRr4bVDS1CApEX7PVixLOMWkbgEySAA2S_JP9ZHdhzRqBfsLoIOK_DzZd-w8tGi29wPgjl4oTDmt_iokgg1lownQ0_UqhtvRLvGp_hJHMqiEpUryDhBLnHDWIPPofJf442ZeI1eQdAcN2vzdGAUxWpkztLfe1Q1_3WOBQvOs87pLGwprbcDSjbGnl1LmnPuj8tVRnBq4LtjMk1oC7v3gXDIjtyFNyPKNOFOrPDKJ-CIg25NwoGeZukQ4m2SrsSkAuGK2avuDZoU6Z9Krv9KvAw2JKJRfdvD2ICseIyaudgC2hRDk493G_auq2tM4nsqVWi_79owd2MhljqZazLGbBZAtS42soVTy4sUyy36mLbSTy5YXFVlXZysCLZEPa7ItNv3pGd4nQtww133GkOzgzBQzodW2EoWoxUnTssBk6L9c4f4wOiAOVGVH_1rAu-XloYHkvhlp--qO1nLXqjFUuS1Zgh8Vuof2L5LI1tKPR9T8SiqbvrNTlZAjnyOizK0R0c68JuJH1KulvD_t4 |
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.
Was this intended?
If you want to override specific env variables then you can create a .env.local
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.
Ou fuck... I revoked the key.... Thanks for noticing...
libs/payment/api/src/lib/payment-provider/bexio/bexio-payment-provider.ts
Outdated
Show resolved
Hide resolved
…provider.ts Co-authored-by: Itrulia <[email protected]>
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.
@antkiewiczk & @tomaszdurka can you review it again that we can merge it if ok. Thanks :-) |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1119 +/- ##
==========================================
+ Coverage 40.67% 41.03% +0.36%
==========================================
Files 296 296
Lines 7548 7554 +6
Branches 1561 1561
==========================================
+ Hits 3070 3100 +30
+ Misses 4312 4283 -29
- Partials 166 171 +5 ☔ View full report in Codecov by Sentry. |
} | ||
}) | ||
|
||
jest.mock('node-fetch', () => |
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.
👍
0450ff8
@antkiewiczk improved test coverage can you also review it :-) |
Isue is discuss and cleared
No description provided.