Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

💰 Stripe API

NotificationsYou must be signed in to change notification settings

dmjio/stripe

Repository files navigation

HackageHaskell Programming LanguageMIT LICENSEJoin the chat at https://gitter.im/dmjio/stripeBuild Status

Stripe API coverage for Haskell (Stripe API)

All Stripe commands are supported, including but not limited to:

  • Charges
  • Refunds
  • Customers
  • Cards
  • Subscriptions
  • Plans
  • Coupons
  • Discounts
  • Invoices
  • Invoice Items
  • Disputes
  • Transfers
  • Recipients (Deprecated)
  • Bitcoin
  • Application Fees
  • Application Fee Refunds
  • Account
  • Balance
  • Events and Tokens

Haddock Coverage

All code written for this library is documented to completion with the haddock documentation tool

Thoroughly unit-tested with hspec.All API commands are unit-tested before inclusion into the API (see the tests directory).To run the tests, perform the following:

cabal cleancabal configure --enable-testscabal build testsdist/build/tests/tests# You will be prompted to enter your *TEST* key

Pagination is possible on all API calls that return a JSON array.Any API call that returns aStripeList is eligible for pagination.To use in practice do the following:

importWeb.StripeimportWeb.Stripe.Customermain::IO()main=dolet config=StripeConfig (StripeKey"secret key")Nothing  result<- stripe config$ getCustomers(Just30::MaybeLimit)-- Defaults to 10 if Nothing, 100 is Max(StartingAfter$CustomerId"customer_id0")(EndingBefore$CustomerId"customer_id30")case resultofRight stripelist->print (list stripelist:: [Customer])Left stripeError->print stripeError

Stripe API calls can take multiple optional parameters.stripe-haskell supports optional parameters through the use of type-families and typeclasses.In practice, the function to use is(-&-) to specify optional parameters on a request.For a deeper dive into how this works, please see thisblog post.

chargeCardByToken::TokenId->Currency->Amount->IO (EitherStripeErrorCharge)chargeCardByToken tokenId currency amount=  stripe config$ createCharge amount currency-&- tokenId

All versioning is hard-coded (for safety) to version2014-10-07.Stripe API versions specified in the HTTP headers of Stripe requests take precedenceover the API version specified in your Stripe Dashboard. In an attempt to ensureAPI consistency and correct parsing of returned JSON, all Stripe versions are hard-coded, and areinaccessible to the end-users of this library. When a new Stripe API version is releasedthis library will increment the hard-coded API version.

Object expansion is supported on Stripe objects eligible for expansion though theExpandParams type.Object expansion allows normal Stripe API calls to return expanded objects inside of other objects.For example, aCustomer object contains a Card ID hash on the default_card field.This default_card hash can be expanded into a fullCard object inside aCustomer object.As an example:

importWeb.StripeimportWeb.Stripe.Customermain::IO()main=dolet config=StripeConfig (StripeKey"secret key")Nothing  result<- stripe config$ getCustomerExpandable   (CustomerId"customerid")   (["default_card"]::ExpandParams)case resultofRight customer->print (defaultCard customer)-- Will be an `ExpandedCard`Left stripeError->print stripeError

Stripe objects allow the embedding of arbitrary metadata.Any Stripe object that supports the embedding of metadata is available via this API.As an example:

importWeb.StripeimportWeb.Stripe.Couponmain::IO()main=dolet config=StripeConfig (StripeKey"secret key")Nothing  result<- stripe config$ updateCoupon (CouponId"couponid") [("key1","value2"), ("key2","value2")]case resultofRight coupon->print$ couponMetaData couponLeft stripeError->print stripeError

Any API recommendations or bugs can be reported on the GitHub issue tracker.Pull requests welcome!

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]


[8]ページ先頭

©2009-2025 Movatter.jp