Skip to content

zachwick/stripe-provider

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vapor Stripe Provider

Swift Vapor CircleCI

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.

Getting Started

In your Package.swift file, add the following

.package(url: "https://github.com/vapor-community/stripe-provider.git", from: "2.2.0")

Register the config and the provider in configure.swift

let config = StripeConfig(productionKey: "sk_live_1234", testKey: "sk_test_1234")

services.register(config)
try services.register(StripeProvider())

And you are all set. Interacting with the API is quite easy from any route handler.

struct ChargeToken: Content {
    var stripeToken: String
}

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.stripeToken).map { stripeCharge in
            if stripeCharge.status == .success {
                return .ok
            } else {
                print("Stripe charge status: \(stripeCharge.status.rawValue)")
                return .badRequest
            }
        }
    }
}

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

JS Stripe integration

Also make sure to check out stripes documenation to add the client JS magic here or here

Whats Implemented

Core Resources

  • Balance
  • Charges
  • Customers
  • Disputes
  • Events
  • File Links
  • File Uploads
  • PaymentIntents
  • Payouts
  • Products
  • Refunds
  • Tokens

Payment Methods

  • Bank Accounts
  • Cards
  • Sources

Checkout

  • Sessions

Billing

  • Coupons
  • Discounts
  • Invoices
  • Invoice Items
  • Products
  • Plans
  • Subscriptions
  • Subscription items
  • Usage Records

Connect

  • Account
  • Application Fee Refunds
  • Application Fees
  • Country Specs
  • External Accounts
  • Persons
  • Top-ups
  • Transfers
  • Transfer Reversals

Fraud

  • Reviews
  • Value Lists
  • Value List Items

Issuing

  • Authorizations
  • Cardholders
  • Cards
  • Disputes
  • Transactions

Terminal

  • Connection Tokens
  • Locations
  • Readers

Orders

  • Orders
  • Order Items
  • Returns
  • SKUs
  • Ephemeral Keys

Sigma

  • Scheduled Queries

Webhooks

  • Webhook Endpoints

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

Stripe Provider for Vapor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 100.0%