Skip to content

Commit 01761c2

Browse files
committed
add get-payment
1 parent 92a5c92 commit 01761c2

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import quickbooks from "../../quickbooks.app.mjs";
3+
4+
export default {
5+
key: "quickbooks-get-payment",
6+
name: "Get Payment",
7+
description: "Returns info about a payment. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#read-a-payment)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
quickbooks,
12+
paymentId: {
13+
propDefinition: [
14+
quickbooks,
15+
"paymentId",
16+
],
17+
},
18+
minorVersion: {
19+
propDefinition: [
20+
quickbooks,
21+
"minorVersion",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
if (!this.paymentId) {
27+
throw new ConfigurationError("Must provide paymentId parameter.");
28+
}
29+
30+
const response = await this.quickbooks.getPayment({
31+
$,
32+
paymentId: this.paymentId,
33+
params: {
34+
minorversion: this.minorVersion,
35+
},
36+
});
37+
38+
if (response) {
39+
$.export("summary", `Successfully retrieved payment with id ${response.Payment.Id}`);
40+
}
41+
42+
return response;
43+
},
44+
};

components/quickbooks/quickbooks.app.mjs

+26-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export default {
149149
optional: true,
150150
},
151151
purchaseId: {
152-
label: "purchase Id",
152+
label: "Purchase Id",
153153
type: "string",
154154
description: "Id of the purchase.",
155155
withLabel: true,
@@ -376,6 +376,23 @@ export default {
376376
});
377377
},
378378
},
379+
paymentId: {
380+
type: "string",
381+
label: "Payment Id",
382+
description: "The identifier of a payment",
383+
async options({ page }) {
384+
return this.getPropOptions({
385+
page,
386+
resource: "Payment",
387+
mapper: ({
388+
Id: value, CustomerRef: customerRef, TotalAmt: totalAmt, TxnDate: txnDate,
389+
}) => ({
390+
value,
391+
label: `${customerRef.name} - Amount: ${totalAmt} - ${txnDate}`,
392+
}),
393+
});
394+
},
395+
},
379396
},
380397
methods: {
381398
_companyId() {
@@ -535,6 +552,14 @@ export default {
535552
...opts,
536553
});
537554
},
555+
getPayment({
556+
paymentId, ...opts
557+
}) {
558+
return this._makeRequest({
559+
path: `company/${this._companyId()}/payment/${paymentId}`,
560+
...opts,
561+
});
562+
},
538563
query(opts = {}) {
539564
return this._makeRequest({
540565
path: `company/${this._companyId()}/query`,

0 commit comments

Comments
 (0)