diff --git a/README.md b/README.md index 38e7901a..e3cbd8c5 100644 --- a/README.md +++ b/README.md @@ -14,22 +14,40 @@ Payment abstraction library - interact with different Payment Service Providers 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 API Calls +### Supported Gateway API Calls 1. Authorize 2. Capture 3. Void 4. Refund -### To run tests +### Webhooks Support -#### Unit test +We support abstracting PsP Webhook notifications into a common event interface. + +### PsP Support Matrix +| PsP | Gateway APIs | Webhooks (Beta) | +|-----|--------------|----------| +| [Adyen](https://docs.adyen.com/classic-integration/api-integration-ecommerce) | ✅ | ✅ | +| [Authorize.Net](https://developer.authorize.net/api/reference/index.html#payment-transactions) | ✅ | ❌ | +| [Braintree](https://www.braintreepayments.com/) | ✅ | ❌ | +| [CyberSource](https://developer.cybersource.com/api-reference-assets/index.html#payments) | ✅ | ❌ | +| [Checkout.com](https://api-reference.checkout.com/) | ✅ | ❌ | +| [FirstData](https://docs.firstdata.com/org/gateway/docs/api) | ✅ | ❌ | +| [NMI](https://secure.networkmerchants.com/gw/merchants/resources/integration/integration_portal.php#methodology) | ✅ | ❌ | +| [Orbital](https://developer.jpmorgan.com/products/orbital-api) | ✅ | ❌ | +| [RocketGate](https://www.rocketgate.com/) | ✅ | ❌ | +| [Stripe](https://stripe.com/docs/api) | ✅ | ✅ | + +## To run tests + +### Unit test ``` go test -v -tags=unit $(go list ./... | grep -v integration-tests) ``` -#### Integration test +### Integration test The following environment variables are needed in order to run tests ```shell script @@ -51,7 +69,7 @@ $ export CHECKOUTCOM_TEST_KEY="YOUR_CHECKOUTCOM_PRIVATE_KEY" Then run tests with: `go test ./integration-tests/` -#### Code Example for Auth + Capture +## Code Example for Auth + Capture ``` import ( @@ -97,13 +115,4 @@ captureRequest := sleet.CaptureRequest{ TransactionReference: authorizeResponse.TransactionReference, } client.Capture(&captureRequest) -``` - -#### Supported Gateways - -- [Authorize.Net](https://developer.authorize.net/api/reference/index.html#payment-transactions) -- [CyberSource](https://developer.cybersource.com/api-reference-assets/index.html#payments) -- [Stripe](https://stripe.com/docs/api) -- [Adyen](https://docs.adyen.com/classic-integration/api-integration-ecommerce) -- [Braintree](https://www.braintreepayments.com/) -- [NMI](https://secure.networkmerchants.com/gw/merchants/resources/integration/integration_portal.php#methodology) +``` \ No newline at end of file diff --git a/webhooks/types.go b/webhooks/types.go new file mode 100644 index 00000000..aac4352e --- /dev/null +++ b/webhooks/types.go @@ -0,0 +1,29 @@ +package webhooks + +import "github.com/BoltApp/sleet" + +// WebhookTranslator Sleet interface which takes an eventBody and translates the body to the +// Sleet TransactionEvent. Normalizes all fields to the structure and enums defined by Sleet. +type WebhookTranslator interface { + Translate(eventBody *string) (*TransactionEvent, error) +} + +type TransactionEventType int + +const ( + CaptureEvent TransactionEventType = 1 + VoidEvent TransactionEventType = 2 + RefundEvent TransactionEventType = 3 +) + +type TransactionEvent struct { + // Core event fields, these should be included in every transaction event + transactionEventType TransactionEventType // Normalized event type for the transaction + transactionReferenceId *string // id representing the transaction on the PsP system + success bool // normalized indicator on event representing success or not + + // Optional event fields, may be available based on the event type or processor implementation + merchantTransactionReferenceId *string // id representing the transaction on caller's system (as passed to the PsP if supported) + amount sleet.Amount + +}