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
The HTTP response code 500 means "Internal Server Error":
The server encountered an unexpected condition which prevented it from fulfilling the request.
That means your client successfully sent the HTTP request but the server failed to generate an expected response because some problem happened on the server itself and it is the responsibility of the owner of that system to fix it. The root cause could be any number of things (programming error, database problem, networking issue, can of soda spilled on server motherboard, etc.); however, the debugging information exists on the server infrastructure and is generally not (should not!) be available to clients since it may contain sensitive information.
It is possible that there was some problem in the request that your client issued and, in that case, the server should respond with some sort of 4xx "Client Error" response. However, we cannot know if that was the case because the server failed to generate a meaningful response.
Your only recourse is to contact the owner of that system, notify them of the error on their server, and hope that they resolve it so you can continue your work.