예제 #1
0
func VoidAuthorization(auth *auth.PayPalAuth, id string) (response *VoidResponse, err error) {
	url := fmt.Sprintf("%s%s%s/void", auth.Endpoint, "/v1/payments/authorization/", id)
	api_response, statusCode, err := common.DoRequest(auth, "POST", url, nil)
	if err == nil {
		if statusCode == 200 {
			err = json.Unmarshal(api_response, &response)
		} else {
			err = fmt.Errorf("Api call status code: %d, %s", statusCode, string(api_response))
		}
	}
	return
}
예제 #2
0
func CaptureAuthorization(auth *auth.PayPalAuth, id string, currency string, total float64, is_final_capture bool) (response *CaptureResponse, err error) {
	amount := CaptureAmount{Currency: currency, Total: fmt.Sprintf("%0.2f", total)}
	captureDetails := &CaptureDetails{Amount: amount, IsFinalCapture: is_final_capture}
	url := fmt.Sprintf("%s%s%s/capture", auth.Endpoint, "/v1/payments/authorization/", id)
	if err == nil {
		api_response, statusCode, err := common.DoRequest(auth, "POST", url, captureDetails)
		if err == nil {
			if statusCode == 200 {
				err = json.Unmarshal(api_response, &response)
			} else {
				err = fmt.Errorf("API call status code %d, %s", statusCode, string(api_response))
			}
		}
	}
	return
}