How do I add my shopping cart items to Transaction.item_list_.items - paypal

I am trying to pass over my shopping cart items to paypal using the .net REST API SDK
Below is the code:
Dim b As Integer = 0
Dim pCartItem As New PayPal.Api.Payments.Item
Dim pCartItemList As New PayPal.Api.Payments.ItemList
Do While b <= cart.Count - 1
pCartItem.name = cart(b).Name
pCartItem.price = cart(b).Price
pCartItem.quantity = cart(b).Quantity
pCartItem.currency = "USD"
pCartItem.sku = cart(b).Sku
pCartItemList.items.Add(pCartItem) 'This line errors out
pCartItem = New PayPal.Api.Payments.Item
b += 1
Loop
orderTransaction.item_list = pCartItemList
The line that errors out pCartItemList.items.Add(pCartItem) throws the error "Object reference not set to the instance of an object. Try using the keyword "new" :. I don't understand why because when i hover over the pCartItem in Visual Studio I am able to see all the correct values that have been assigned from my shopping cart.
Is this even the right way to add Item objects to the Transacation.item_list ?
Any help would be greatly appreciated.
Thanks,
Tommy

I have figured out that error for anyone else who may run into this here is the code that works
Dim pCartItem As PayPal.Api.Payments.Item = New PayPal.Api.Payments.Item
orderTransaction.item_list = New PayPal.Api.Payments.ItemList
orderTransaction.item_list.items = New List(Of PayPal.Api.Payments.Item)
Do While b <= cart.Count - 1
pCartItem.name = cart(b).Name
pCartItem.price = cart(b).Price
pCartItem.quantity = cart(b).Quantity
pCartItem.currency = "USD"
pCartItem.sku = cart(b).Sku
orderTransaction.item_list.items.Add(pCartItem)
pCartItem = New PayPal.Api.Payments.Item
b += 1
Loop

Related

how to hide other column

In my datagridview, I just want to show other fields such as ID,LastName,FirstName, and MiddleName and i dont want to show any fields but i want it to retrieve even it's hidden. But when i specify what i just want to show in my datagridview it causes runtime error.
this is my code to load the datagridview.
MysqlConn.Open()
Dim Query As String
Query = "select ID,LastName,FirstName,MiddleName from god.precord"
COMMAND = New MySqlCommand(Query, MysqlConn)
SDA.SelectCommand = COMMAND
SDA.Fill(dbDataSet)
bSource.DataSource = dbDataSet
DataGridView1.DataSource = bSource
SDA.Update(dbDataSet)
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
then this is my code for retrieve data into textboxes
Private Sub DataGridView1_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If e.RowIndex >= 0 Then
Dim row As DataGridViewRow
row = Me.DataGridView1.Rows(e.RowIndex)
txtid.Text = row.Cells("ID").Value.ToString
txtlastname.Text = row.Cells("LastName").Value.ToString
txtfirstname.Text = row.Cells("FirstName").Value.ToString
txtmiddlename.Text = row.Cells("MiddleName").Value.ToString
txtaddress.Text = row.Cells("Address").Value.ToString
txtcontactno.Text = row.Cells("ContactNo").Value.ToString
txtgender.Text = row.Cells("Gender").Value.ToString
dtpbirthdate.Text = row.Cells("Birthdate").Value.ToString
txtage.Text = row.Cells("Age").Value.ToString
End If
End Sub
runtime error
please help me this is for my thesis
thankyou in advance <3
You have to add hidden column into the select query to retreive the data.
Hide the column from the DataGridView instead.
try
MysqlConn.Open()
Dim Query As String
Query = "select ID,LastName,FirstName,MiddleName,Address from god.precord"
COMMAND = New MySqlCommand(Query, MysqlConn)
SDA.SelectCommand = COMMAND
SDA.Fill(dbDataSet)
bSource.DataSource = dbDataSet
DataGridView1.DataSource = bSource
SDA.Update(dbDataSet)
DataGridView1.Columns("Address").Visible = false
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try

Libreoffice Calc run macro with HYPERLINK

