How to get list of payment methods/shipping method and assign it to a order (suitescript) - netsuite

I'm working with creating salesorder in netsuite using suitescript but I can't find any document about "payment method", so how can I get a payment method such as VISA card and assign to the order? (I think it's required a payment method id but I didn't find payment method in supported suitescript records).
[update]
Here is my code:
var order = nlapiCreateRecord("salesorder");
// set some field value
// order.setFieldValue(....)
Now I want get payment method and shipping method id to set to order:
order.setFieldValue("shipmethod", shippingmethodId);
order.setFieldValue("paymentmethod", paymentmethodId);
I already have payment method name "Test Payment Method" and shipping method "Test Shipping Method". How can I get their id using their name?

For Payment Methods:
To get a list of the payment methods and their respective IDs available in your NetSuite account, you should navigate to Setup > Accounting > Accounting Lists. You will see a Type filter on the bottom of the page. Select Payment Method in there and you'll be able to see the different payment methods available for you.
For Shipping Methods:
Navigate to Lists > Accounting > Shipping Items.
Edit:
Actually you don't need to. Use nlobjRecord.setFieldText instead of setFieldValue i.e. order.setFieldText('VISA')

You can use hard-coded values instead of getting the values dynamically.

Related

Search payment records information in Netsuite using Suitelet

Need to get payment data from Transaction >> Payable >> Pay single vendor form and create a data file. This has been done with an eventscript (add button), a clientscript and a Suitelet by searching currentRecord data from client script to Suitelet and generated a file. However, searching Transaction record type could not get payer payment department and cost center data as I know. So any advice and recommendation from Netsuite experts on how can get these payer data from Netsuite with the existing Transaction information on the Bill Payment form, like payment check number, entity id, transaction number, etc ?
When using the N/search module the following 3 tools are invaluable for retrieving data from netsuite transactions.
Netsuite records browser (shows all of the fields, available search filters, and joins ect.)
https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_1/script/record/vendorpayment.html
Another great tool is an extension called Netsuite Field Explorer developed by Michoel Chaikin
you can also turn on field ids in your account by navigating to Home->Set preferences->General tab->Set defaults->Show internal ids
(This will show the field id when you click on the field "What is this?" link directly on the record)
between the three you should be able to get everything you need to run a search and retrieve the data you are looking for.
Depending on your needs you can either search.create (return multiple records) or search.lookupfield(return a single record)

Get Default Payment Source (default card) for Stripe Customer?

I created a POC with a customer/credit card in Stripe and I logged into my dashboard within Stripe and was able to see this customer has a default source (the test credit card I added) associated correctly. It shows this card is the default source.
When I run this .Net code:
var customerService = new CustomerService();
var stripeCustomer = await customerService.GetAsync(customerId);
To get that customer, it returns everything correctly except his source. All of the fields I had hoped I can find it from are empty! I want to know his default payment source so I can show it on the front end with a little icon to indicate it's default.
DefaultSource, DefaultSourceId, and Sources properties are all blank/null.
Is there a way to have Stripe return it, or do I need to do something else? I tried the 'expand' property for the GetAsync method but that threw an error saying the above properties are not expandable (i.e. I can't ask Stripe to expand/return Source).
Any ideas what I can do?
FYI I also tried this:
var paymentMethodService = new PaymentMethodService();
var cards = await paymentMethodService.ListAsync(new PaymentMethodListOptions { Customer = customerId, Type = "card"});
and there doesn't seem to be a property anywhere that says the card is default (although it does correctly return all cards). I believe Stripe documentation states the Customer is the holder of the default source, not the card object. What gives?
Thanks in advance!
It looks like you're using Payment Methods, since your payment method list call has the results you expect, which means the customer likely doesn't have any sources. You can try that again with the properly pluralized expand[]=sources if you do know your Customer has Sources attached.
For Payment Methods, there is no general default for the Customer. For one-time Payment Intents, you must always specify the payment_method from among those attached to the Customer for future payments.
For paying invoices (related to recurring subscriptions, eg), you can set the invoice_settings.default_payment_method for Customer. This only applies to invoices.

How to get newly created sales order internal id in suitescript 2.0?

I'm writing a suitescript to send order details to a customer email address.
Is it possible to get the sales order id through scriptContext or similar method?
My function is run on Sales Order After Submit.
function afterSubmit(scriptContext){
soid = scriptContext.soid; //<--trying to get the sales order id
}
In an afterSubmit, you can use scriptContext.newRecord.id.
See afterSubmit documentation here: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4407992281.html
and record.Record object members documentation here: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4267255811.html#bridgehead_4273190849

How to create a campaign in Netsuite erp

Hi i am working with NetSuite and I just want to know to create a email campaign, what are the required attributes and methods to create a email campaign pro-grammatically?
Any help on this will be great.
You can use nlapiSendCampaignEmail(campaigneventid, recipientid)
Both, the parameters are required.
As per docs:
Use this function to send a single “on-demand” campaign email to a
specified recipient and return a campaign response ID to track the
email. This function works in conjunction with the Lead Nurturing
(campaigndrip) sublist only; it does not work with the E-mail
(campaignemail) sublist.

How to get customer billing address in blCheckoutWorkflow in broadleaf?

I would like to the get customer billing address details and would like to log them in an activity class in the blCheckoutWorkflow.
I have tried the following.
Order order=context.getOrder();
Customer c=order.getCustomer();
c.getCustomerPayments().get(0).getBillingAddress();
But here the size of the list returned by getCustomerPayments() is 0. So I am getting ArrayIndexOutOfBoundsException.
Is there a way to get the billing address that is entered by the customer in the /checkout.
Kindly, reply me.
getCustomerPayments() is designed to hold saved payment information for a particular Customer and is not really applicable to the current Order. This is used when a Customer wants to save payment information for checking out next time (the 'token' property on CustomerPaymentImpl is used to look up the PCI-sensitive data from the payment gateway).
If you are using Broadleaf 3.1.0-GA+ then you should do:
Order order = context.getOrder();
Address billingAddress = order.getOrderPayments().get(0).getBillingAddress();
If you are using Broadleaf 3.0.10-GA or below you should do:
Order order = context.getOrder();
Address billingAddress = order.getPaymentInfos().get(0).getAddress();

Resources