damirstuhec / stripe

Vapor Stripe Provider

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vapor Stripe Provider

Swift Vapor Build

Stripe 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.

Why Create this?

There wasn't a library for it that worked with Vapor, and I needed one for my project. The Stripe API is huge, and therefor I only plan on implementing the things that deal with payments. If there is something you need outside of that scope, feel free to submit a Pull Request.

Getting Started

In your Package.swift file, add a Package For Swift 3

.Package(url: "https://github.com/vapor-community/stripe.git", Version(1,0,0))

For Swift 4

.package(url: "https://github.com/vapor-community/stripe.git", .exact(Version(1,0,0)))

You'll need a config file as well. Place a stripe.json file in your Config folder

{
    "apiKey": "YOUR_API_KEY"
}

Add the provider to your droplet

try drop.addProvider(Stripe.Provider.self)

And you are all set. Interacting with the API is quite easy. Everything is Node backed with a simple API.

Making calls to the api is a simple one line

let object = try drop.stripe?.balance.history().serializedResponse()

The object is returned response model, or model array.

Testing

To avoid having to remember to add tests to LinuxMain.swift you can use Sourcery to add your tets cases there for you. Just install the sourcery binary with Homebrew brew install sourcery, navigate to your project folder, and from the command line run the following:

sourcery --sources Tests/ --templates Sourcery/LinuxMain.stencil --args testimports='@testable import StripeTests'

It will generate the following with your tests added:

import XCTest
@testable import StripeTests
extension BalanceTests {
static var allTests = [
  ("testBalance", testBalance),
  ...
]
}
.
.
XCTMain([
  testCase(BalanceTests.allTests),
  ...
])

Whats Implemented

  • Balance Fetching
  • Charges
  • Customers
  • Coupons
  • Plans
  • Refunds
  • Tokens
  • Sources
  • Subscriptions
  • Connect account
  • Orders
  • Order Items
  • Products
  • Disputes
  • Invoices
  • Invoice Items
  • Ephemeral Keys

License

Vapor Stripe Provider is available under the MIT license. See the 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! 😀

About

Vapor Stripe Provider

License:MIT License


Languages

Language:Swift 100.0%