I'm trying to use hyperlinks instead of buttons to run Basic macros. It seems to be more natural to me because hyperlinks are directly connected to a cell and buttons are not.
I'm using the following Formula:
=HYPERLINK("vnd.sun.star.script:Standard.Module1.Test?language=Basic&location=document";"Check")
It should call the Subroutine Test placed in the document's macros under Standard.Module1 and display the Text 'Check' in the Cell it is written.
This works absolutely fine with libreoffice 3.6.1.2 but it doesn't work at all with version 4.1.4.2. I can't see any errors it just happens nothing at all. I tried to simply click the Hyperlink and also to hold CTRL and click it. Same result - nothing.
When I use a button the macro works as expected.
Does anyone know how to solve this problem?
This seems to be a bug in Calc. The protocol vnd.sun.star.script runs in hyperlink URLs in Writer still in version 4.2. But in Calc it runs not.
As a workaround you could have the following function attached to the sheet event "Double click". Then the macro runs if you double click the cell with the =HYPERLINK formula.
The last two versions are the results of my first ideas. I will let them in the answer because of comprehensibility reasons. But this last version is the best workaround in my opinion. It will closest work like the original vnd.sun.star.script: URL.
public function Doubelclicked(target) as Boolean
if left(target.formula, 32) = "=HYPERLINK(""vnd.sun.star.script:" then
sFormulaHyperlink = target.formula
sMacroURLRaw = mid(sFormulaHyperlink, 13, instr(13, sFormulaHyperlink, ";") - 13)
target.formula = "=""" & sMacroURLRaw
sMacroURL = target.string
target.formula = sFormulaHyperlink
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "URL"
args(0).Value = sMacroURL
oFrame = ThisComponent.CurrentController.Frame
oDisp.executeDispatch(oFrame, sMacroURL, "", 0, args)
end if
Doubelclicked = false
end function
Here are the previous versions:
public function Doubelclicked(target) as Boolean
if left(target.formula, 32) = "=HYPERLINK(""vnd.sun.star.script:" then
sMacroURL = mid(target.formula, 13, instr(13, target.formula, chr(34))-13)
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
oFrame = ThisComponent.CurrentController.Frame
oDisp.executeDispatch(oFrame, sMacroURL, "", 0, Array())
end if
Doubelclicked = false
end function
With this it is not possible to pass parameters in the macro URL. But if it only is the goal to get the address of the cell from which the macro was called, then this is possible because we have the target of the double click. So i have updated my workaround.
public function Doubelclicked(target) as Boolean
if left(target.formula, 32) = "=HYPERLINK(""vnd.sun.star.script:" then
lStartLocation = instr(13, target.formula,"&location=")
if lStartLocation > 0 then
lEndLocation = instr(lStartLocation + 1, target.formula,"&")
if lEndLocation = 0 then lEndLocation = instr(lStartLocation + 1, target.formula,"""")
sMacroURL = mid(target.formula, 13, lEndLocation - 13)
'msgbox sMacroURL
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
dim args(2) as new com.sun.star.beans.PropertyValue
args(0).Name = "TargetAddress"
args(0).Value = target.AbsoluteName
oFrame = ThisComponent.CurrentController.Frame
oDisp.executeDispatch(oFrame, sMacroURL, "", 0, args)
end if
end if
Doubelclicked = false
end function
Greetings
Axel

How to get the NextBillingDate for Recurring Payment with Trial Period in the Sandbox?

I am trying to set up recurring payments using the classic API. In the sandbox I'm trying to understand, given the setup I have here, why I get a return result showing that the next payment due date is in 1 month, when as far as I can tell I'm configuring this for a 3 month trial period. Here's the code I'm working with:
========================================================
Private Function CreateRecurringPaymentsProfileRequestType(token As String,
subscriptionName As String,
monthlyAmount As String,
startDate As DateTime) As CreateRecurringPaymentsProfileRequestType
Dim reqType As New CreateRecurringPaymentsProfileRequestType()
Dim reqDetails As New CreateRecurringPaymentsProfileRequestDetailsType()
reqType.CreateRecurringPaymentsProfileRequestDetails = reqDetails
reqDetails.Token = token
Dim profDetails As New RecurringPaymentsProfileDetailsType()
reqDetails.RecurringPaymentsProfileDetails = profDetails
profDetails.BillingStartDate = startDate.ToString("s")
Dim schedDetails As New ScheduleDetailsType()
reqDetails.ScheduleDetails = schedDetails
schedDetails.Description = subscriptionName
schedDetails.AutoBillOutstandingAmount = AutoBillType.NOAUTOBILL
Dim activationDetails As New ActivationDetailsType()
schedDetails.ActivationDetails = activationDetails
Dim payPeriod As New BillingPeriodDetailsType()
schedDetails.PaymentPeriod = payPeriod
schedDetails.AutoBillOutstandingAmount = AutoBillType.ADDTONEXTBILLING
schedDetails.MaxFailedPayments = 3
'== schedDetails.TrialPeriod -> trial period setup
Dim TrialPeriodPayment As New BasicAmountType(CurrencyCodeType.USD, "0.00")
Dim trialPeriod As New BillingPeriodDetailsType()
trialPeriod.Amount = TrialPeriodPayment
trialPeriod.BillingPeriod = BillingPeriodType.MONTH
trialPeriod.BillingFrequency = 1
trialPeriod.TotalBillingCycles = 3
schedDetails.TrialPeriod = trialPeriod
Dim basicPayment As New BasicAmountType(CurrencyCodeType.USD, monthlyAmount)
payPeriod.Amount = basicPayment
payPeriod.BillingPeriod = BillingPeriodType.MONTH
payPeriod.BillingFrequency = 1
Return reqType
End Function
On the return page I am doing this to gather the information from PayPal to show to the end user. Since I am setting the Trial Period for 3 Months I expect the next billing date to show up as Today's Date + 3 Months. Instead it is showing me Today's Date + 1 Month (Note: for the sake of brevity I am deleting irrelevant code from this routine):
Public Sub GetDetailsAndCreateRecurringPayment(token As String)
'== CHECK ON PAYMENT INFO RETURNED BY USER FROM PAYPAL REDIRECT
Dim detailsResponse As GetExpressCheckoutDetailsResponseType
Dim details As GetExpressCheckoutDetailsResponseDetailsType
Dim recurResponse As CreateRecurringPaymentsProfileResponseType
Dim recurDetails As CreateRecurringPaymentsProfileResponseDetailsType
Dim profResponse As GetRecurringPaymentsProfileDetailsResponseType
Dim profDetails As GetRecurringPaymentsProfileDetailsResponseDetailsType
...
Dim NextBillingDate() As String
...
'== GET DATA FROM PAYPAL
detailsResponse = payPalUtil.GetExpressCheckoutDetails(token)
details = detailsResponse.GetExpressCheckoutDetailsResponseDetails()
recurResponse = payPalUtil.CreateRecurringPaymentsProfile(token, MySession.ElthosPaymentType, MySession.ElthosPaymentAmount, DateTime.Now)
recurDetails = recurResponse.CreateRecurringPaymentsProfileResponseDetails
profResponse = payPalUtil.GetRecurringPaymentsProfile(recurDetails.ProfileID)
profDetails = profResponse.GetRecurringPaymentsProfileDetailsResponseDetails
'== CHECK FOR ERRORS - IF ANY THEN PRINT TO SCREEN AND EXIT SUB
Dim errorsText As String = ""
If (detailsResponse.Errors.Count > 0) Then
For Each errorObj As ErrorType In detailsResponse.Errors
errorsText = errorsText & errorObj.ShortMessage
Next
Lab_detailErrors.Text = errorsText & ". "
Exit Sub
End If
...
NextBillingDate = profDetails.RecurringPaymentsSummary.NextBillingDate.ToString.Split("T")
...
End Sub
Am I doing something wrong, or do I not understand how the Sandbox is supposed to work in regards to next billing date? Any help with this is much appreciated! Thanks!
Any advice about how to test this efficiently in the Sandbox would also be much appreciated as well. Thanks again!

Trying to insert QBO invoice with IPP.NET

I am attempting to insert an invoice into Quickbooks Online using IPP.NET. The problem seems to be in setting the item.
Here is a snippet of my VB code for the first line, which works fine...
Dim qboInvoiceLine1 as new intuit.ipp.data.qbo.invoiceline
qboInvoiceline1.desc="Desc1"
qboInvoiceLine1.amount=10
qboInvoiceLine1.AmountSpecified=True
If I add the following code for setting the item, I get an error forming the XML...
Dim items1 as List(Of Intuit.Ipp.Data.Qbo.Item)=New List(Of Intuit.Ipp.Data.Qbo.Item)
Dim item1 as new intuit.ipp.data.qbo.item
item1.id=new intuit.ipp.data.qbo.idtype
item1.id.value="1"
items1.add(item1)
qboInvoiceLine1.Items=items1.ToArray
I do not even understand why the item ID seems to be some kind of array or list of items. One source of documentation suggests there is an itemID property of the invoice line, but this does not seem to be the case. Can anyone give me code for setting the itemID for an invoice line?
ItemsChoiceType2[] invoiceItemAttributes = { ItemsChoiceType2.ItemId, ItemsChoiceType2.UnitPrice,ItemsChoiceType2.Qty };
object[] invoiceItemValues = { new IdType() { idDomain = idDomainEnum.QB, Value = "5" }, new decimal(33), new decimal(2) };
var invoiceLine = new InvoiceLine();
invoiceLine.Amount = 66;
invoiceLine.AmountSpecified = true;
invoiceLine.Desc = "test " + DateTime.Now.ToShortDateString();
invoiceLine.ItemsElementName = invoiceItemAttributes;
invoiceLine.Items = invoiceItemValues;
invoiceLine.ServiceDate = DateTime.Now;
invoiceLine.ServiceDateSpecified = true;
listLine.Add(invoiceLine);

Parameter to Crystal Report

i created a #Month as parameter name in crystal report and just insert to the report header section.
When i run the report always it asks the parameter by showing one box. How i pass through code. My existing code is below
MyReport rpt = new MyReport();
var srcData = ; //here i added my LINQ statement to select the data
rpt.SetDataSource(srcData);
ParameterDiscreteValue pdValue = new ParameterDiscreteValue();
pdValue.Value = combo2.SelectedValue;
rpt.ParameterFields["#Month"].CurrentValues.Add(pdValue);
this.ReportViewer1.ReportSource = rpt;
this.ReportViewer1.RefreshReport();
Where i did the mistake?
Hi I solved by just removing RefershReport() method of crystalreportviewer
I find from : http://www.it-sideways.com/2011/10/how-to-disable-parameter-prompt-for.html
If it's not working it suggests a typo or something. Try analyzing rpt.ParameterFields (set a breakpoint and watch). Have you got the parameter name correct? Data type?
I had trouble with adding parameters as well. Here's an example of what I got working:
string ponumber = Request.QueryString["ponumber"].ToString();
string receiptno = Request.QueryString["receiptno"].ToString();
// Put Away Report
CrystalReportSource CrystalReportSource1 = new CrystalReportSource();
CrystalReportViewer CrystalReportViewer1 = new CrystalReportViewer();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.EnableParameterPrompt = false;
CrystalReportSource1.Report.FileName = "Report3.rpt";
CrystalReportSource1.EnableCaching = false;
// This will set the values of my two parameters in the report
CrystalReportSource1.ReportDocument.SetParameterValue(0, ponumber);
CrystalReportSource1.ReportDocument.SetParameterValue(1, receiptno);
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo.ServerName = ConfigurationManager.AppSettings["WarehouseReportServerName"];
logOnInfo.ConnectionInfo.DatabaseName = ConfigurationManager.AppSettings["WarehouseReportDatabaseName"];
logOnInfo.ConnectionInfo.UserID = ConfigurationManager.AppSettings["WarehouseReportUserID"];
logOnInfo.ConnectionInfo.Password = ConfigurationManager.AppSettings["WarehouseReportPassword"];
TableLogOnInfos infos = new TableLogOnInfos();
infos.Add(logOnInfo);
CrystalReportViewer1.LogOnInfo = infos;
maindiv.Controls.Add(CrystalReportSource1);
maindiv.Controls.Add(CrystalReportViewer1);
CrystalReportViewer1.DataBind();