-
Notifications
You must be signed in to change notification settings - Fork 9
New order API endpoints - v1.2 #30
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: master
Are you sure you want to change the base?
Conversation
PAY-34: Setup local development
…ange TypeScript target to ES2022 # Conflicts: # tsconfig.json
PAY-36: Add jest testing
PAY-38: Added github actions setup
PAY-37: setup connect API client
PAY-35: Add order create
# Conflicts: # src/connect/order/OrderApi.ts
PAY-53: Improve API test assertions
Co-authored-by: Max Hoogenbosch <[email protected]>
Co-authored-by: Max Hoogenbosch <[email protected]>
Co-authored-by: Max Hoogenbosch <[email protected]>
changelog and upgrade guide
update readme with orders
Make sure orderId is used instead of order ID for backward compatability
add service config API
README.md
Outdated
| ```typescript | ||
| payNL.Transaction.start({ | ||
| //the amount in euro | ||
| amount: 19.95, |
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.
Dit moet cents zijn, toch?
https://developer.pay.nl/v2.0/reference/post_transactions-1
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.
Dit is de oude(re) API, dus deze docs: https://docs.pay.nl/developers
Maar daar staat het ook dat het in centen moet, dus dat hebben we niet goed gecontroleerd.
README.md
Outdated
| // Start transaction and send to the terminal | ||
| Paynl.Transaction.start({ | ||
| payNL.Transaction.start({ | ||
| amount: 0.01, |
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.
Idem
| return; | ||
| } | ||
| } | ||
| if (response.statusCode !== 200) { |
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.
Wordt 201 nooit gebruikt?
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.
Dit is de oude API die we opnieuw geformat hebben maar niet aangepast, dus dat kan ik je niet zeggen.
| private static apiToken: string; | ||
| private static serviceId: string; | ||
| private static baseUrl = "https://rest-api.pay.nl"; | ||
| private static baseUrl = 'https://rest-api.pay.nl'; |
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.
Wat leeft hier? Ik ken alleen rest.pay.nl en gms-api.tinpay.nl, is dit voor de oude transactie apis? Als dat zo is, was dat een requirement?
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.
Dit is de oude API inderdaad: https://docs.pay.nl/developers
Alles daarvoor hebben we in deze versie niet aangepast, alleen linting is erover gegaan. Zie de andere PR (en de changelog en upgrade guide) voor de complete migratie waarbij dit verdwenen is.
| } | ||
|
|
||
| function configureBackwardsCompatibleApi(options: ClientOptions) { | ||
| Paynl.Config.setApiToken(options.apiToken); |
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.
Welke format krijgt de apiToken, moet de gebruiker hier AT:at-secret inzetten?
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.
Nee dit is de token (zo word het in my.pay.nl genoemd). Zal er ongeveer zo uit zien :) ****************************************
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.
Er zijn meerdere type tokens, je kan authen via at:at-secret, SL-code:SL-secret, of username/auth JWT tokens. Maar als Wesley het goed vind, maakt het mij niet uit :)
| var data = {}; | ||
| const data = {}; | ||
|
|
||
| data['amount'] = Math.round(this.amount * 100); |
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.
Als je door de gehele SDK gewoon centen aanhoud, hoef je dit niet te doen. Krijg je ook geen gedoe met afrondingsfoutjes
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 wilden in deze versie niks aanpassen aan de bestaande oude code.
| } | ||
| private formatDateTime(date: Date) { | ||
| return dateFormat(date, 'dd-mm-yyyy hh:MM:ss'); | ||
| return dateFormat(date, 'dd-mm-yyyy hh:MM:ss'); |
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.
Slikt de API niet gewoon de return van date.toISOString
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 wilden in deze versie niks aanpassen aan de bestaande oude code.
| if (this.bankaccountBic) data['bankaccountBic'] = this.bankaccountBic; | ||
| if (this.processDate) data['processDate'] = this.formatDate(this.processDate); | ||
| if (this.description) data['description'] = this.description; | ||
| if (this.ipAddress) data['ipAddress'] = this.ipAddress; | ||
| if (this.email) data['email'] = this.email; | ||
| if (this.promotorId) data['promotorId'] = this.promotorId; | ||
| if (this.tool) data['tool'] = this.tool; | ||
| if (this.info) data['info'] = this.info; | ||
| if (this.object) data['object'] = this.object; | ||
| if (this.extra1) data['extra1'] = this.extra1; | ||
| if (this.extra2) data['extra2'] = this.extra2; | ||
| if (this.extra3) data['extra3'] = this.extra3; | ||
| if (this.currency) data['currency'] = this.currency; | ||
| if (this.exchangeUrl) data['exchangeUrl'] = this.exchangeUrl; |
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.
Waarvoor dient dit?
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 wilden in deze versie niks aanpassen aan de bestaande oude code. Dit is enkel linting/formatting die is toegepast.
| /** | ||
| * The id of the paymentmethod. | ||
| * Use PaymentMethods.getList() to retrieve the available paymentmethods | ||
| * Use PaymentMethods.getList() to retrieve the available paymentmethods |
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.
Wil je hier niet de paymentmethods van de saleslocation gebruiken?
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 wilden in deze versie niks aanpassen aan de bestaande oude code.
| private calculateVatCode(priceIncl, vatAmount) { | ||
| var vatCodes = { 0: 'N', 9: 'L', 21: 'H' }; | ||
| var priceExcl = priceIncl - vatAmount; | ||
| const vatCodes = { 0: 'N', 9: 'L', 21: 'H' }; | ||
| const priceExcl = priceIncl - vatAmount; | ||
| if (!vatAmount || vatAmount == 0 || !priceIncl || priceIncl == 0) { | ||
| return vatCodes[0]; | ||
| } | ||
|
|
||
| var vatRate = (vatAmount / priceExcl) * 100; | ||
| const vatRate = (vatAmount / priceExcl) * 100; | ||
|
|
||
| var closest = Object.keys(vatCodes).reduce( | ||
| (prev, curr) => { | ||
| var prevFloat = parseFloat(prev); | ||
| var currFloat = parseFloat(curr); | ||
| return (Math.abs(currFloat - vatRate) < Math.abs(prevFloat - vatRate) ? curr : prev); | ||
| }); | ||
| const closest = Object.keys(vatCodes).reduce((prev, curr) => { | ||
| const prevFloat = parseFloat(prev); | ||
| const currFloat = parseFloat(curr); | ||
| return Math.abs(currFloat - vatRate) < Math.abs(prevFloat - vatRate) ? curr : prev; | ||
| }); |
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.
Waarom mag de user een vatAmount invullen, ipv door de hele sdk gewoon die N L H toepassen? Is dit voor compatibiliteit
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 wilden in deze versie niks aanpassen aan de bestaande oude code.
|
Bedankt voor je review zo ver @Joep-Scenius! Zoals je ziet heb je deels ook de bestaande code gereviewed, dat laten we hier dus even voor wat het is. |
|
Oeps, dat had ik niet helemaal door. Lekker laten zitten inderdaad. In je andere PR moet alles wel 100% toch? |
|
Snap ik goed, no worries! Ja in de andere PR is wel alles door ons geschreven 👍 |
- Use cents where possible - Update type declarations of service config - Remove template literals to improve DX
|
Ziet er goed uit! Kunnen jullie een seintje geven als alles is verwerkt? (Waar nodig) dan kun je wel mergen denk ik |
PAY-66: Resolved feedback on v1.2.0
|
@Joep-Scenius ik heb zojuist je feedback verwerkt, kan je er nog een keer naar kijken? |
Description
How to test
bun run ./examples/connect/createOrder.tsornpx ts-node ./examples/connect/createOrder.ts)npm installnpm run testand see tests succeednpm run lintto see linting succeedReleasing