项目作者: BoltApp

项目描述 :
Payment abstraction library - one interface for multiple payment processors ( inspired by Ruby's ActiveMerchant )
高级语言: Go
项目地址: git://github.com/BoltApp/sleet.git
创建时间: 2019-11-13T21:56:58Z
项目社区:https://github.com/BoltApp/sleet

开源协议:MIT License

下载


Sleet

CircleCI status
GoDoc
Go Report Card

Payment abstraction library - interact with different Payment Service Providers (PsP) with one unified interface.

Installation

go get github.com/BoltApp/sleet

Methodology

Wherever possible, we try to use native Golang implementations of the PsP’s API. We also assume that the caller can pass along raw credit card information (i.e. are PCI compliant)

Supported Gateway API Calls

  1. Authorize
  2. Capture
  3. Void
  4. Refund

Webhooks Support

We support abstracting PsP Webhook notifications into a common interface.

PsP Support Matrix

PsP Gateway APIs Webhooks
Adyen
Authorize.Net
Braintree
CyberSource
Checkout.com
FirstData
NMI
Orbital
RocketGate
Stripe

To run tests

Unit test

  1. go test -v -tags=unit $(go list ./... | grep -v integration-tests)

Integration test

The following environment variables are needed in order to run tests

```shell script
$ export ADYEN_USERNAME=”YOUR_ADYEN_WEBSERVICE_USERNAME”
$ export ADYEN_ACCOUNT=”YOUR_ADYEN_MERCHANT_ACCOUNT”
$ export ADYEN_PASSWORD=”YOUR_ADYEN_WEBSERVICE_PASSWORD”
$ export STRIPE_TEST_KEY=”YOUR_STRIPE_API_KEY”
$ export AUTH_NET_LOGIN_ID=”YOUR_AUTHNET_LOGIN”
$ export AUTH_NET_TXN_KEY=”YOUR_AUTHNET_TXN_KEY”
$ export BRAINTREE_MERCHANT_ID=”YOUR_BRAINTREE_MERCHANT_ACCOUNT”
$ export BRAINTREE_PUBLIC_KEY=”YOUR_BRAINTREE_PUBLIC_KEY”
$ export BRAINTREE_PRIVATE_ID=”YOUR_BRAINTREE_PRIVATE_KEY”
$ export CYBERSOURCE_ACCOUNT=”YOUR_CYBS_ACCOUNT”
$ export CYBERSOURCE_API_KEY=”YOUR_CYBS_KEY”
$ export CYBERSOURCE_SHARED_SECRET=”YOUR_CYBS_SECRET”
$ export NMI_SECURITY_KEY=”YOUR_NMI_PRIVATE_KEY”
$ export CHECKOUTCOM_TEST_KEY=”YOUR_CHECKOUTCOM_PRIVATE_KEY”
$ export CHECKOUTCOM_TEST_KEY_WITH_PCID=”YOUR_CHECKOUTCOM_PRIVATE_KEY_WITH_PROCESSING_CHANNEL_ID”
$ export CHECKOUTCOM_TEST_PCID=”YOUR_CHECKOUTCOM_PROCESSING_CHANNEL_ID”

  1. Then run tests with: `go test ./integration-tests/`
  2. ## Code Example for Auth + Capture
  3. ```go
  4. import (
  5. "github.com/BoltApp/sleet"
  6. "github.com/BoltApp/sleet/gateways/authorize_net"
  7. )
  8. // Generate a client using your own credentials
  9. client := authorize_net.NewClient("AUTH_NET_LOGIN_ID", "AUTH_NET_TXN_KEY")
  10. amount := sleet.Amount{
  11. Amount: 100,
  12. Currency: "USD",
  13. }
  14. card := sleet.CreditCard{
  15. FirstName: "Bolt",
  16. LastName: "Checkout",
  17. Number: "4111111111111111",
  18. ExpMonth: 8,
  19. EpxYear: 2010,
  20. CVV: "000",
  21. }
  22. streetAddress := "22 Linda St."
  23. locality := "Hoboken"
  24. regionCode := "NJ"
  25. postalCode := "07030"
  26. countryCode := "US"
  27. address := sleet.BillingAddress{
  28. StreetAddress1: &streetAddress,
  29. Locality: &locality,
  30. RegionCode: ®ionCode,
  31. PostalCode: &postalCode,
  32. CountryCode: &countryCode,
  33. }
  34. // To get specific response headers, add them to the request options.
  35. // They will be attached to the AuthorizationResponse
  36. options := make(map[string]interface{})
  37. options["ResponseHeader"] = []string{"x-test-header"}
  38. authorizeRequest := sleet.AuthorizationRequest{
  39. Amount: &amount,
  40. CreditCard: &card,
  41. BillingAddress: &address,
  42. Options: options,
  43. }
  44. authorizeResponse, _ := client.Authorize(&authorizeRequest)
  45. captureRequest := sleet.CaptureRequest{
  46. Amount: &amount,
  47. TransactionReference: authorizeResponse.TransactionReference,
  48. }
  49. client.Capture(&captureRequest)