Exemple #1
0
        private V1PaypalPayoutResult _V1CCPayout(string payout_batch_id, string recipient_email, string emailSubject, string payout_note, string currency, double amount)
        {
            string url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v1/payments/payouts?sync_mode=true";

            V1PaypalPayout payout = new V1PaypalPayout
            {
                sender_batch_header = new V1PaypalSenderBatch
                {
                    email_subject   = emailSubject,
                    sender_batch_id = payout_batch_id
                },
                items = new List <V1PaypalPayoutItem>
                {
                    new V1PaypalPayoutItem {
                        amount = new V1PaypalPayoutAmount {
                            currency = currency, value = amount.ToString("0.00")
                        },
                        note           = payout_note,
                        receiver       = recipient_email,
                        recipient_type = "EMAIL",
                        sender_item_id = payout_batch_id + "_01"
                    }
                }
            };
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            //serializer.RegisterConverters(new JavaScriptConverter[] { new NullPropertiesConverter() });
            string payout_json = serializer.Serialize(payout);
            //payment_json = @"{'intent':'sale','payer':{'payment_method':'credit_card','funding_instruments':[{'credit_card':{'number':'5500005555555559','type':'mastercard','expire_month':12,'expire_year':2018,'cvv2':'111','first_name':'Betsy','last_name':'Buyer'}}]},'transactions':[{'amount':{'total':'7.47','currency':'USD'},'description':'This is the payment transaction description.'}]}";
            string return_json          = _V1Action(url, payout_json);
            V1PaypalPayoutResult result = serializer.Deserialize <V1PaypalPayoutResult>(return_json);

            return(result);
        }
Exemple #2
0
        public PaypalPayoutResult Payout(string payout_batch_id, string recipient_email, string emailSubject, string payout_note, string currency, double amount)
        {
            V1PaypalPayoutResult result = _V1CCPayout(payout_batch_id.Left(25), recipient_email, emailSubject, payout_note, currency, amount);

            return(new PaypalPayoutResult
            {
                status = result.batch_header.batch_status
                , amount = double.Parse(result.batch_header.amount.value)
                , currency = result.batch_header.amount.currency
                , fee = double.Parse(result.batch_header.fees.value)
                , fee_currency = result.batch_header.fees.currency
                , recipient_email = recipient_email
                , payout_batch_id = result.batch_header.payout_batch_id
                , time_completed = result.batch_header.time_completed
                , link = result.links[0].href
                , sender_batch_id = result.batch_header.sender_batch_header.sender_batch_id
            });
        }