我在 golang 应用程序中使用 logpacker 包来使用 paypal 进行信用卡交易,但它返回POST https://api.sandbox.paypal.com/v1/payments/payment: 500错误我的 main.go 文件具有此代码::
package main
import (
paypalsdk "github.com/logpacker/PayPal-Go-SDK"
"fmt"
)
var ClientID = "my-client-id"
var SecretID = "my-secret-key"
func main() {
// Initialize client
c, err := paypalsdk.NewClient(ClientID, SecretID, paypalsdk.APIBaseSandBox)
if err != nil {
panic(err)
}
// Retrieve access token
_, err = c.GetAccessToken()
if err != nil {
panic(err)
}
// Create credit card payment
p := paypalsdk.Payment{
Intent: "sale",
Payer: &paypalsdk.Payer{
PaymentMethod: "credit_card",
FundingInstruments: []paypalsdk.FundingInstrument{{
CreditCard: &paypalsdk.CreditCard{
Number: "43118885805455",
Type: "visa",
ExpireMonth: "11",
ExpireYear: "2023",
CVV2: "123",
FirstName: "abc",
LastName: "abc",
},
}},
},
Transactions: []paypalsdk.Transaction{{
Amount: &paypalsdk.Amount{
Currency: "USD",
Total: "7.00",
},
Description: "My Payment",
}},
RedirectURLs: &paypalsdk.RedirectURLs{
ReturnURL: "http://...",
CancelURL: "http://...",
},
}
_, err = c.CreatePayment(p)
if err != nil {
fmt.Println(err)
}
//fmt.Println(data)
}
在此之后我运行 main.go 文件并生成以下错误错误:POST https://api.sandbox.paypal.com/v1/payments/payment: 500
这是一个logpacker包github链接:https ://github.com/logpacker/PayPal-Go-SDK
慕尼黑5688855
相关分类