【问题标题】:Braintree passing shipping address with RequestBraintree 通过请求传递送货地址
【发布时间】:2016-02-07 19:19:24
【问题描述】:

我在使用 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

【问题讨论】:

    标签: vb.net braintree braintree-data


    【解决方案1】:

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

    您可以通过在 TransactionRequest 对象中指定 ShippingAddress 来添加送货地址作为交易的一部分。 ShippingAddress 将被创建为 AddressRequest 对象。您可以查看完整的 .NET 示例,其中包括创建送货地址 on our developers site

    至于如何用VB.net做到这一点,根据你的代码sn-p,你应该可以做这样的事情:

    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

    【讨论】:

      猜你喜欢
      • 2017-06-07
      • 1970-01-01
      • 1970-01-01
      • 2013-08-03
      • 2012-01-29
      • 1970-01-01
      • 2014-12-06
      • 1970-01-01
      • 2013-01-07
      相关资源
      最近更新 更多