Пример #1
0
 /// <summary>
 /// Creates an authorization against the Gateway.
 /// See https://github.com/clearhaus/gateway-api-docs/blob/master/source/index.md#authentication
 /// </summary>
 /// <param name="amount">Amount of money to reserve, minor units of <c>currency</c> (Required)</param>
 /// <param name="currency">Currency in which <c>amount</c> is specified (Required)</param>
 /// <param name="mpoInfo">MobilePay Online payment information (Required)</param>
 /// <param name="pares">3D-Secure result (omittable)</param>
 /// <param name="opts">Optional parameters for authorizations or null (Omittable)</param>
 /// <exception cref="ClrhsNetException">Network error communicating with gateway</exception>
 /// <exception cref="ClrhsAuthException">Thrown if APIKey is invalid</exception>
 /// <exception cref="ClrhsGatewayException">Thrown if gateway responds with internal server error</exception>
 /// <exception cref="ClrhsException">Unexpected connection error</exception>
 /// <remarks>Signing must be enabled for this method to function</remarks>
 public Authorization Authorize(string amount, string currency, MobilePayOnlineInfo mpoInfo, string pares, AuthorizationRequestOptions opts)
 {
     using (var restRequest = buildAuthorizeRequest(amount, currency, mpoInfo, pares, opts))
     {
         return(POSTtoObject <Authorization>(restRequest));
     }
 }
Пример #2
0
        private RestRequest buildAuthorizeRequest(
            string amount,
            string currency,
            MobilePayOnlineInfo mpoInfo,
            string pares,
            AuthorizationRequestOptions opts)
        {
            var restRequest = buildRestRequest("authorizations/");

            restRequest.AddParameter("amount", amount);
            restRequest.AddParameter("currency", currency);
            restRequest.AddParameters(mpoInfo.GetArgs());

            if (!string.IsNullOrWhiteSpace(pares))
            {
                restRequest.AddParameter("mobilepayonline[pares]", pares);
            }

            if (opts != null)
            {
                restRequest.AddParameters(opts.GetArgs());
            }

            return(restRequest);
        }
Пример #3
0
 /// <summary>
 /// <see cref="Authorize(string, string, MobilePayOnlineInfo, string, AuthorizationRequestOptions)"/>
 /// </summary>
 /// <param name="amount">Amount of money to reserve, minor units of <c>currency</c> (Required)</param>
 /// <param name="currency">Currency in which <c>amount</c> is specified (Required)</param>
 /// <param name="mpoInfo">MobilePay Online payment information (Required)</param>
 /// <param name="pares">3D-Secure result (omittable)</param>
 /// <param name="opts">Optional parameters for authorizations or null (Omittable)</param>
 /// <exception cref="ClrhsNetException">Network error communicating with gateway</exception>
 /// <exception cref="ClrhsAuthException">Thrown if APIKey is invalid</exception>
 /// <exception cref="ClrhsGatewayException">Thrown if gateway responds with internal server error</exception>
 /// <exception cref="ClrhsException">Unexpected connection error</exception>
 /// <remarks>Signing must be enabled for this method to function</remarks>
 async public Task <Authorization> AuthorizeAsync(string amount, string currency, MobilePayOnlineInfo mpoInfo, string pares, AuthorizationRequestOptions opts)
 {
     using (var restRequest = buildAuthorizeRequest(amount, currency, mpoInfo, pares, opts))
     {
         return(await POSTtoObjectAsync <Authorization>(restRequest));
     }
 }