Skip to content

Commit

Permalink
Merge pull request #115 from vapor-community/vapor-4
Browse files Browse the repository at this point in the history
Vapor 4
  • Loading branch information
Andrewangeta authored Mar 7, 2020
2 parents 5e9d77e + 349032c commit af50805
Show file tree
Hide file tree
Showing 148 changed files with 66 additions and 10,264 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/*.xcodeproj
Package.pins
Package.resolved
.swiftpm
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT LICENSE

Copyright (c) 2017 Anthony Castelli & Andrew Edwards
Copyright (c) 2020 Anthony Castelli & Andrew Edwards

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 10 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
// swift-tools-version:4.2
// swift-tools-version:5.2
import PackageDescription

let package = Package(
name: "Stripe",
platforms: [
.macOS(.v10_15)
],
products: [
.library(name: "Stripe", targets: ["Stripe"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "3.2.2"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-rc.1"),
.package(url: "https://github.com/vapor-community/stripe-kit.git", .exact("6.0.0")),
],
targets: [
.target(name: "Stripe", dependencies: ["Vapor"]),
.testTarget(name: "StripeTests", dependencies: ["Vapor", "Stripe"])
.target(name: "Stripe", dependencies: [
.product(name: "StripeKit", package: "stripe-kit"),
.product(name: "Vapor", package: "vapor"),
]),
]
)
111 changes: 14 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
# Vapor Stripe Provider
# Stripe

![Swift](http://img.shields.io/badge/swift-4.1-brightgreen.svg)
![Vapor](http://img.shields.io/badge/vapor-3.0-brightgreen.svg)
[![CircleCI](https://circleci.com/gh/vapor-community/stripe-provider.svg?style=svg)](https://circleci.com/gh/vapor-community/stripe-provider)
![Swift](http://img.shields.io/badge/swift-5.2-brightgreen.svg)
![Vapor](http://img.shields.io/badge/vapor-4.0-brightgreen.svg)

[Stripe][stripe_home] is a payment platform that handles credit cards, bitcoin and ACH transfers. They have become one of the best platforms for handling payments for projects, services or products.

## Getting Started
### Stripe is a Vapor wrapper around [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-provider.git", from: "2.2.0")
.package(url: "https://github.com/vapor-community/stripe.git", from: "5.0.0")
~~~~

Register the config and the provider in `configure.swift`
~~~~swift
let config = StripeConfig(productionKey: "sk_live_1234", testKey: "sk_test_1234")

services.register(config)
try services.register(StripeProvider())
~~~~
To use Stripe in your Vapor application, set the environment variable for you Stripe API key
~~~
export STRIPE_API_KEY="sk_123456"
~~~

And you are all set. Interacting with the API is quite easy from any route handler.
Now you can access a `StripeClient` via `Request`.
~~~~swift

struct ChargeToken: Content {
Expand All @@ -30,7 +28,7 @@ struct ChargeToken: Content {

func chargeCustomer(_ req: Request) throws -> EventLoopFuture<HTTPStatus> {
return try req.content.decode(ChargeToken.self).flatMap { charge in
return try req.make(StripeClient.self).charge.create(amount: 2500, currency: .usd, source: charge.token).map { stripeCharge in
return req.stripe.charge.create(amount: 2500, currency: .usd, source: charge.stripeToken).map { stripeCharge in
if stripeCharge.status == .success {
return .ok
} else {
Expand All @@ -42,90 +40,9 @@ func chargeCustomer(_ req: Request) throws -> EventLoopFuture<HTTPStatus> {
}
~~~~

And you can always check the documentation to see the required paramaters for specific API calls.

## Whats Implemented

### Core Resources
* [x] Balance
* [x] Charges
* [x] Customers
* [x] Disputes
* [ ] Events
* [x] File Links
* [x] File Uploads
* [x] PaymentIntents
* [x] Payouts
* [x] Products
* [x] Refunds
* [x] Tokens
---
### Payment Methods
* [x] Bank Accounts
* [x] Cards
* [x] Sources
---
### Checkout
* [ ] Sessions
---
### Billing
* [x] Coupons
* [x] Discounts
* [x] Invoices
* [x] Invoice Items
* [x] Products
* [x] Plans
* [x] Subscriptions
* [x] Subscription items
* [ ] Usage Records
---
### Connect
* [x] Account
* [ ] Application Fee Refunds
* [ ] Application Fees
* [ ] Country Specs
* [ ] External Accounts
* [x] Persons
* [ ] Top-ups
* [x] Transfers
* [x] Transfer Reversals
---
### Fraud
* [ ] Reviews
* [ ] Value Lists
* [ ] Value List Items
---
### Issuing
* [ ] Authorizations
* [ ] Cardholders
* [ ] Cards
* [ ] Disputes
* [ ] Transactions
---
### Terminal
* [ ] Connection Tokens
* [ ] Locations
* [ ] Readers
---
### Orders
* [x] Orders
* [x] Order Items
* [x] Returns
* [x] SKUs
* [x] Ephemeral Keys
---
### Sigma
* [ ] Scheduled Queries
---
### Webhooks
* [ ] Webhook Endpoints

[stripe_home]: http://stripe.com "Stripe"
[stripe_api]: https://stripe.com/docs/api "Stripe API Endpoints"

## License

Vapor Stripe Provider is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
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! 😀
Loading

0 comments on commit af50805

Please sign in to comment.