Beispiel #1
0
        /// <summary>
        /// Create a new billing agreement by passing the details for the agreement, including the name, description, start date, payer, and billing plan in the request JSON.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="agreement">The Agreement object to be used when creating the PayPal resource.</param>
        /// <returns>Agreement</returns>
        public static Agreement Create(APIContext apiContext, Agreement agreement)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            // Configure and send the request
            var resourcePath = "v1/payments/billing-agreements";
            var resource     = PayPalResource.ConfigureAndExecute <Agreement>(apiContext, HttpMethod.POST, resourcePath, agreement.ConvertToJson());

            resource.token = SDKUtil.GetTokenFromApprovalUrl(resource.links);
            return(resource);
        }