This commit is contained in:
Aliaksandr Pliutau 2015-11-02 10:34:16 +07:00
parent 3a2323e1ef
commit ab760e8561
2 changed files with 34 additions and 13 deletions

View File

@ -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
}

View File

@ -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
}
)