Пример #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Returnmac != null)
         {
             hashCode = hashCode * 59 + Returnmac.GetHashCode();
         }
         if (HostedCheckoutId != null)
         {
             hashCode = hashCode * 59 + HostedCheckoutId.GetHashCode();
         }
         if (InvalidTokens != null)
         {
             hashCode = hashCode * 59 + InvalidTokens.GetHashCode();
         }
         if (MerchantReference != null)
         {
             hashCode = hashCode * 59 + MerchantReference.GetHashCode();
         }
         if (PartialRedirectUrl != null)
         {
             hashCode = hashCode * 59 + PartialRedirectUrl.GetHashCode();
         }
         return(hashCode);
     }
 }
 /// <summary>
 /// Validates the properties for this instance are valid before sending the request to the API.
 /// </summary>
 /// <remarks>
 /// Provides simple client side validation, such as required fields beign provided and fields under maximum lengths etc.
 /// </remarks>
 public override void Validate()
 {
     Amount.GuardZeroOrNegative(nameof(Amount));
     MerchantReference.GuardNullOrWhiteSpace(nameof(MerchantReference));
     Origin.GuardNullOrWhiteSpace(nameof(Origin));
     OriginData.GuardNull(nameof(OriginData));
     Customer.GuardNull(nameof(Customer));
     Customer?.Phone.GuardNullOrWhiteSpace(nameof(Customer.Phone));
 }
Пример #3
0
        public void Acknowledge(string orderId, MerchantReference merchantReference)
        {
            if (orderId == null)
            {
                throw new ArgumentNullException("orderId");
            }
            if (merchantReference == null)
            {
                throw new ArgumentNullException("merchantReference");
            }

            var order = FetchOrder(orderId);

            order.Confirm(merchantReference);
        }
Пример #4
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (MerchantReference != null)
         {
             hashCode = hashCode * 59 + MerchantReference.GetHashCode();
         }
         if (ReferenceOrigPayment != null)
         {
             hashCode = hashCode * 59 + ReferenceOrigPayment.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Updates the Merchant Reference for a previously created payment by id.
        /// </summary>
        /// <exception cref="MerchantApi.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">Id, required.</param>
        /// <param name="body">MerchantReference Body, required.</param>
        /// <returns>IRestResponse</returns>
        public IRestResponse PaymentUpdateMerchantReference(string id, MerchantReference body = null)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling PaymentApi->PaymentUpdateMerchantReference");
            }
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling PaymentApi->PaymentUpdateMerchantReference");
            }

            var localVarResponse = PaymentUpdateMerchantReferenceWithHttpInfo(id, body);

            return(localVarResponse);
        }
Пример #6
0
        public void PaymentUpdateMerchantReference()
        {
            string paymentToken = null;

            var authorization = authorizationApi.AuthorizationCreateToken();

            paymentToken = "001.u0hglki77ko70iuavgnb31vo2qq4ehold53brkdngfj9l73f";

            var response = instance.PaymentGetByToken(paymentToken);

            var reference = new MerchantReference("new_merchan_order_id_1234");

            instance.PaymentUpdateMerchantReference(response.Id, reference);

            response = instance.PaymentGetByToken(paymentToken);

            Assert.IsInstanceOf <Payment>(response, "response is Payment");
        }
Пример #7
0
        internal static Dictionary <string, object> ToDictionary(this MerchantReference merchantReference)
        {
            var result = new Dictionary <string, object>();

            if (string.IsNullOrEmpty(merchantReference.OrderId1))
            {
                return(result);
            }
            result.Add("orderid1", merchantReference.OrderId1);

            if (string.IsNullOrEmpty(merchantReference.OrderId2))
            {
                return(result);
            }
            result.Add("orderid2", merchantReference.OrderId2);

            return(result);
        }
Пример #8
0
        internal static void Confirm(this Order order, MerchantReference merchantReference)
        {
            if ((string)order.GetValue("status") != "checkout_complete")
            {
                return;
            }

            var data = new Dictionary <string, object>
            {
                { "status", "created" }
            };

            if (!merchantReference.IsEmpty)
            {
                data.Add("merchant_reference", merchantReference.ToDictionary());
            }

            order.Update(data);
        }
