-1

我在使用 Braintree 时是 VB.net 的新手,它工作正常,现在我需要在付款请求中传递运输详细信息。我该怎么做

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
4

1 回答 1

2

全面披露:我是 Braintree 的开发人员。

您可以通过在对象中指定ShippingAddress将送货地址添加为交易的一部分。将被创建为一个对象。您可以看到一个完整的 .NET 示例,其中包括在我们的开发人员网站上创建一个送货地址。TransactionRequestShippingAddressAddressRequest

至于如何使用 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 支持

于 2015-11-09T19:44:34.127 回答