src/Azos.Stripe/Pay/Stripe/StripeSystem.cs
/// <summary>
/// Creates new recipient in Stripe system.
/// Is used as a temporary entity to substitute recipient parameter in Transfer operation then deleted
/// </summary>
Creates new recipient in Stripe system.
Is used as a temporary entity to substitute recipient parameter in Transfer operation then deleted
Creates new recipient in Stripe system . Is used as a temporary entity to substitute recipient parameter in Transfer operation then deleted
private string createRecipient(StripeSession session, Account recipientAccount, string description)
      {
        var recipientActualAccountData = session.FetchAccountData(recipientAccount);
        try
        {
          var bodyPrms = new Dictionary<string, string>()
          {
            {PRM_NAME, recipientActualAccountData.AccountTitle},
            {PRM_TYPE, recipientActualAccountData.AccountType == AccountType.Corporation ? "corporation" : "individual"},
            {PRM_EMAIL, recipientActualAccountData.BillingAddress.EMail}
          };
          fillBodyParametersFromAccount(bodyPrms, recipientActualAccountData);
          var prms = new WebClient.RequestParams(this)
          {
            UserName = session.SecretKey,
            Method = HTTPRequestMethod.POST,
            BodyParameters = bodyPrms
          };
          dynamic obj = WebClient.GetJsonAsDynamic(new Uri(RECIPIENT_URI), prms);
          return obj.id;
        }
        catch (Exception ex)
        {
          var wex = ex as System.Net.WebException;
          if (wex != null)
          {
            var response = wex.Response as System.Net.HttpWebResponse;
            if (response != null)
            {
              string errorMessage = this.GetType().Name +
                ".createRecipient(customerAccout='{0}')".Args(recipientActualAccountData);
              PaymentStripeException stripeEx = PaymentStripeException.Compose(response, errorMessage, wex);
              if (stripeEx != null) throw stripeEx;
            }
          }
          throw new PaymentStripeException(StringConsts.PAYMENT_CANNOT_CREATE_RECIPIENT_ERROR + this.GetType()
            + " .Refund(customerAccout='{0}')".Args(recipientActualAccountData), ex);
        }
      }
private string createRecipient ( StripeSession session , Account recipientAccount , string description ) { var recipientActualAccountData = session . FetchAccountData ( recipientAccount ) ; try { var bodyPrms = new Dictionary < string , string > ( ) { { PRM_NAME , recipientActualAccountData . AccountTitle } , { PRM_TYPE , recipientActualAccountData . AccountType == AccountType . Corporation ? " " : " " } , { PRM_EMAIL , recipientActualAccountData . BillingAddress . EMail } } ; fillBodyParametersFromAccount ( bodyPrms , recipientActualAccountData ) ; var prms = new WebClient . RequestParams ( this ) { UserName = session . SecretKey , Method = HTTPRequestMethod . POST , BodyParameters = bodyPrms } ; dynamic obj = WebClient . GetJsonAsDynamic ( new Uri ( RECIPIENT_URI ) , prms ) ; return obj . id ; } catch ( Exception ex ) { var wex = ex as System . Net . WebException ; if ( wex != null ) { var response = wex . Response as System . Net . HttpWebResponse ; if ( response != null ) { string errorMessage = this . GetType ( ) . Name + " " . Args ( recipientActualAccountData ) ; PaymentStripeException stripeEx = PaymentStripeException . Compose ( response , errorMessage , wex ) ; if ( stripeEx != null ) throw stripeEx ; } } throw new PaymentStripeException ( StringConsts . PAYMENT_CANNOT_CREATE_RECIPIENT_ERROR + this . GetType ( ) + " " . Args ( recipientActualAccountData ) , ex ) ; } }
Creates new recipient in Stripe system.
Creates new recipient in Stripe system .
session
StripeSession
recipientAccount
Account
description
string