feat(dashboard,js-sdk,types): add ability to capture payment from order page (#8368)
what: - adds ability to capture payment from order page bugs found: - when capturing payment of one order, other orders statuses get affected from "captured" to "partially captured". Will investigate this separately. https://github.com/user-attachments/assets/0a1beac2-74fc-4803-8528-8de5913964d4
This commit is contained in:
1 parent
4a7b2fd625
commit
3169543d56
10 files changed
+160
-30
No files matched your search
@@ -8,6 +8,7 @@ import { InventoryItem } from "./inventory-item"
|
||||
import { Invite } from "./invite"
|
||||
import { Notification } from "./notification"
|
||||
import { Order } from "./order"
|
||||
import { Payment } from "./payment"
|
||||
import { PriceList } from "./price-list"
|
||||
import { PricePreference } from "./price-preference"
|
||||
import { Product } from "./product"
|
||||
@@ -59,6 +60,7 @@ export class Admin {
|
||||
public productTag: ProductTag
|
||||
public user: User
|
||||
public currency: Currency
|
||||
public payment: Payment
|
||||
|
||||
constructor(client: Client) {
|
||||
this.invite = new Invite(client)
|
||||
@@ -90,5 +92,6 @@ export class Admin {
|
||||
this.productTag = new ProductTag(client)
|
||||
this.user = new User(client)
|
||||
this.currency = new Currency(client)
|
||||
this.payment = new Payment(client)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { HttpTypes, SelectParams } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
export class Payment {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async capture(
|
||||
id: string,
|
||||
body: HttpTypes.AdminCapturePayment,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<{ payment: HttpTypes.AdminPayment }>(
|
||||
`/admin/payments/${id}/capture`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { AdminPaymentCollection } from "../payment/admin"
|
||||
import {
|
||||
BaseOrder,
|
||||
BaseOrderAddress,
|
||||
@@ -6,7 +7,10 @@ import {
|
||||
BaseOrderShippingMethod,
|
||||
} from "./common"
|
||||
|
||||
export interface AdminOrder extends BaseOrder {}
|
||||
export interface AdminOrder extends BaseOrder {
|
||||
payment_collections: AdminPaymentCollection[]
|
||||
}
|
||||
|
||||
export interface AdminOrderLineItem extends BaseOrderLineItem {}
|
||||
export interface AdminOrderFilters extends BaseOrderFilters {}
|
||||
export interface AdminOrderAddress extends BaseOrderAddress {}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
BasePayment,
|
||||
BasePaymentCollection,
|
||||
BasePaymentCollectionFilters,
|
||||
BasePaymentProvider,
|
||||
@@ -11,6 +12,7 @@ export interface AdminPaymentProvider extends BasePaymentProvider {
|
||||
is_enabled: boolean
|
||||
}
|
||||
|
||||
export interface AdminPayment extends BasePayment {}
|
||||
export interface AdminPaymentCollection extends BasePaymentCollection {}
|
||||
export interface AdminPaymentSession extends BasePaymentSession {}
|
||||
|
||||
@@ -21,3 +23,11 @@ export interface AdminPaymentProviderFilters
|
||||
export interface AdminPaymentCollectionFilters
|
||||
extends BasePaymentCollectionFilters {}
|
||||
export interface AdminPaymentSessionFilters extends BasePaymentSessionFilters {}
|
||||
|
||||
export interface AdminCapturePayment {
|
||||
amount?: number
|
||||
}
|
||||
|
||||
export interface AdminPaymentResponse {
|
||||
payment: AdminPayment
|
||||
}
|
||||
Reference in new issue
Block a user