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
|
package paypalsdk
|
||||||
|
|
||||||
import ()
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
// CreateDirectCreditCardPayment sends request with payment
|
// CreateDirectPaypalPayment sends request with payment
|
||||||
func CreateDirectCreditCardPayment(cc CreditCard, amount Amount) error {
|
func (c *Client) CreateDirectPaypalPayment(payment PaypalPaymentRequest) (*PaymentResponse, error) {
|
||||||
return nil
|
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"`
|
Issue string `json:"issue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreditCard - All info about customer's CC
|
// PaypalPaymentRequest - All info about paypal type payment
|
||||||
CreditCard struct {
|
PaypalPaymentRequest struct {
|
||||||
Type string
|
Transactions []Transaction
|
||||||
Number string
|
}
|
||||||
ExpireYear int
|
|
||||||
ExpireMonth int
|
// PaymentResponse structure
|
||||||
FirstName string
|
PaymentResponse struct {
|
||||||
LastName string
|
}
|
||||||
|
|
||||||
|
// Transaction element
|
||||||
|
Transaction struct {
|
||||||
|
Amount Amount
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amount to pay
|
// Amount to pay
|
||||||
Amount struct {
|
Amount struct {
|
||||||
Currency string
|
Currency string
|
||||||
Amount float32
|
Total float32
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user