Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vapor-community/stripe
Stripe library for Vapor
https://github.com/vapor-community/stripe
card payment stripe stripe-api swift vapor vapor-provider vapor-service vapor-stripe
Last synced: about 1 month ago
JSON representation
Stripe library for Vapor
- Host: GitHub
- URL: https://github.com/vapor-community/stripe
- Owner: vapor-community
- License: mit
- Created: 2017-04-16T00:41:03.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-08-21T15:01:37.000Z (about 1 year ago)
- Last Synced: 2024-05-21T06:07:08.831Z (4 months ago)
- Topics: card, payment, stripe, stripe-api, swift, vapor, vapor-provider, vapor-service, vapor-stripe
- Language: Swift
- Homepage:
- Size: 957 KB
- Stars: 174
- Watchers: 12
- Forks: 32
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stripe
![Swift](http://img.shields.io/badge/swift-5.2-brightgreen.svg)
![Vapor](http://img.shields.io/badge/vapor-4.0-brightgreen.svg)### Stripe is a Vapor helper to use [StripeKit](https://github.com/vapor-community/stripe-kit)
## Usage guide
In your `Package.swift` file, add the following~~~~swift
.package(url: "https://github.com/vapor-community/stripe.git", from: "14.0.0")
~~~~To use Stripe in your Vapor application, set the environment variable for you Stripe API key
~~~
export STRIPE_API_KEY="sk_123456"
~~~Now you can access a `StripeClient` via `Request`.
~~~~swiftstruct ChargeToken: Content {
var token: String
}func chargeCustomer(_ req: Request) throws -> EventLoopFuture {
return try req.content.decode(ChargeToken.self).flatMap { charge in
return req.stripe.charge.create(amount: 2500, currency: .usd, source: charge.stripeToken).map { stripeCharge in
if stripeCharge.status == .success {
return .ok
} else {
print("Stripe charge status: \(stripeCharge.status.rawValue)")
return .badRequest
}
}
}
}
~~~~## License
Stripe is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
## Want to help?
Feel free to submit a pull request whether it's a clean up, a new approach to handling things, adding a new part of the API, or even if it's just a typo. All help is welcomed! 😀