Esempio n. 1
0
        public bool execute()
        {
            // ### Initialize `Payout` Object tests
            // Initialize a new `Payout` object with details of the batch payout to be created.
            var payout = new Payout
            {
                // #### items
                // The `items` array contains the list of payout items to be included in this payout.
                // If `syncMode` is set to `true` when calling `Payout.Create()`, then the `items` array must only
                // contain **one** item.  If `syncMode` is set to `false` when calling `Payout.Create()`, then the `items`
                // array can contain more than one item.
                items = new List <PayoutItem>
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        amount         = new Currency
                        {
                            value    = amount.ToString(),
                            currency = currency
                        },
                        receiver       = receiver,
                        note           = "Thank you.",
                        sender_item_id = "item_1"
                    },
                }
            };

            // ### Payout.Create()
            // Creates the batch payout resource.
            // `syncMode = false` indicates that this call will be performed **asynchronously**,
            // and will return a `payout_batch_id` that can be used to check the status of the payouts in the batch.
            // `syncMode = true` indicates that this call will be performed **synchronously** and will return once the payout has been processed.
            // > **NOTE**: The `items` array can only have **one** item if `syncMode` is set to `true`.
            var createdPayout = payout.Create(apiContext, true);

            ZDatabaseManager.sendTransactionQuery(this.accountID, -amount, 2, 6, 2);

            return(true);
        }
Esempio n. 2
0
        public void execute()
        {
            Refund refund = Refund.Get(apiContext, transactionPaypalID);

            ZDatabaseManager.editTransactionState(transactionDBID, "Reversed");
        }
Esempio n. 3
0
        public bool executePayment()
        {
            //don't create the payment again
            if (this.payment != null)
            {
                return(false);
            }

            //TODO - Remove randomness
            Random rnd = new Random();

            Address billingAddress = new Address();

            billingAddress.line1        = address;
            billingAddress.city         = city;
            billingAddress.country_code = countryCode;
            billingAddress.postal_code  = postalCode;
            billingAddress.state        = state;

            CreditCard creditCard = new CreditCard();

            creditCard.number          = cardNumber;
            creditCard.type            = cardType;
            creditCard.expire_month    = expMonth;
            creditCard.expire_year     = expYear;
            creditCard.cvv2            = cvv;
            creditCard.first_name      = firstName;
            creditCard.last_name       = lastName;
            creditCard.billing_address = billingAddress;

            Details amountDetails = new Details();

            amountDetails.subtotal = subTotal.ToString();
            amountDetails.tax      = "0.00";
            amountDetails.shipping = "0.00";

            Amount amount = new Amount();

            amount.total    = subTotal.ToString();
            amount.currency = currency;
            amount.details  = amountDetails;

            Transaction transaction = new Transaction();

            transaction.amount      = amount;
            transaction.description = itemDescription;

            List <Transaction> transactions = new List <Transaction>();

            transactions.Add(transaction);

            FundingInstrument fundingInstrument = new FundingInstrument();

            fundingInstrument.credit_card = creditCard;

            List <FundingInstrument> fundingInstruments = new List <FundingInstrument>();

            fundingInstruments.Add(fundingInstrument);

            Payer payer = new Payer();

            payer.funding_instruments = fundingInstruments;
            payer.payment_method      = "credit_card";

            payment              = new Payment();
            payment.intent       = "sale";
            payment.payer        = payer;
            payment.transactions = transactions;


            try
            {
                //attempt to create the payment
                payment = payment.Create(apiContext);
                //if payment was approved
                if (payment.state.ToLower() == "approved")
                {
                    //Send the query to add transaction
                    ZDatabaseManager.sendTransactionQuery(accountID, subTotal, 2, 3, 1);
                }
                else
                {
                    return(false);
                }
            } catch (PayPal.PaymentsException e)
            {
                Console.WriteLine(e);
                return(false);
            }

            saleID    = payment.transactions[0].related_resources[0].sale.id;
            paymentID = payment.id;
            return(true);
        }