Acceptance criteria:
- The payment bounded context has a new use case that allows to capture a one-time payment.
Implementation Details
This needs a number of changes, building on each other:
- Change configuration T361100: Adapt PayPal configuration to have two return URLS
- Add method to load Orders to PayPalPaymentIdentifierRepository T361102: Add a database method to find Orders by Order ID
- Add a captureOrder API method to the PaypalAPI interface and implementation. It should receive an order id (string) and call the "capture order" Paypal endpoint (see https://developer.paypal.com/docs/api/orders/v2/#orders_capture ) . It should return the id string from the purchase_units.payments.capture section of the response. This is the Transaction ID.
- Create use case (e.g. CapturePayPalPaymentUseCase or CapturePayPalOrderUseCase) in the payment bounded context. It should:
- Receive an OrderID (string) as parameter
- load the Order with the OrderId
- call the CaptureOrder method of the API. This will return the transaction ID
- add the transaction id to the order
- store the order
- If everything went well, return a success result object with the payment id and transaction id
- If the API call failed, or something was not found in the database, return an error result object