{"version":3,"sources":["webpack:///./node_modules/@abaco/buyer-contract-module/src/modules/buyer-contract-module/api/PaymentApi.ts"],"names":["PaymentApi","http","rootPath","contractId","url","this","get","res","data","undefined","propsToDate","newInvoiceData","post","pkid","editedContract","put","service","subscriptionType","duration","parseInt","paymentId","couponCode","form","coupon_ids"],"mappings":"yOAGqBA,E,WACjB,WAAoBC,EAA0BC,GAAgB,uBAA1C,KAAAD,OAA0B,KAAAC,W,8GAEvC,WAAqBC,GAArB,gGACGC,EADH,UACYC,KAAKH,SADjB,4BAC6CC,EAD7C,0BAEeE,KAAKJ,KAAKK,IAAIF,GAF7B,cAEGG,EAFH,OAGc,OAAbA,EAAIC,WAA8BC,IAAbF,EAAIC,MAAmC,KAAbD,EAAIC,MACnDE,eAAYH,EAAIC,KAAM,CAAC,cAJxB,kBAMID,EAAIC,MANR,gD,gJASA,WAAsBL,EAAoBQ,GAA1C,gGACGP,EADH,UACYC,KAAKH,SADjB,2BAC4CC,EAD5C,qBAEeE,KAAKJ,KAAKW,KAAKR,EAAKO,GAFnC,cAEGJ,EAFH,yBAGIA,EAAIC,MAHR,gD,kJAMA,WAAsBK,EAAcC,GAApC,gGACGV,EADH,UACYC,KAAKH,SADjB,2BAC4CW,GAD5C,SAEeR,KAAKJ,KAAKc,IAAIX,EAAKU,GAFlC,cAEGP,EAFH,yBAGIA,EAAIC,MAHR,gD,iJAMA,WAAqBQ,EAAyBC,GAA9C,gGACGb,EADH,UACYC,KAAKH,SADjB,uBACwCc,EADxC,yBACgEC,GADhE,SAEeZ,KAAKJ,KAAKK,IAAIF,GAF7B,cAEGG,EAFH,OAGC,kBAAoBA,EAAIC,KAAKU,WAC7BX,EAAIC,KAAKU,SAAWC,SAASZ,EAAIC,KAAKU,WAJvC,kBAMIX,EAAIC,MANR,gD,8IAwBA,WAAkBK,EAAcO,EAAmBC,GAAnD,kGACGC,EAAOD,EAAa,CAAEE,WAAYF,GAAe,GACjDjB,EAFH,WAEaC,KAAKH,SAFlB,mBAEqCkB,EAFrC,gCAEsEP,GAFtE,SAGeR,KAAKJ,KAAKc,IAAIX,EAAKkB,GAHlC,cAGGf,EAHH,yBAIIA,EAAIC,MAJR,gD","file":"js/chunk-2d21ad1b.cbe6be79.js","sourcesContent":["import { HTTPClient, propsToDate } from \"@abaco/web-common/src/HTTP\";\nimport { InvoiceData, InvoiceDataOut, PaymentInfo, PaymentService, SubscriptionType } from \"../models/Payment\";\n\nexport default class PaymentApi {\n constructor(private http: HTTPClient, private rootPath: string) {}\n\n public async getInvoiceData(contractId: number): Promise {\n const url = `${this.rootPath}/v1/b2c/contract/${contractId}/last_invoice`;\n const res = await this.http.get(url);\n if (res.data !== null && res.data !== undefined && res.data !== \"\") {\n propsToDate(res.data, [\"dt_insert\"]);\n }\n return res.data;\n }\n\n public async saveInvoiceData(contractId: number, newInvoiceData: InvoiceDataOut): Promise {\n const url = `${this.rootPath}/v1/b2c/invoice/${contractId}/invoice`;\n const res = await this.http.post(url, newInvoiceData);\n return res.data;\n }\n\n public async editInvoiceData(pkid: number, editedContract: InvoiceDataOut): Promise {\n const url = `${this.rootPath}/v1/b2c/invoice/${pkid}`;\n const res = await this.http.put(url, editedContract);\n return res.data;\n }\n\n public async getPaymentInfo(service: PaymentService, subscriptionType: SubscriptionType): Promise {\n const url = `${this.rootPath}/v1/payment/${service}/payment_info/${subscriptionType}`;\n const res = await this.http.get(url);\n if (\"string\" === typeof res.data.duration) {\n res.data.duration = parseInt(res.data.duration);\n }\n return res.data;\n // return {\n // client_id: \"AVenXqhSeDSaj0Op1l8oF86nDZtVZg0cUGnw6jQ1ngkSCvOl5i61I9YkqjW9iPvkZjyxZG9-h1l9132j\",\n // plan_id: \"P-4CS998956F6846031MFK2JKQ\",\n // currency: \"EUR\",\n // duration: 365,\n // price: 220\n // }\n\n // plan_id: 'P-26N90344FL252213SMFKXQRY'\n\n // P-0KJ07292F06400433MFKXACI actual 220€\n // \"P-00Y928400H160573MME7XZSA\" old 300€\n // live client id AZHNgsYagHkbQKeLZVDSKYITQjjnnsqZiQq-U5VgJqkY7XaQ7Z64dMhqccMUpz641IW8Z69YUZ-oR3B_\n // test client id AVenXqhSeDSaj0Op1l8oF86nDZtVZg0cUGnw6jQ1ngkSCvOl5i61I9YkqjW9iPvkZjyxZG9-h1l9132j\n //return {client_id: \"AVenXqhSeDSaj0Op1l8oF86nDZtVZg0cUGnw6jQ1ngkSCvOl5i61I9YkqjW9iPvkZjyxZG9-h1l9132j\"};\n }\n\n public async savePayment(pkid: number, paymentId: string, couponCode: string | null) {\n const form = couponCode ? { coupon_ids: couponCode } : {};\n const url = ` ${this.rootPath}/v1/b2c/${paymentId}/transaction/invoice/${pkid}`;\n const res = await this.http.put(url, form);\n return res.data;\n }\n}\n"],"sourceRoot":""}