Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(commerce/backend): add pre-interaction checkout flow #723

Merged
merged 17 commits into from
Sep 11, 2023

Conversation

raducristianpopa
Copy link
Member

@raducristianpopa raducristianpopa commented Sep 8, 2023

@github-actions github-actions bot added type: test Improvements or additions to tests package: boutique/backend Boutique backend implementations labels Sep 8, 2023
@raducristianpopa raducristianpopa changed the title feat(commerce/backend): add op client feat(commerce/backend): add pre-interaction checkout flow Sep 8, 2023
Comment on lines +10 to +17
AUTH_SERVER: z.string().url().default('http://rafiki-auth:3006'),
PAYMENT_POINTER: z.string().default('http://rafiki-backend/shop'),
KEY_ID: z.string().default('8e5e109e-9ea8-44a0-9490-1792bf1e07cb'),
PRIVATE_KEY: z
.string()
.default(
'LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1DNENBUUF3QlFZREsyVndCQ0lFSU9LemxweFR5c0xhbS94VWZ5R2t2T2dpSmcraTEvT25STURWMElqNi9vVnQKLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQ=='
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to seed our wallet with a default account with two payment pointers. Will do this in a separate PR later on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 2 payment pointers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One that will be the shop's payment pointer and one that will act as the customer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the customer one is necessary as any payment pointer can be used for customer actions

start: ['redirect'],
finish: {
method: 'redirect',
uri: `${this.env.FRONTEND_URL}/placeholder?orderId=${orderId}`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placeholder URL for the moment.

return null
}

if (cached.expires !== null && cached.expires < Date.now()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a base cache class and might be used in other places as well directly as an abstraction, do you intend to also cleanup the cache on different instances except for when the specific item is retrieved and found as expired?

How about we also have a loop that periodically checks expired items? (Unless we want to have a notion of observability on cache misses which i don't think is the case)

What do you think about either a loop that checks expired items, or an implementation of an LRU cache?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how an LRU cache fits our case? Regarding the loop that periodically checks expired items, that's what I'm planning to do (we cache some order related fields so we won't need to save them in the database), but this is going to be in the second phase of the checkout flow (post-interaction).

dragosp1011
dragosp1011 previously approved these changes Sep 11, 2023
@raducristianpopa raducristianpopa merged commit d9da304 into main Sep 11, 2023
9 checks passed
@raducristianpopa raducristianpopa deleted the rp--open-payments branch September 11, 2023 12:17
raducristianpopa added a commit that referenced this pull request Sep 20, 2023
* chore(deps): update typescript-eslint monorepo to ^6.6.0 (#714)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency @tailwindcss/typography to ^0.5.10 (#715)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update pnpm to v8.7.4 (#716)

* chore(deps): update pnpm to v8.7.4

* Update docker files

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Radu-Cristian Popa <radu.popa@breakpointit.eu>

* fix(deps): update dependency ky to ^1.0.1 (#717)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(backend): Slow incoming payments (#706)

* reduce expiry time to 15 sec on payment pointer transaction

* Handle transfer already exists properly

* handle new webhook event - payment_pointer.not_found

* feat(middleware): add handling of axios errors (#719)

* feat(middleware): add handling of axios errors

* fix: avoid double response send

* fix(deps): update dependency express-rate-limit to ^6.11.1 (#720)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency @interledger/http-signature-utils to v1.0.4 (#724)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency @tanstack/react-query to ^4.35.0 (#725)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency eslint to ^8.49.0 (#727)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(commerce/backend): add pre-interaction checkout flow (#723)

* Draft

* Progress

* Make tests work again

* Progress

* Refactor

* Remove calculateTotalAmount

* Remove parseKey

* Progress

* Add cache

* Rename fix

* Add token cache

* Update OP libraries

* Downgrade `interledger/open-payments`: breaking changes

* Fixes

* Typo

* Address feedback

* fix(quote): change invalid amount error (#729)

* fix(quote): change invalid amount error

* fix: resolve lint issue

* feat(commerce/frontend): add checkout view (#731)

* Add checkout view

* Backend changes

* Fixes

* fix(rapyd): add additional beneficiary fields on withdraw money (#730)

* fix(rapyd): add additional beneficiary fields on withdraw money

* fix: generate required fields

* fix: remove console.log

* fix: resolve some address issues

* chore(deps): update typescript-eslint monorepo to ^6.7.0 (#735)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update pnpm to v8.7.5 (#734)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency express-rate-limit to ^6.11.2 (#736)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency @tanstack/react-query to ^4.35.3 (#743)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency jest to ^29.7.0 (#744)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency react-router-dom to ^6.16.0 (#747)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(commerce): post-interaction checkout flow (#733)

* Initial design for order confirmation page

* Progress

* More progress ..

* Add orders worker

* Finish checkout

* Prevent multiple submissions

* Address feedback

* Address feedback

* Address feedback

* Refactor prepare method

* Address feedback

* Address feedback

* chore(deps): update dependency @types/jest to ^29.5.5 (#752)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency uuid to ^9.0.1 (#751)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency express-rate-limit to v7 (#754)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency @types/react to v18.2.22 (#759)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update typescript-eslint monorepo to ^6.7.2 (#760)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency postcss to ^8.4.30 (#761)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency sharp to ^0.32.6 (#762)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(commerce): verify interaction hash and add polling mechanism (#763)

* Hash verification

* Finish polling mechanism

* Format

* Fix tests

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: xplicit <111863110+beniaminmunteanu@users.noreply.github.com>
Co-authored-by: dragosp1011 <109967337+dragosp1011@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: boutique/backend Boutique backend implementations type: test Improvements or additions to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add first phase of the checkout flow (pre-interaction) Add OP client
3 participants