Skip to content

qutheory/stripe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

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
    • History
    • Balance by ID
  • Charges
    • Creating Charges
    • Retrieving a charge by id
    • Listing all charges
    • Updating a charge
    • Capturing a charge
  • Customers
    • Creating
    • Updating
    • Deleting
    • Fetching by Customer ID
    • Listing All Customers (With filters)
  • Coupons
    • Creating
    • Updating
    • Deleting
    • Fetching by Coupon ID
    • Listing All Coupons (With filters)
  • Plans
    • Creating
    • Updating
    • Deleting
    • Fetching by Plan ID
    • Listing All Plans (With filters)
  • Refunds
    • Creating a Refund
    • Retrieval
    • Updating
    • Listing all
  • Tokens
    • Card Creation
    • Bank Creation
    • Token Retrieval
  • Sources
    • Creating
    • Updating
    • Fetching by Source ID
  • Subscriptions
    • Creating
    • Updating
    • Deleting
    • Fetching by subscription ID
    • Listing All Subscriptions (With filters)
  • Connect account
    • Creating
    • Updating
    • Deleting
    • Fetching by account ID
    • Listing All Accounts (With filters)
    • Rejecting accounts
    • Creating dashboard login link for express accounts
  • Orders
  • Order Items
  • Products
  • Disputes
  • Cards

License

Vapor Stripe Provider is available under the MIT license. See the LICENSE file for more info.

Packages

No packages published

Languages

  • Swift 100.0%