From 9c9ea24ecf2390d4f6f76fde333b4224255116cc Mon Sep 17 00:00:00 2001 From: Robert Cooper Date: Tue, 1 Feb 2022 16:22:59 -0800 Subject: [PATCH 1/3] cleanup readme + prepare for webhooks --- README.md | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 85c60278..f6065aee 100644 --- a/README.md +++ b/README.md @@ -14,22 +14,39 @@ 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 interface. + +### PsP Support Matrix +| PsP | Gateway APIs | Webhooks | +|-----|--------------|----------| +| [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) | ✅ | ❌ | +| [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 @@ -50,7 +67,7 @@ $ export NMI_SECURITY_KEY="YOUR_NMI_PRIVATE_KEY" Then run tests with: `go test ./integration-tests/` -#### Code Example for Auth + Capture +## Code Example for Auth + Capture ``` import ( @@ -96,13 +113,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 From 0b42aea758a202226f819f673138b4e3eded4095 Mon Sep 17 00:00:00 2001 From: Robert Cooper Date: Tue, 1 Feb 2022 16:24:48 -0800 Subject: [PATCH 2/3] add checkout.com --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index de25d746..1d619444 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ We support abstracting PsP Webhook notifications into a common interface. | [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) | ✅ | ❌ | From 7990cea7248ea0481d037881981ea12ff34b30ed Mon Sep 17 00:00:00 2001 From: Robert Cooper Date: Thu, 3 Feb 2022 13:53:30 -0800 Subject: [PATCH 3/3] webhooks --- README.md | 8 ++++---- webhooks/types.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 webhooks/types.go diff --git a/README.md b/README.md index 1d619444..e3cbd8c5 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,12 @@ Wherever possible, we try to use native Golang implementations of the PsP's API. ### Webhooks Support -We support abstracting PsP Webhook notifications into a common interface. +We support abstracting PsP Webhook notifications into a common event interface. ### PsP Support Matrix -| PsP | Gateway APIs | Webhooks | +| PsP | Gateway APIs | Webhooks (Beta) | |-----|--------------|----------| -| [Adyen](https://docs.adyen.com/classic-integration/api-integration-ecommerce) | ✅ | ❌ | +| [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) | ✅ | ❌ | @@ -37,7 +37,7 @@ We support abstracting PsP Webhook notifications into a common interface. | [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) | ✅ | ❌ | +| [Stripe](https://stripe.com/docs/api) | ✅ | ✅ | ## To run tests 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 + +}