Skip to content

Commit

Permalink
Merge pull request #57 from saleor/feat/authorize-webhooks
Browse files Browse the repository at this point in the history
feat: authorize webhooks
  • Loading branch information
peelar committed Jan 9, 2024
2 parents 9157cad + a0db74e commit 465dcc7
Show file tree
Hide file tree
Showing 53 changed files with 1,299 additions and 1,132 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-horses-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-app-authorize-net": minor
---

Added registering and handling Authorize.net webhooks. Enclosing the two-way synchronization between Saleor and Authorize.net transactions. Known issues: hard-coded channels, skipped webhook body verification. Both will be addressed in the next release.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ AUTHORIZE_TRANSACTION_KEY=
AUTHORIZE_PUBLIC_CLIENT_KEY=
AUTHORIZE_ENVIRONMENT="sandbox"
AUTHORIZE_SALEOR_CHANNEL_SLUG="default-channel"
AUTHORIZE_PAYMENT_FORM_URL=""
AUTHORIZE_PAYMENT_FORM_URL=""
APP_API_BASE_URL=""
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
Important:
# Authorize.net App

- Checkout UI relies on "Authorize transactions instead of charging" in the Saleor Dashboard -> Configuration -> Channels -> [channel] settings.
## Development

### Build

```bash
pnpm run build
```

### Run

#### Running the Authorize.net App

```bash
pnpm run dev
```

The app will run on port 8000.

#### Running the Authorize.net UI example

```bash
cd example
pnpm run dev
```

> [!IMPORTANT]
> Both the example and the app need to be [tunneled](https://docs.saleor.io/docs/3.x/developer/extending/apps/developing-with-tunnels).
## Important

- The `example` Checkout UI relies on the "Authorize transactions instead of charging" setting in the Saleor Dashboard -> Configuration -> Channels -> [channel] settings.

- The Saleor transaction id is stored in Authorize transaction `order.description`. Ideally, we would store it in `refId` but that field is max. 20 characters long and the Saleor transaction id is longer than that.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev --port 8001",
"build": "next build",
"start": "next start",
"lint": "next lint --fix --dir src",
Expand Down
22 changes: 22 additions & 0 deletions graphql/fragments/Transaction.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fragment Transaction on TransactionItem {
id
pspReference
sourceObject: order {
... on Order {
total {
gross {
...Money
}
}
}
...OrderOrCheckoutLines
}
privateMetadata {
key
value
}
authorizedAmount {
amount
currency
}
}
17 changes: 1 addition & 16 deletions graphql/fragments/TransactionCancelationRequestedEvent.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ fragment TransactionCancelationRequestedEvent on TransactionCancelationRequested
amount
}
transaction {
id
pspReference
sourceObject: order {
channel {
id
slug
}
}
privateMetadata {
key
value
}
authorizedAmount {
amount
currency
}
...Transaction
}
}
13 changes: 1 addition & 12 deletions graphql/fragments/TransactionChargeRequestedEvent.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ fragment TransactionChargeRequestedEvent on TransactionChargeRequested {
actionType
}
transaction {
id
pspReference
sourceObject: order {
... on Order {
total {
gross {
...Money
}
}
}
...OrderOrCheckoutLines
}
...Transaction
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fragment TransactionInitializeSessionEvent on TransactionInitializeSession {
}
}
transaction {
id
...Transaction
}
sourceObject {
__typename
Expand Down
2 changes: 1 addition & 1 deletion graphql/fragments/TransactionProcessSessionEvent.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fragment TransactionProcessSessionEvent on TransactionProcessSession {
actionType
}
transaction {
id
...Transaction
}
sourceObject {
__typename
Expand Down
17 changes: 1 addition & 16 deletions graphql/fragments/TransactionRefundRequestedEvent.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ fragment TransactionRefundRequestedEvent on TransactionRefundRequested {
actionType
}
transaction {
id
pspReference
sourceObject: order {
... on Order {
total {
gross {
...Money
}
}
}
...OrderOrCheckoutLines
}
privateMetadata {
key
value
}
...Transaction
}
}
4 changes: 2 additions & 2 deletions graphql/mutations/TransactionEventReport.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ mutation TransactionEventReport(
$transactionId: ID!
$amount: PositiveDecimal!
$availableActions: [TransactionActionEnum!]!
$externalUrl: String!
$externalUrl: String
$message: String
$pspReference: String!
$time: DateTime!
$time: DateTime
$type: TransactionEventTypeEnum!
) {
transactionEventReport(
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"type": "module",
"scripts": {
"dev": "pnpm generate && next dev",
"dev": "pnpm generate && next dev --port 8000",
"build": "pnpm generate && next build",
"deploy": "tsx ./src/deploy.ts",
"start": "next start",
Expand Down Expand Up @@ -63,6 +63,7 @@
"jose": "4.14.4",
"jsdom": "22.1.0",
"lodash-es": "4.17.21",
"micro": "10.0.1",
"modern-errors": "6.0.0",
"modern-errors-http": "4.0.0",
"modern-errors-serialize": "5.0.0",
Expand Down Expand Up @@ -108,7 +109,7 @@
"@types/authorizenet": "1.0.1",
"@types/bluebird": "3.5.38",
"@types/lodash-es": "4.17.8",
"@types/node": "20.5.4",
"@types/node": "20.10.4",
"@types/omit-deep-lodash": "1.1.1",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
Expand Down
Loading

0 comments on commit 465dcc7

Please sign in to comment.