I am new to VB.net while using braintree, it is working fine, now I need to pass shipping details with the payment request. How can I do it
If Request.Form("payment_method_nonce") <> "" Then
Dim strStatus As String = ""
Dim gateway As New Braintree.BraintreeGateway
With gateway
.Environment = Braintree.Environment.SANDBOX
.PublicKey = "*********"
.PrivateKey = "*************"
.MerchantId = "*************"
End With
Dim transactionRequest As New Braintree.TransactionRequest
With transactionRequest
.Amount = 100
.PaymentMethodNonce = Request.Form("payment_method_nonce")
End With
Dim result As Braintree.Result(Of Braintree.Transaction) = gateway.Transaction.Sale(transactionRequest)
If result.Errors Is Nothing Then
If result.Target.Status.ToString = Braintree.TransactionStatus.AUTHORIZED.ToString Then
strStatus = "Payment is " & result.Target.Status.ToString
Dim result1 As Braintree.Result(Of Braintree.Transaction) = gateway.Transaction.SubmitForSettlement(result.Target.Id)
strStatus = strStatus & " And Now its " & result1.Target.Status.ToString
Label1.Text = "Paid"
Else
strStatus = result.Target.Status.ToString
End If
Else
strStatus = result.Message.ToString
Label1.Text = "Not Paid"
End If
status.Text = strStatus
End If
Full disclosure: I'm a developer at Braintree.
You can add the shipping address as part of the transaction by specifying ShippingAddress in your
TransactionRequest
object.ShippingAddress
would be created as anAddressRequest
object. You can see a full .NET example which includes creating a shipping address on our developers site.As for how to do this with VB.net, based on your code snippet, you should be able to do something like this:
Then modify your
transactionRequest
to be like this:If you need any other assistance related to this, I recommend reaching out to Braintree support.