Giter Club home page Giter Club logo

stripe-haskell-library's Introduction

Stripe-Haskell-Library

CircleCI

This code is auto-generated by Haskell-OpenAPI-Client-Code-Generator available on Hackage.

Generation

The files were auto-generated and formatted (with ormolu) with:

openapi3-code-generator-exe stripe-api.yml --force --property-type-suffix="'" --module-name "StripeAPI" --convert-to-camel-case --omit-additional-operation-functions --package-name "stripeapi"
for file in $(find src -name "*.hs"); do LC_ALL=C.UTF-8 ormolu -m inplace $file; done

How to use

See example/src/StripeHandling.hs for an example usage. The example can be run as follows (add your Stripe API key to example/src/StripeHandling.hs):

cd example
stack run --fast

On the package level

From hackage

  • install cabal
  • cabal install stripeapi (This may take a while)

From source

See https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator#example-package for an example project generated with the same code generator.

Hackage

This library is available at https://hackage.haskell.org/package/stripeapi.

stripe-haskell-library's People

Contributors

alucardtheripper avatar joel-bach avatar norfairking avatar thomasbach-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stripe-haskell-library's Issues

postAccounts Breaking Stripe Update

Stripe recently pushed a change that allows Account.settings.bacs_debit_payments.display_name to be a nullable(string).

Stripe Changelog

image

This appears to have broken postAccounts in some cases with the following error:

Error in $.settings['bacs_debit_payments']['display_name']: parsing Text failed, expected String, but encountered Null

Is it possible to update the code according to the latest Stripe OpenAPI spec?

NotificationEventDataObject' is empty

The type NotificationEventDataObject' (https://hackage.haskell.org/package/stripeapi-0.1.0.2/docs/StripeAPI-Types-NotificationEventData.html#t:NotificationEventDataObject-39-) is empty and therefore not usable to extract information from the response. The relevant part from the Stripe specification is the following:

    notification_event_data:
      description: ''
      properties:
        object:
          description: Object containing the API resource relevant to the event. For
            example, an `invoice.created` event will have a full [invoice object](https://stripe.com/docs/api#invoice_object)
            as the value of the object key.
          type: object
        previous_attributes:
          description: Object containing the names of the attributes that have changed,
            and their previous values (sent along only with *.updated events).
          type: object
      required:
      - object
      title: NotificationEventData
      type: object
      x-expandableFields: []

The generated code corresponds to the specification but is not usable nevertheless. One possible solution would be to adjust the generator to use Data.Aeson.Value instead of unit types.

Question: Trying out latest api version

For trying out the the latest api version without pinning the version on my stripe account, this is where I would set it right?
https://stripe.com/docs/api/versioning

instance MonadHTTP Handler where
  httpBS req = HTTP.httpBS (HTTP.addRequestHeader "Stripe-Version" "2022-11-15" req)

I can't seem to make it work. It's still registering as the old api version in the stripe api logs

Invalid UTF-8 characters found in POST body

I have the following test:

module ThirdParty.StripeAPISpec (spec) where

import qualified Network.HTTP.Client as HTTPClient
import qualified StripeAPI           as Stripe

import Test.Hspec (Spec, describe, expectationFailure, it)

import TestUtils

spec :: Spec
spec = do
  describe "checkout sessions" $ do
    it "should contain a payment intent and a session url" $ do
      let params = (Stripe.mkPostCheckoutSessionsRequestBody "http://localhost:3000/" "http://localhost:3000/")
                   { Stripe.postCheckoutSessionsRequestBodyLineItems = Just [lineItems]
                   , Stripe.postCheckoutSessionsRequestBodyMode = Just Stripe.PostCheckoutSessionsRequestBodyMode'EnumPayment
                   , Stripe.postCheckoutSessionsRequestBodyClientReferenceId = Just "some-booking-id"
                   }
          lineItems = Stripe.mkPostCheckoutSessionsRequestBodyLineItems'
                      { Stripe.postCheckoutSessionsRequestBodyLineItems'PriceData = Just priceData
                      , Stripe.postCheckoutSessionsRequestBodyLineItems'Quantity = Just 3
                      }
          priceData = (Stripe.mkPostCheckoutSessionsRequestBodyLineItems'PriceData' "EUR")
                      { Stripe.postCheckoutSessionsRequestBodyLineItems'PriceData'ProductData = Just productData
                      , Stripe.postCheckoutSessionsRequestBodyLineItems'PriceData'UnitAmount = Just 100
                      }
          productData = Stripe.mkPostCheckoutSessionsRequestBodyLineItems'PriceData'ProductData' "foobar2000-î"
          getCheckout = Stripe.postCheckoutSessions params
          conf = Stripe.defaultConfiguration
                   { Stripe.configSecurityScheme = Stripe.bearerAuthenticationSecurityScheme testStripeAPIKey
                   }
      res <- Stripe.runWithConfiguration conf getCheckout
      case HTTPClient.responseBody res of
        Stripe.PostCheckoutSessionsResponse200 session -> do
          let mPaymentIntentId = Stripe.checkout'sessionPaymentIntent session
              mSessionUrl = Stripe.checkout'sessionUrl session
          case (mSessionUrl, mPaymentIntentId) of
            (Just _, Just (Stripe.Checkout'sessionPaymentIntent'Text _)) ->
              pure ()
            others -> expectationFailure $
              "Did not find sessionPaymentIntent and sessionUrl in " <> show others
        other -> expectationFailure $ "Did not find session response: " <> show other

Nothing special here, but note the î in the ProductData field. This tests fails with the following message:

  1) ThirdParty.StripeAPI, checkout sessions, should contain a payment intent and a session url
       Did not find session response: PostCheckoutSessionsResponseDefault (Error {errorError = ApiErrors {apiErrorsCharge = Nothing, apiErrorsCode = Just "invalid_utf8_in_post_body", apiErrorsDeclineCode = Nothing, apiErrorsDocUrl = Nothing, apiErrorsMessage = Just "Invalid UTF-8 characters found in POST body: \"foobar2000-\\xEE\".  For assistance, please contact [email protected].", apiErrorsParam = Nothing, apiErrorsPaymentIntent = Nothing, apiErrorsPaymentMethod = Nothing, apiErrorsPaymentMethodType = Nothing, apiErrorsSetupIntent = Nothing, apiErrorsSource = Nothing, apiErrorsType = ApiErrorsType'EnumInvalidRequestError}})

Removing said î the test succeeds.

I haven't really looked into this yet, just discovered the issue. Do you have any suggestion what's wrong here? Can you give me pointers?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.