doujuanju3076 2018-10-03 14:56 采纳率: 0%
浏览 60
已采纳

如何使用logpacker软件包paypal进行信用卡付款?

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

  • 写回答

1条回答 默认 最新

  • douhensheng1131 2018-10-03 20:51
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器