Swiftpack.co - Package - vapor-community/stripe-provider

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.1.2")

Register the config and the provider to your Application

let config = StripeConfig(apiKey: "sk_12345678")

services.register(config)

try services.register(StripeProvider())

app = try Application(services: services)

stripeClient = try app.make(StripeClient.self)

And you are all set. Interacting with the API is quite easy and adopts the Future syntax used in Vapor 3. Making calls to the api is straight forward.

let cardParams = ["exp_month": 1,
                  "exp_year": 2030,
                  "number": "4242424242424242",
                  "cvc": 123,
                  "object": "card"]

let futureCharge = try stripeClient.charge.create(amount: 2500, currency: .usd, source: cardParams)

futureCharge.do({ (charge) in
    // do something with charge object...
}).catch({ (error) in
    print(error)
})

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
  • [ ] File Uploads
  • [ ] Payouts
  • [x] Refunds
  • [x] Tokens

Payment Methods

  • [x] Bank Accounts
  • [x] Cards
  • [x] Sources

Subscriptions

  • [x] Coupons
  • [x] Discounts
  • [x] Invoices
  • [x] Invoice Items
  • [x] Plans
  • [x] Subscriptions
  • [x] Subscription items

Connect

  • [x] Account
  • [ ] Application Fee Refunds
  • [ ] Application Fees
  • [ ] Country Specs
  • [x] External Accounts
  • [x] Transfers
  • [x] Transfer Reversals

Relay

  • [x] Orders
  • [x] Order Items
  • [x] Products
  • [x] Returns
  • [x] SKUs
  • [x] 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! 😀

Github

link
Stars: 73
Help us keep the lights on

Dependencies

Releases

2.1.3 - Jul 14, 2018

Made the StripeClient a singleton so we can keep a single instance and not have a copy that doesn't get changes to routes for tests for example.

2.1.2 - Jul 14, 2018

2.1.1 - Jul 3, 2018

2.1.0 - Jun 18, 2018

This release makes it possible to have safe assumptions about properties that are guaranteed to be returned from the API such as id and object. This release also makes error handling easier to work with and has every error code stripe offers and supports debuggable!

2.0.9 - Jun 8, 2018