Skip to content

Releases: LucaDiba/satispay-client

v1.0.1

09 Dec 00:16
bccca51
Compare
Choose a tag to compare

Patch Changes

v1.0.0

21 Feb 05:24
81b7b6f
Compare
Choose a tag to compare

Major Changes

  • d66664d: # Breaking changes

    Errors

    Before this change, the library returned the following object for all the Client requests:

    const paymentResponse = await satispay.payments.create({
      flow: "MATCH_CODE",
      amountUnit: 100,
      currency: "EUR",
    });
    
    /**
     * paymentResponse: {
     *   success: true,
     *   data: {
     *     ...
     *   }
     * } | {
     *   success: false,
     *   error: {
     *     ...
     *   }
     * }
     */
    
    if (paymentResponse.success) {
      const payment = paymentResponse.data;
    
      // Save the payment id
      const paymentId = payment.id;
    
      // Redirect the user to the redirectUrl
      const redirectUrl = payment.redirect_url;
    
      // ...
    } else {
      // Handle the error
      const error = paymentResponse.error;
    }

    After this change, the library will directly throw an error if the request fails.
    If the request is successful, the library will return the successful response.

    try {
      const payment = await satispay.payments.create({
        flow: "MATCH_CODE",
        amountUnit: 100,
        currency: "EUR",
      });
    
      // Save the payment id
      const paymentId = payment.id;
    
      // Redirect the user to the redirectUrl
      const redirectUrl = payment.redirect_url;
    
      // ...
    } catch (error) {
      // Handle the error
    }

    The error type SatispayError has been introduced. It extends the Error class and has the following properties:

    • name: string - The error name
    • message: string - The error message
    • code: string - The error code
    • status: number - The HTTP status code

    It is possible to check the error type using the isSatispayError utility function.
    If the result is true, the error type SatispayError is automatically inferred.

    import { SatispayError } from "@lucadiba/satispay-client";
    
    try {
      // ...
    } catch (error) {
      if (SatispayError.isSatispayError(error)) {
        // The SatispayError type is automatically inferred to the error variable
      } else {
        // The type of the error variable is unknown
      }
    }

v0.1.6

12 Nov 00:46
3eb7b39
Compare
Choose a tag to compare
v0.1.6 Pre-release
Pre-release

Patch Changes

v0.1.5

11 Sep 00:43
2b41162
Compare
Choose a tag to compare
v0.1.5 Pre-release
Pre-release

Patch Changes

  • 99fa769: Add metadata to "create payment"

v0.1.4

10 Sep 18:01
761ca03
Compare
Choose a tag to compare
v0.1.4 Pre-release
Pre-release

Patch Changes

  • 59a72b1: Fix timezone offset when signing request

v0.1.3

09 Sep 05:03
Compare
Choose a tag to compare
v0.1.3 Pre-release
Pre-release

Patch Changes