Swiftpack.co - Package - PerfectlySoft/Perfect-Stripe

Perfect Stripe API

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 3.0 Platforms OS X | Linux License Apache PerfectlySoft Twitter Slack Status

Perfect Stripe API

Note: This is a work in progress and will grow to 100% API coverage over time. Your pull requests will help this!

This API will connect your Server Side Swift application with the Stripe payment gateway.

Compatibility with Swift

The master branch of this project currently compiles with Xcode 8.3 or the Swift 3.1 toolchain on macOS and Ubuntu.

Usage

Import the module by including in your Package.swift file.

.Package(url: "https://github.com/PerfectlySoft/Perfect-Stripe.git", majorVersion: 1)

Then use in your file by importing:

import PerfectStripe

Documentation

Configuration

Obtain a Stripe API key, and set this for use:

Stripe.apiKey = "<your api key>"

Balances

Get account balance

Retrieves the current account balance, based on the authentication that was used to make the request.

This is addressing the following object: https://stripe.com/docs/api/curl#retrieve_balance

let balance = StripeBalance()
balance.get()

This will populate the balance object as seen in https://github.com/PerfectlySoft/Perfect-Stripe/blob/master/Sources/PerfectStripe/Balance/Balance.swift

Retrieve balance history

Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.

let balanceHistory = StripeBalance()
do {
	let history = try balanceHistory.history()
	print("history.count: \(history.count)")
} catch {
	print("history error: \(error)")
}

Retrieve a balance transaction

Retrieves the balance transaction with the given ID.

Returns a balance transaction if a valid balance transaction ID was provided.

let balanceTransaction = StripeBalanceTransaction()
balanceTransaction.get("<transaction_id>")

print("balanceTransaction.id: \(balanceTransaction.id)")

Charges

List charges

Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.

let chargeListTest = StripeCharge()
do {
	let list = try chargeListTest.list()
	print("chargeListTest returned: \(list)")
	list.forEach{
		c in
		print(c.id)
	}
} catch {
	print("chargeListTest error: \(error)")
}

This returns, for eample the follwoing sample output:

chargeListTest returned: [PerfectStripe.StripeCharge, PerfectStripe.StripeCharge]
ch_1ALEBOA9o38RUZnAwAJoJHok
ch_1AKWBHA9o38RUZnAFzf6IIx2

Coupons

Discounts

Disputes

Events

File uploads

Payouts

Plans

Refunds

Shipping

Subscriptions

Issues

We use JIRA for all bugs and support related issues.

If you find a mistake, bug, or any other helpful suggestion you'd like to make on the docs please head over to http://jira.perfect.org:8080/servicedesk/customer/portal/1 and raise it.

A comprehensive list of open issues can be found at http://jira.perfect.org:8080/projects/ISS/issues

Further Information

For more information on the Perfect project, please visit perfect.org.