2015-11-06 48 views
-2

我是新來VB.net使用braintree時,它工作正常,現在我需要傳遞付款請求的送貨細節。我該怎麼辦呢Braintree傳遞送貨地址與請求

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 

回答

2

全面披露:我在布倫特裏開發商。

您可以在TransactionRequest對象中指定ShippingAddress作爲交易的一部分添加送貨地址。 ShippingAddress將被創建爲AddressRequest對象。您可以看到一個完整的.NET示例,其中包括創建送貨地址on our developers site

至於如何做到這一點與VB.net,根據您的代碼段,你應該能夠做這樣的事情:

Dim shippingAddressRequest As New Braintree.AddressRequest  
With shippingAddressRequest 
    .FirstName = "John" 
    .LastName = "Smith" 
    .StreetAddress = "123 Example St." 
    .Locality = "Chicago" 
    .Region = "IL" 
    .PostalCode = "60601" 
    .CountryCodeAlpha2 = "US" 
End With 

然後修改transactionRequest是這樣的:

Dim transactionRequest As New Braintree.TransactionRequest 
With transactionRequest 
    .Amount = 100 
    .PaymentMethodNonce = Request.Form("payment_method_nonce") 
    .ShippingAddress = shippingAddressRequest 
End With 

如果您需要與此相關的任何其他幫助,我建議您聯繫Braintree support