Swiftpack.co - Package - vapor-community/stripe

Stripe

Swift Vapor

Stripe is a Vapor helper to use StripeKit

Usage guide

In your Package.swift file, add the following

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

To use Stripe in your Vapor application, set the environment variable for you Stripe API key

export STRIPE_API_KEY="sk_123456"      

Now you can access a StripeClient via Request.


struct ChargeToken: Content {
    var token: String
}

func chargeCustomer(_ req: Request) throws -> EventLoopFuture<HTTPStatus> {
    return try req.content.decode(ChargeToken.self).flatMap { charge in
        return req.stripe.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
            }
        }
    }
}

License

Stripe 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: 139

Used By

Total: 0

Releases

Stripe 5.1.0 - 2020-04-30 19:46:05

This release:

  • Adds a helper method to verify a signature for a Request.
  • Conforms StripeSignatureError to AbortError for useful messages inside the Stripe logs.
func handleWebhook(_ req: Request) throws -> EventLoopFuture<Response> {
     // ...
     try StripeClient.verifySignature(for: req, secret: "whs_1234", tolerance: 500) 
}

Stripe 5.0.1 - 2020-04-29 00:23:52

Updates to latest stripe kit

Stripe 5.0.0 - 2020-04-21 00:18:16

Updates to the latest release of StripeKit.

Stripe 4.0.0 💳🎉 - 2020-04-10 18:46:30

This release has support for the Vapor 4 official tag.

Stripe 4.0.0 RC 3 - 2020-03-28 18:11:30

Fixed package name.

Stripe 4.0.0 RC 2 - 2020-03-28 17:56:32

Removed pinned version of StripeKit.

Stripe 4.0.0-rc.1 - 2020-03-07 23:50:38

First release candidate for Vapor 4 Stripe wrapper.

Stripe 2.6.0 - 2020-03-06 22:24:42

This release points to the new vapor3 branch for Vapor 3 legacy support as master will be for Vapor 4 going forward.

StripeProvider 2.5.0 - 2019-12-18 19:44:10

This release adds support for PaymentIntents

Stripe provider 2.4.1 - 2019-12-06 20:35:31

Points back to the master branch.

StripeProvider 3.0 beta 2 - 2019-11-06 02:49:50

Updates to support the 2019-11-05 API

StripeProvider 3.0.0 Beta 1 - 2019-11-03 06:57:49

StripeProvider 2.4.0 (Vapor 3) - 2019-10-09 16:00:33

Adds support for payment intents and updated to the latest API of 09-09-2019. See changes here.

StripeProvider 3.0.0 Alpha 1.5 - 2019-09-28 23:19:13

Exported StripeKit so now you can just import Stripe rather than StripeKit.

StripeKit updates. - 2019-07-16 00:14:03

Direct Charing - 2019-07-05 15:21:20

Adds support for Stripe Direct Charging

StripeKit updates. - 2019-06-19 03:08:48

StripeKit Bug fixes update. - 2019-06-19 02:32:59

Update to StripeKit Latest - 2019-06-14 23:53:21

StripeProvider 3.0.0 🚀 - 2019-06-14 23:32:44

Initial Vapor 4 Support

Persons API Support - 2019-03-01 05:49:28

Update Charge routes to Latest API - 2019-02-25 01:39:47

Stripe API Upgrade and bug Fixes - 2019-02-25 00:29:56

⚠️ There are some breaking changes in this release

If you would like to remain on the latest non-breaking version, you can specify the version manually in your Package.swift file

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

Fix balance history endpoint - 2019-01-25 15:37:21

Balance and charges Route fixes - 2019-01-25 10:13:17

Legal Entity fixes - 2019-01-24 23:37:45

Properly encode LegalEntity with a dictionary when creating or updating connect accounts.

Bug Fixes - 2019-01-07 21:11:14

Properly encodes the Stripe Terms of Acceptance date as an epoch date.

Connect Accounts - 2019-01-05 19:31:37

Connect Account creation now accept all parameters

Invoice Fixes - 2018-10-18 17:04:37

Even More Bugs - 2018-10-10 17:49:30