forked from go-packages/paypal
types
This commit is contained in:
parent
3a2323e1ef
commit
ab760e8561
25
payment.go
25
payment.go
|
@ -1,8 +1,25 @@
|
|||
package paypalsdk
|
||||
|
||||
import ()
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// CreateDirectCreditCardPayment sends request with payment
|
||||
func CreateDirectCreditCardPayment(cc CreditCard, amount Amount) error {
|
||||
return nil
|
||||
// CreateDirectPaypalPayment sends request with payment
|
||||
func (c *Client) CreateDirectPaypalPayment(payment PaypalPaymentRequest) (*PaymentResponse, error) {
|
||||
buf := bytes.NewBuffer([]byte(""))
|
||||
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/payment"), buf)
|
||||
if err != nil {
|
||||
return &PaymentResponse{}, err
|
||||
}
|
||||
|
||||
req.SetBasicAuth(c.ClientID, c.Secret)
|
||||
req.Header.Set("Authorization", "Bearer "+c.Token.Token)
|
||||
req.Header.Set("Content-type", "application/x-www-form-urlencoded")
|
||||
|
||||
p := PaymentResponse{}
|
||||
err = c.Send(req, &p)
|
||||
|
||||
return &p, nil
|
||||
}
|
||||
|
|
22
types.go
22
types.go
|
@ -47,20 +47,24 @@ type (
|
|||
Issue string `json:"issue"`
|
||||
}
|
||||
|
||||
// CreditCard - All info about customer's CC
|
||||
CreditCard struct {
|
||||
Type string
|
||||
Number string
|
||||
ExpireYear int
|
||||
ExpireMonth int
|
||||
FirstName string
|
||||
LastName string
|
||||
// PaypalPaymentRequest - All info about paypal type payment
|
||||
PaypalPaymentRequest struct {
|
||||
Transactions []Transaction
|
||||
}
|
||||
|
||||
// PaymentResponse structure
|
||||
PaymentResponse struct {
|
||||
}
|
||||
|
||||
// Transaction element
|
||||
Transaction struct {
|
||||
Amount Amount
|
||||
}
|
||||
|
||||
// Amount to pay
|
||||
Amount struct {
|
||||
Currency string
|
||||
Amount float32
|
||||
Total float32
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user