Get Payment Instrument of Customer Record

Hi,

I need to develop a suitelet script which accept customer id and return payment instruments information such as payment card id, memo, etc

Get Payment Instrument of Customer Record

And this is my current script ( I don’t know how to find payment instrument so I developed it as return parent field value )

function onRequest(context) {
        try {
            if (context.request.method === http.Method.POST) {
                var requestBody = context.request.body;
                var customerId = JSON.parse(requestBody).customerId;
                var searchRec = search.create({
                    type: search.Type.CUSTOMER,
                    filters: [
                      ['internalid', 'anyof', customerId]
                    ],
                    columns: [
                      search.createColumn({ name: 'parent' })
                    ]
                }).run().getRange({
                    start: 0,
                    end: 1
                });
                if (searchRec.length > 0) {
                    var paymentMemo = searchRec[0].getValue({
                        name: 'parent'
                    });
                    var resData={
                        sucess:"Sucess",
                        memo: paymentMemo
                    };
                    context.response.write(JSON.stringify(resData));
                } else {
                    var errorRes = {
                        error: "Not found for the given customerId."
                    }
                    context.response.write(errorRes);
                }
            }
        } catch (e) {
            log.error('suitelet error', JSON.stringify(e));
            throw e.message;
        }

Please let me know if someone have knowledge to solve this problem.

Thank you

Rookie Asked on July 23, 2023 in Saved Searches.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor