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

View File

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