feat(medusa, stripe, paypal): Add update payment session support to the abstract payment processor API (#4442)
* feat(medusa, stripe, paypal): Add update payment session support to the abstract payment processor API * continue to add updatePaymentData * feat: Add update payment data to paypal as well and add stripe tests * fix stripe updatePaymentData returned object type * fix tests * Create three-ravens-raise.md * fix paypal updatePayment data impl --------- Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
1 parent
1903217705
commit
4264302f21
9 files changed
+345
-138
No files matched your search
@@ -17,6 +17,7 @@ import { humanizeAmount } from "medusa-core-utils"
|
||||
import { roundToTwo } from "./utils/utils"
|
||||
import { CreateOrder, PaypalSdk } from "../core"
|
||||
import { Logger } from "@medusajs/types"
|
||||
import { MedusaError } from "@medusajs/utils"
|
||||
|
||||
class PayPalProviderService extends AbstractPaymentProcessor {
|
||||
static identifier = "paypal"
|
||||
@@ -280,6 +281,23 @@ class PayPalProviderService extends AbstractPaymentProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
async updatePaymentData(sessionId: string, data: Record<string, unknown>) {
|
||||
try {
|
||||
// Prevent from updating the amount from here as it should go through
|
||||
// the updatePayment method to perform the correct logic
|
||||
if (data.amount) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
"Cannot update amount, use updatePayment instead"
|
||||
)
|
||||
}
|
||||
|
||||
return data
|
||||
} catch (e) {
|
||||
return this.buildError("An error occurred in updatePaymentData", e)
|
||||
}
|
||||
}
|
||||
|
||||
async retrieveOrderFromAuth(authorization) {
|
||||
const link = authorization.links.find((l) => l.rel === "up")
|
||||
const parts = link.href.split("/")
|
||||
|
||||
Reference in new issue
Block a user