Giter Club home page Giter Club logo

stripe's Introduction

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: "7.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! ๐Ÿ˜€

stripe's People

Contributors

andrewangeta avatar anthonycastelli avatar baarde avatar calebkleveter avatar sorix avatar ksmandersen avatar madsodgaard avatar robipresotto avatar balestrapatrick avatar vzsg avatar nsmutablestring avatar kschins avatar andreaferrando avatar tanner0101 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.