feat: add MBWay and Wero APM integrations#198
feat: add MBWay and Wero APM integrations#198Bala1324 wants to merge 6 commits intopaypal-examples:mainfrom
Conversation
| value: z.string(), | ||
| }); | ||
|
|
||
| const ClientOrderPayloadSchema = z.object({ |
There was a problem hiding this comment.
Are you able to implement these new APMs without any Order creation changes? We cannot accept purchase_units from the client code. We need to abstract this.
There was a problem hiding this comment.
Agreed, this is a blocker to merging, we cannot teach purchase_units to be passed in from the client side
There was a problem hiding this comment.
Removed ClientOrderPayloadSchema and the purchase_units path entirely. Client now sends only {currencyCode, processingInstruction } -- no purchase_units from client. Server builds the order payload using OneTimePaymentSchema.
| ); | ||
|
|
||
| router.get( | ||
| "/paypal-api/checkout/orders/:orderId", |
There was a problem hiding this comment.
| "/paypal-api/checkout/orders/:orderId", |
Can we use the existing "/paypal-api/checkout/orders/create-order-for-one-time-payment" route for this behavior and add a new optional param to it for processingInstruction?
There was a problem hiding this comment.
Reused the existing /paypal-api/checkout/orders/create-order-for-one-time-payment route and added processingInstruction as an optional param
dwilliams27
left a comment
There was a problem hiding this comment.
Some comments that should be addressed
| value: z.string(), | ||
| }); | ||
|
|
||
| const ClientOrderPayloadSchema = z.object({ |
There was a problem hiding this comment.
Agreed, this is a blocker to merging, we cannot teach purchase_units to be passed in from the client side
| ); | ||
|
|
||
| router.get( | ||
| "/paypal-api/checkout/orders/:orderId", |
| for (const { sku, quantity } of cart) { | ||
| const { name, price } = getProduct(sku); | ||
| totalAmount += Number.parseFloat(price) * quantity; | ||
| totalAmount += parseFloat(price) * quantity; |
There was a problem hiding this comment.
This should be left as Number.parseFloat
There was a problem hiding this comment.
Reverted back to Number.parseFloat. Fixed.
| // console.log( | ||
| // "[createOrderForOneTimePayment] Orders payload sent to v2/checkout/orders:", | ||
| // JSON.stringify(parsed, null, 2), | ||
| // ); |
There was a problem hiding this comment.
These commented out debug log blocks should all be removed before merging
There was a problem hiding this comment.
Removed all commented out debug log blocks.
|
|
||
| response.status(statusCode).json(result); | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Was newline removed here?
There was a problem hiding this comment.
Fixed. Added newline at end of file.
| throw new Error("Missing API credentials"); | ||
| } | ||
|
|
||
| export const PAYPAL_BASE_URL ="https://api-m.sandbox.paypal.com"; |
There was a problem hiding this comment.
This shouldn't be needed once fetch is removed
There was a problem hiding this comment.
Agreed. Removed PAYPAL_BASE_URL and direct fetch. processingInstruction is now handled via ProcessingInstruction.OrderCompleteOnPaymentApproval enum from the SDK. The enum exists in the SDK source but not yet published to npm — raised a PR to the SDK repo. Once merged and released, this will work cleanly without any direct fetch.
7912441 to
650178e
Compare
| ``` | ||
| The server will run on `http://localhost:8080` | ||
|
|
||
| ### Client Setup |
There was a problem hiding this comment.
I think these client steps are no longer needed. All a developer has to do is run the server for static examples like this. Ex:
cd server/node
npm install
npm start
There was a problem hiding this comment.
Removed the Client Setup section from both the MBWay and Wero README files. Developers only need to run the server for static examples.
| ) { | ||
| const { currencyCode, totalAmount, items } = OneTimePaymentSchema.parse( | ||
| request.body ?? {}, | ||
| request.body, |
There was a problem hiding this comment.
Please add this back. There are use cases where the POST body is empty so we want it to default to an empty object.
| request.body, | |
| request.body ?? {}, |
There was a problem hiding this comment.
Added ?? {} back to default to an empty object when the POST body is empty.
This PR adds sample integrations for two new Alternative Payment Methods (APMs) — MBWay and Wero
Changes
Client
MbWay
Wero
Server