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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看