Пример #9
0
        public ConfirmResponse Confirm(string orderId, MerchantReference merchantReference)
        {
            if (orderId == null)
            {
                throw new ArgumentNullException("orderId");
            }
            if (merchantReference == null)
            {
                throw new ArgumentNullException("merchantReference");
            }

            var order           = FetchOrder(orderId);
            var snippet         = order.GetSnippet();
            var billingAddress  = order.GetBillingAddress();
            var shippingAddress = order.GetShippingAddress();

            order.Confirm(merchantReference);

            return(new ConfirmResponse(orderId, snippet, billingAddress, shippingAddress, order.GetStringField("status"), order.GetStringField("reservation"), order.GetTotalCost()));
        }
Пример #10
0
        /// <summary>
        /// Returns true if CreateHostedCheckoutResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of CreateHostedCheckoutResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CreateHostedCheckoutResponse other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Returnmac == other.Returnmac ||
                     Returnmac != null &&
                     Returnmac.Equals(other.Returnmac)
                     ) &&
                 (
                     HostedCheckoutId == other.HostedCheckoutId ||
                     HostedCheckoutId != null &&
                     HostedCheckoutId.Equals(other.HostedCheckoutId)
                 ) &&
                 (
                     InvalidTokens == other.InvalidTokens ||
                     InvalidTokens != null &&
                     InvalidTokens.SequenceEqual(other.InvalidTokens)
                 ) &&
                 (
                     MerchantReference == other.MerchantReference ||
                     MerchantReference != null &&
                     MerchantReference.Equals(other.MerchantReference)
                 ) &&
                 (
                     PartialRedirectUrl == other.PartialRedirectUrl ||
                     PartialRedirectUrl != null &&
                     PartialRedirectUrl.Equals(other.PartialRedirectUrl)
                 ));
        }
Пример #11
0
        public bool UpdateOrderId(string orderId, string commerceOrderId)
        {
            if (orderId == null)
            {
                throw new ArgumentNullException("orderId");
            }
            if (commerceOrderId == null)
            {
                throw new ArgumentNullException("commerceOrderId");
            }

            var order = FetchOrder(orderId);

            var merchant = new MerchantReference(commerceOrderId, string.Empty);

            var data = new Dictionary <string, object>
            {
                { "merchant_reference", merchant.ToDictionary() }
            };

            order.Update(data);
            return(true);
        }
Пример #12
0
        /// <summary>
        /// Returns true if PaymentReferences instances are equal
        /// </summary>
        /// <param name="other">Instance of PaymentReferences to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PaymentReferences other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     MerchantReference == other.MerchantReference ||
                     MerchantReference != null &&
                     MerchantReference.Equals(other.MerchantReference)
                     ) &&
                 (
                     ReferenceOrigPayment == other.ReferenceOrigPayment ||
                     ReferenceOrigPayment != null &&
                     ReferenceOrigPayment.Equals(other.ReferenceOrigPayment)
                 ));
        }
        /// <summary>
        /// Updates the Merchant Reference for a previously created payment by id.
        /// </summary>
        /// <exception cref="MerchantApi.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">Id, required.</param>
        /// <param name="body">MerchantReference Body, required.</param>
        /// <returns>IRestResponse</returns>
        public IRestResponse PaymentUpdateMerchantReferenceWithHttpInfo(string id, MerchantReference body = null)
        {
            var    localVarPath         = GetBasePath() + "payments/" + id;
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }

            // authentication (Authorization) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Authorization")))
            {
                localVarHeaderParams["Authorization"] = Configuration.GetApiKeyWithPrefix("Authorization");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("PaymentUpdateMerchantReferenceWithHttpInfo", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(localVarResponse);
        }
 public PaymentRequest(Card card, MerchantId merchantId, Money amountToCharge, MerchantReference merchantReference = default)
 {
     Card              = card;
     MerchantId        = merchantId;
     AmountToCharge    = amountToCharge;
     MerchantReference = merchantReference == default(MerchantReference) ? Option <MerchantReference> .None : Optional(merchantReference);
 }