Skip to content

Conversation

@Jeroen-G
Copy link
Contributor

@Jeroen-G Jeroen-G commented Sep 1, 2025

Description

  • Added the order endpoints for the Transaction Gateway Unit API.
  • Automated tests and linting (run on this repo as soon as this PR is merged)
  • A PR template

How to test

  • Have node and npm installed. To run the examples you can use a setup with e.g. npm or bun, for example: bun run ./examples/connect/createOrder.ts or npx ts-node ./examples/connect/createOrder.ts)
  • npm install
  • Run npm run test and see tests succeed
  • Run npm run lint to see linting succeed
  • Get an API token and service location ID
  • Try out the examples from `./examples/connect
  • Try out the examples from other example folders to verify that the old API is still accessible

Releasing

  • merge this PR
  • create a release v1.2 with the notes from the changelog

Xammie and others added 30 commits August 21, 2025 11:42
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
@Jeroen-G Jeroen-G changed the title New order API endpoints New order API endpoints - v1.2 Sep 2, 2025
Jeroen-G and others added 2 commits September 2, 2025 10:39
@Jeroen-G Jeroen-G mentioned this pull request Sep 2, 2025
6 tasks
README.md Outdated
```typescript
payNL.Transaction.start({
//the amount in euro
amount: 19.95,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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,

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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wordt 201 nooit gebruikt?

Copy link
Contributor Author

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';

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?

Copy link
Contributor Author

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);

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?

Copy link
Contributor

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 :) ****************************************

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);

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

Copy link
Contributor Author

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');

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

Copy link
Contributor Author

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.

Comment on lines +44 to +57
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waarvoor dient dit?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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.

Comment on lines 149 to +168
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;
});

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

Copy link
Contributor Author

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.

@Jeroen-G
Copy link
Contributor Author

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.

@Joep-Scenius
Copy link

Oeps, dat had ik niet helemaal door. Lekker laten zitten inderdaad. In je andere PR moet alles wel 100% toch?

@Jeroen-G
Copy link
Contributor Author

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
@Joep-Scenius
Copy link

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
@Xammie
Copy link
Contributor

Xammie commented Oct 1, 2025

@Joep-Scenius ik heb zojuist je feedback verwerkt, kan je er nog een keer naar kijken?

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

Successfully merging this pull request may close these issues.

3 participants