Exemple #1
0
        public async Task <(bool, long)> VerifyPayment(int cost, string authority)
        {
            var payment = new Payment(cost);
            PaymentVerificationResponse res = await payment.Verification(authority);

            return(res.Status == 100, res.RefId);
        }
Exemple #2
0
        public int PaymentVerification(string MerchantID, string Authority, int Amount, out long RefID)
        {
            PaymentVerificationRequest inValue = new PaymentVerificationRequest();

            inValue.Body            = new PaymentVerificationRequestBody();
            inValue.Body.MerchantID = MerchantID;
            inValue.Body.Authority  = Authority;
            inValue.Body.Amount     = Amount;
            PaymentVerificationResponse retVal = ((PaymentGatewayImplementationServicePortType)(this)).PaymentVerification(inValue);

            RefID = retVal.Body.RefID;
            return(retVal.Body.Status);
        }
        private async Task <bool> SetResult(PaymentResponseConfig responseConfig, PaymentVerificationResponse response)
        {
            var isSuccess = false;
            var authority = responseConfig.Authority;

            if (IsSuccess(response.Body.Status))
            {
                await SetSuccessAsync(authority, response);

                isSuccess = true;
            }
            else
            {
                await SetFailAsync(authority);
            }

            return(isSuccess);
        }
Exemple #4
0
        //public async Task<PaymentRequestResponse> UnverifiedTransactions()
        //{
        //    //var k = await Client.Create().(this._merchantId, this._amount, description, email, mobile, callbackUrl);
        //    using (HttpClient httpClient = new HttpClient())
        //    {
        //        using (HttpResponseMessage httpResponseMessage = await httpClient.PostAsync("http://api3.zarinpal.dev/pg/rest/WebGate/UnverifiedTransactions.json",
        //            new StringContent(JsonConvert.SerializeObject(new
        //            {
        //                MerchantID = this._merchantId
        //            }), Encoding.UTF8, "application/json")))
        //        {
        //            return JsonConvert.DeserializeObject<PaymentRequestResponse>(await httpResponseMessage.Content.ReadAsStringAsync());
        //        }
        //    }
        //}

        public async Task <PaymentVerificationResponse> Verification(string authority)
        {
            var k = await Client.Create().PaymentVerificationAsync(this._merchantId, authority, this._amount);

            PaymentVerificationResponse obj = new PaymentVerificationResponse();

            obj.RefId  = k.Body.RefID;
            obj.Status = k.Body.Status;
            return(obj);

            //using (HttpClient httpClient = new HttpClient())
            //{
            //    using (HttpResponseMessage httpResponseMessage = await httpClient.PostAsync("http://api3.zarinpal.dev/pg/rest/WebGate/PaymentVerification.json",
            //        new StringContent(JsonConvert.SerializeObject(new
            //        {
            //            MerchantID = this._merchantId,
            //            Amount = this._amount,
            //            Authority = authority
            //        }), Encoding.UTF8, "application/json")))
            //    {
            //        return JsonConvert.DeserializeObject<PaymentVerificationResponse>(await httpResponseMessage.Content.ReadAsStringAsync());
            //    }
            //}
        }
 private async Task SetSuccessAsync(string authority, PaymentVerificationResponse response)
 {
     long refID = response.Body.RefID;
     await zarinPalPaymentRepository.SetSuccessAsync(authority, refID);
 }