I am using logpacker package in golang app to make credit card transaction using paypal, but it returns me POST https://api.sandbox.paypal.com/v1/payments/payment: 500
error
My main.go file having this code::
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)
}
After this I am running main.go file and it generates following error
error: POST https://api.sandbox.paypal.com/v1/payments/payment: 500
This is a logpacker package github link: https://github.com/logpacker/PayPal-Go-SDK