The Braintree Transaction API has a field for lineItems, but how do I use it? The Transaction response doesn't return line items, and there are no lineitems int the control panel for transactions either.
It looks like the line items aren't actually stored anywhere. Am I right? If so, what's the point of them?
I want to show customers an itemised receipt of the transaction (which is a really obvious use case, right?). Is there anyway to get Braintree to generate this as part of the transaction?
I'm using version 2.5 of the Braintree Node.js SDK.
I'm not sure if this was the case a month ago when you asked the question, but it seems that the transaction response does return line items:
https://developers.braintreepayments.com/reference/response/transaction/node#line_items
UPDATED ANSWER
As of version 2.6.0 of the Braintree Node SDK, lineItems is an attribute of the Transaction response object. See Braintree's associated documentation here.
ORIGINAL ANSWER
You may use gateway.transactionLineItem.findAll(someTransactionId, function(err, response) {}) to retrieve the line items associated with a transaction. This is documented in the tests of the SDK:
specHelper.defaultGateway.transactionLineItem.findAll(response.transaction.id, function (err, response) {
assert.equal(response.length, 1);
let lineItem = response[0];
assert.equal(lineItem.quantity, '1.0232');
assert.equal(lineItem.name, 'Name #1');
assert.equal(lineItem.kind, 'debit');
assert.equal(lineItem.unitAmount, '45.1232');
assert.equal(lineItem.totalAmount, '45.15');
done();
});
We are in the process of updating our developer docs and Control Panel to reflect this behavior.
Related
I'm working on a little web application that will crawl and update baseball standings by day and track teams positions (among other things) over time.
I have an API I grab all of this from and a collection in MongoDB that stores all the team data and information for the current day. Right now I just run this manually but eventually it'll be automated to run at like 3am or whenever.
The API supplies a unique ID for each team that never changes. So what I'm doing is I'm taking in the team data from the API. Passing it to a function that then extracts the teams data (there is other data from the response object I don't need), puts it into an object for replacement, and then wherever that team ID exist in the collection its document is replaced in a bulkWite.
async function currentStandings(db,team_standings,callback){
const current_standings = db.collection('current_standings');
let replacePool = [];
for(const single_team of team_standings.data.standing){
let replaceOnePusher = {
replaceOne: {
"filter": {"team_id": single_team.team_id},
"replacement": single_team
}
}
replacePool.push(replaceOnePusher);
}
await current_standings.bulkWrite(replacePool);
callback();
}
However when I execute this code for the first time each day I get an error reading BulkWriteError: After applying the update, the (immutable) field '_id' was found to have been altered to _id: ObjectId('5f26e57b6831761ac840bf1d') (not the same ID every day) and if I look in Compass the data isn't updated. If I immediately run the script again, it goes through successfully without error. Refreshing the data in compass generates the correct data.
Can someone explain to me what is going wrong here? This is actually my first time using MongoDB since I wanted to learn it and this pet project seemed like a good place to start.
I am Using User event aftersubmit on Sales order to add/update line item. As soon as line item updated shipping cost should recalculate. I am using real time shipping method and cost.
Now If I change item manually, I need to click ‘calculate’ button under Shipping tab, which calculate and update shipping cost. But when I add/update line item using user event, it became ZERO.
Is there any way to calculate shipping cost by script? Is there any way to run functionality of native ‘calculate’ shipping cost button by script?
For your case i.e User event, we need a dynamic record to do this, so load a dynamic Sales Order record, using id from the Standard record in User Event context:-
var drSalesOrder = record.load({type: record.Type.SALES_ORDER, id: salesOrderId, isDynamic: true});
Then doing the following operations in this order(will calculate and set the shipping cost on the order):-
drSalesOrder.setValue({fieldId: 'shipcarrier', value: 'nonups'});
drSalesOrder.setValue({fieldId: 'shipmethod', value: SHIP_ITEMS.FedEx_Ground}); // your shipmethod id here
drSalesOrder.setValue({fieldId: 'shippingcostoverridden', value: true});
drSalesOrder.save({ignoreMandatoryFields: true, enableSourcing: true});
Not natively. We do the calculation by overriding the page element on pageInit, and adding other operations before running the native NS API call.
I know this question is old but on my case I cant get these answers to work (although its the same what is in SuiteAnswer), and I was stuck for some hours trying to retrigger the computation of shipping cost.
What I did is to call the calculateRates() Netsuite's function on saveRecord function in client script. I am lucky the client does not require this in the server. Although its not the correct way but its more okay than not working :)
const saveRecord = (context) => { Shipping.calculateRates(); return true; }
Hope this helps. Thank you!
I am developing a transaction workflow capsule, and I use the function transaction.retrieve() to get order data from the platform. But it returns only part of the order data.
MyReceipt is a structure stored the order informations, it is defined like this:
structure (MyReceipt) {
description (order info)
// properties
features { activity}
}
And it is built as a output concept of Commit Action, like this
action (CommitRequest) {
type (Commit)
description ()
collect {
// MyRequest
}
output (MyReceipt)
}
I try to get data like this
transaction.retrieve("bixby.MyCapsule.MyReceipt")
It is supposed to return all the MyReceipt Data. But it return only part of the Receipt data.Is it right to get all the orders? Or is there other ways to get all the receipt data?
And I have found the sample code use it just like this to get the last Receipt data
transaction.retrieve("bixby.MyCapsule.MyReceipt", "ALL", 1)
but it doesn't explain what these two parameter "ALL" and 1 represent for. And I want to get more details about the usage of this function.
Could you plz tell me how to use the function transaction.retrieve() or other function to get all the Receipt historical data, and How can I check out the transaction data for someone when I try to find the cause of the issue.
Copy the answer from dogethis. (Thanks, man! You do the hard work, I took credit)
We have the DOC ready online here
Basically, ALL is the default to get all state of transaction data, and 1 means only one record. The API page was not there before, so thanks for let us know.
I think it's the 1 cause you not get all record, but it does has a limit 20...
Have fun with Bixby!
I have upgraded the Stripe.net to the latest version which is 20.3.0 and now I don't seem to find the .Last4 for the credit card. I had the following method:
public void CreateLocalCustomer(Stripe.Customer stipeCustomer)
{
var newCustomer = new Data.Models.Customer
{
Email = stipeCustomer.Email,
StripeCustomerId = stipeCustomer.Id,
CardLast4 = stipeCustomer.Sources.Data[0].Card.Last4
};
_dbService.Add(newCustomer);
_dbService.Save();
}
But now the stipeCustomer.Sources.Data[0].Card.Last4 says 'IPaymentSource' does not contain a definition for 'Card'. Does anyone know how I can get the card details now? The flow is that I create the customer by passing the Stripe token to Stripe, then I get the above stripeCustomer. So I expect it to be somewhere in that object. But I can't find it. The release notes can be found here.
Thank you.
In the old world of Stripe, there only used to be one type of payment method you could attach to a Customer; specifically, Card-objects. You would create a Card-object by using Stripe.js/v2 or the Create Token API Endpoint to first create a Token-object and then attach that token to a Customer-object with the Create Card API Endpoint.
Once Stripe expanded to support a number of other payment methods though, Stripe built support for a new object type that encapsulated a number of payment methods (including credit cards) called Source-objects. A Source-object is created either by using Stripe.js/v3 or the Create Source API Endpoint. It can also be attached to a Customer-object in much the same way as the Card-objects mentioned above, except they retain their object type. They're still a Source. You use the Attach Source API Endpoint to do this (that is notably identical to the Create Card API Endpoint mentioned above).
What I'm getting at here, is there are now two different object types (or more) that you can expect to see returned in the sources-array (or Sources in .NET). All of these methods though inherit from the IPaymentSource-interface. So if you know you have a Card-object getting returned, you can simply cast the returned object to the Card-class.
Something like this should get you going:
CardLast4 = ((Card) stipeCustomer.Sources.Data[0]).Last4
You can see what I mean by inheritance by looking at this line in the Card-class file:
https://github.com/stripe/stripe-dotnet/blob/master/src/Stripe.net/Entities/Cards/Card.cs#L7
Good luck!
As of Stripe.net.21.4.1, this is what works:
var chargeService = new ChargeService();
var charge = chargeService.Get(id);
CardLast4 = ((Card)charge.Source).Last4;
It's getting hard not to panic when code breaks because of all the micro-changes Stripe makes.
So after debugging, it looks like the Data[0] needs to be cast as Card to get the card.
So it will be CardLast4 = ((Card)stipeCustomer.Sources.Data[0]).Last4.
This is more of a call for help with an exception when calling insertEntity().
I'm using Nodejs on Azure and editing in Monaco, and I've NPM-installed the latest version of azure storage.
The exception I encounter is: (full stack trace at the bottom)
Unaught exception: Error: Parameter entityDescriptor.PartitionKey for function entityOperation should be an object at ArgumentValidator._.extend.object
I'm basically taking my object to save, and creating 2 new properties: PartitionKey and RowKey. I give them string values. I'm following the examples. I'm not using entityGenerator, as the samples here don't, whereas the examples on the Azure Node developers portal do. I wouldn't mind using entityGenerator on the storage-specific properties if required, but the samples in the node azure github repo seem to suggest that you can use simple strings. The entityGenerator looks a bit ugly and cumbersome, honestly, as you'd have to code extra around the entity when you bring it back.
How can I adjust my code to solve this problem and call insertEntity() with success?
exports.saveTally = function(tally, callback) {
var tableSvc = getAzureTableService();
tableSvc.createTableIfNotExists("tally", function(error, result, response) {
if (!error) {
tally.PartitionKey="tally";
tally.RowKey = tally.id;
tableSvc.insertEntity("tally", tally, function(error, result, response) {
if (error) {
console.log("*Error saving tally " + error.toString());
}
else {
callback(tally.id);
}
});
}
});}
The location of the Azure storage client library has changed to https://github.com/Azure/azure-storage-node. The samples you’re using are from the old location and from an older version of the library which is why they’re not working. You’ll find updated samples and code at the new location.
In the newer version, an Edm type must be specified for each table entity. This is because type is stored in the storage service and we want to make sure that we are storing what you intend. Each table entity is an object with the form {_:value, $:Edm.Type}.
Entity generator is a convenience feature which makes it simpler to construct table entity objects. We return entities in the form just mentioned and using this convenience feature will not change that in any way.