2015-12-17 04:56:49 +01:00
package paypalsdk
import "fmt"
// GetSale returns a sale by ID
2015-12-29 10:21:11 +01:00
// Use this call to get details about a sale transaction.
// Note: This call returns only the sales that were created via the REST API.
// Endpoint: GET /v1/payments/sale/ID
2015-12-17 04:56:49 +01:00
func ( c * Client ) GetSale ( saleID string ) ( * Sale , error ) {
sale := & Sale { }
req , err := c . NewRequest ( "GET" , fmt . Sprintf ( "%s%s" , c . APIBase , "/v1/payments/sale/" + saleID ) , nil )
if err != nil {
return sale , err
}
2017-11-23 03:15:11 +01:00
if err = c . SendWithAuth ( req , sale ) ; err != nil {
2015-12-17 04:56:49 +01:00
return sale , err
}
return sale , nil
}
// RefundSale refunds a completed payment.
2015-12-29 10:21:11 +01:00
// Use this call to refund a completed payment. Provide the sale_id in the URI and an empty JSON payload for a full refund. For partial refunds, you can include an amount.
// Endpoint: POST /v1/payments/sale/ID/refund
2015-12-17 04:56:49 +01:00
func ( c * Client ) RefundSale ( saleID string , a * Amount ) ( * Refund , error ) {
type refundRequest struct {
Amount * Amount ` json:"amount" `
}
refund := & Refund { }
req , err := c . NewRequest ( "POST" , fmt . Sprintf ( "%s%s" , c . APIBase , "/v1/payments/sale/" + saleID + "/refund" ) , & refundRequest { Amount : a } )
if err != nil {
return refund , err
}
2017-11-23 03:15:11 +01:00
if err = c . SendWithAuth ( req , refund ) ; err != nil {
2015-12-17 04:56:49 +01:00
return refund , err
}
return refund , nil
}
2015-12-17 05:28:26 +01:00
// GetRefund by ID
2015-12-29 10:21:11 +01:00
// Use it to look up details of a specific refund on direct and captured payments.
// Endpoint: GET /v1/payments/refund/ID
2015-12-17 05:28:26 +01:00
func ( c * Client ) GetRefund ( refundID string ) ( * Refund , error ) {
refund := & Refund { }
req , err := c . NewRequest ( "GET" , fmt . Sprintf ( "%s%s" , c . APIBase , "/v1/payments/refund/" + refundID ) , nil )
if err != nil {
return refund , err
}
2017-11-23 03:15:11 +01:00
if err = c . SendWithAuth ( req , refund ) ; err != nil {
2015-12-17 05:28:26 +01:00
return refund , err
}
return refund , nil
}