feat(medusa-js): Add payment and payment collections clients (#2608)

This commit is contained in:
Carlos R. L. Rodrigues
2022-11-15 21:27:00 +01:00
committed by GitHub
parent 3de553c27f
commit ccfc5f666d
7 changed files with 181 additions and 1 deletions
+1
View File
@@ -66,3 +66,4 @@ export * from "./routes/store/returns"
export * from "./routes/store/shipping-options"
export * from "./routes/store/swaps"
export * from "./routes/store/variants"
export * from "./routes/store/payment-collections"
@@ -45,7 +45,33 @@ import { PaymentCollectionService } from "../../../../services"
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.paymentCollections.sessions(payment_id, payload)
*
* // Total amount = 10000
*
* // Adding two new sessions
* medusa.paymentCollections.manageSessions(payment_id, [
* {
* provider_id: "stripe",
* customer_id: "cus_123",
* amount: 5000,
* },
* {
* provider_id: "manual",
* customer_id: "cus_123",
* amount: 5000,
* },
* ])
* .then(({ payment_collection }) => {
* console.log(payment_collection.id);
* });
*
* // Updating one session and removing the other
* medusa.paymentCollections.manageSessions(payment_id, {
* provider_id: "stripe",
* customer_id: "cus_123",
* amount: 10000,
* session_id: "ps_123456"
* })
* .then(({ payment_collection }) => {
* console.log(payment_collection.id);
* });