Golang支付网关SDK推荐:除Stripe外有哪些按地区收款的解决方案?

Golang支付网关SDK推荐:除Stripe外有哪些按地区收款的解决方案? 我正在开发一个产品,需要集成支付网关。这本质上是一个预订系统,商户需要基于地理位置收取付款。就像 Stripe 提供的功能那样,我们可以按城市范围收取款项。

我已经集成了 Stripe,现在想再集成一个支付网关。我正在寻找能够提供基于地理位置支付功能的新支付网关,这样可以方便地管理我的客户等等。最重要的是,该网关需要提供 Go SDK,因为这将为我节省大量时间。

我已经检查过以下支付网关:

  1. PayPal(不提供基于地理位置的支付功能)
  2. Square(没有提供 Go SDK)

除了这些网关之外,有没有人能根据我的需求推荐合适的支付网关?

提前感谢您的帮助!


更多关于Golang支付网关SDK推荐:除Stripe外有哪些按地区收款的解决方案?的实战教程也可以访问 https://www.itying.com/category-94-b0.html

1 回复

更多关于Golang支付网关SDK推荐:除Stripe外有哪些按地区收款的解决方案?的实战系列教程也可以访问 https://www.itying.com/category-94-b0.html


对于需要基于地理位置收款的支付网关集成,以下是几个推荐的选择,它们都提供Go SDK并支持区域化支付配置:

1. Adyen

Adyen提供强大的地理位置支付功能和完整的Go SDK支持。

package main

import (
    "context"
    "fmt"
    "github.com/adyen/adyen-go-api-library/v7/src/adyen"
    "github.com/adyen/adyen-go-api-library/v7/src/checkout"
)

func createAdyenPayment(amount int, currency string, countryCode string) {
    client := adyen.NewClient(&adyen.Config{
        ApiKey:      "your_api_key",
        Environment: adyen.TestEnv,
    })
    
    req := client.Checkout().Payments(&checkout.PaymentRequest{
        Amount: checkout.Amount{
            Value:    int64(amount),
            Currency: currency,
        },
        Reference: "your_reference",
        MerchantAccount: "your_merchant_account",
        CountryCode:     countryCode, // 基于国家代码的地理位置配置
        PaymentMethod: map[string]interface{}{
            "type": "scheme",
            "number": "4111111111111111",
            "expiryMonth": "03",
            "expiryYear": "2030",
            "holderName": "John Smith",
            "cvc": "737",
        },
    })
    
    resp, httpResp, err := req.Execute(context.Background())
    if err != nil {
        fmt.Printf("Payment failed: %v\n", err)
        return
    }
    
    fmt.Printf("Payment result: %+v\n", resp.ResultCode)
    fmt.Printf("HTTP status: %d\n", httpResp.StatusCode)
}

2. Braintree (PayPal旗下)

Braintree提供地理位置支付规则和Go SDK。

package main

import (
    "context"
    "fmt"
    "github.com/braintree-go/braintree-go"
)

func processBraintreePayment(amount string, merchantAccountID string) {
    bt := braintree.New(
        braintree.Sandbox,
        "your_merchant_id",
        "your_public_key",
        "your_private_key",
    )
    
    tx, err := bt.Transaction().Create(context.Background(), &braintree.TransactionRequest{
        Type:               "sale",
        Amount:             braintree.NewDecimal(100, 2), // $100.00
        MerchantAccountId:   merchantAccountID, // 基于商户账户的地理位置配置
        PaymentMethodNonce: "fake-valid-nonce",
        Options: &braintree.TransactionOptions{
            SubmitForSettlement: true,
        },
    })
    
    if err != nil {
        fmt.Printf("Transaction failed: %v\n", err)
        return
    }
    
    fmt.Printf("Transaction status: %s\n", tx.Status)
    fmt.Printf("Transaction ID: %s\n", tx.Id)
}

3. Worldpay

Worldpay提供区域化支付处理和Go SDK。

package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

type WorldpayPayment struct {
    TransactionReference string `json:"transactionReference"`
    Amount              struct {
        Value    int    `json:"value"`
        Currency string `json:"currency"`
    } `json:"amount"`
    PaymentMethod struct {
        Type string `json:"type"`
    } `json:"paymentMethod"`
    ShopperCountryCode string `json:"shopperCountryCode"` // 基于购物者国家的地理位置
}

func processWorldpayPayment(amount int, currency, countryCode string) {
    payment := WorldpayPayment{
        Amount: struct {
            Value    int    `json:"value"`
            Currency string `json:"currency"`
        }{
            Value:    amount,
            Currency: currency,
        },
        ShopperCountryCode: countryCode,
        PaymentMethod: struct {
            Type string `json:"type"`
        }{
            Type: "Card",
        },
    }
    
    // 使用Worldpay Go SDK或直接HTTP调用
    jsonData, _ := json.Marshal(payment)
    fmt.Printf("Worldpay payment payload: %s\n", string(jsonData))
}

4. 支付宝国际版 (Alipay Global)

如果业务涉及亚洲市场,支付宝国际版提供地理位置支付和Go SDK。

package main

import (
    "fmt"
    "github.com/smartwalle/alipay/v3"
)

func createAlipayPayment(amount string, currency, region string) {
    client, err := alipay.New("your_app_id", "your_private_key", false)
    if err != nil {
        fmt.Printf("Alipay client init failed: %v\n", err)
        return
    }
    
    // 加载支付宝公钥
    client.LoadAliPayPublicKey("your_alipay_public_key")
    
    var p = alipay.TradePagePay{}
    p.NotifyURL = "https://your-domain.com/notify"
    p.ReturnURL = "https://your-domain.com/return"
    p.Subject = "Your Product"
    p.OutTradeNo = "your_order_number"
    p.TotalAmount = amount
    p.ProductCode = "FAST_INSTANT_TRADE_PAY"
    
    // 基于region参数配置地理位置支付规则
    url, err := client.TradePagePay(p)
    if err != nil {
        fmt.Printf("Alipay payment failed: %v\n", err)
        return
    }
    
    fmt.Printf("Alipay payment URL: %s\n", url.String())
}

集成建议

这些支付网关都支持:

  • 基于国家/地区的支付规则配置
  • Go语言SDK支持
  • 区域化支付处理
  • 商户账户管理

选择时考虑因素:

  • 目标市场覆盖范围
  • 手续费结构
  • API限制和性能要求
  • 合规性要求(PCI DSS等)

Adyen和Braintree在全球化支持方面较为突出,而Worldpay在欧洲市场有较强优势,支付宝则专注于亚洲市场。

回到顶部