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 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,
  • ¥15 spaceclaim模型变灰色