Use NVP/SOAP Api from PayPal
parent
0aa9ac202b
commit
938159a55c
@ -1,173 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNet.Http;
|
|
||||||
using Microsoft.AspNet.Mvc;
|
|
||||||
using Microsoft.Data.Entity;
|
|
||||||
using Yavsc.Models;
|
|
||||||
using Yavsc.Models.Haircut;
|
|
||||||
using Yavsc.Models.Haircut.Views;
|
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
|
||||||
{
|
|
||||||
[Produces("application/json")]
|
|
||||||
[Route("api/haircutquery")]
|
|
||||||
public class HairCutQueriesApiController : Controller
|
|
||||||
{
|
|
||||||
private ApplicationDbContext _context;
|
|
||||||
|
|
||||||
public HairCutQueriesApiController(ApplicationDbContext context)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// GET: api/HairCutQueriesApi
|
|
||||||
// Get the active queries for current
|
|
||||||
// user, as a client
|
|
||||||
[HttpGet]
|
|
||||||
public async Task<IActionResult> GetHairCutQueries()
|
|
||||||
{
|
|
||||||
IEnumerable<HaircutQueryClientInfo> info = null;
|
|
||||||
await Task.Run(
|
|
||||||
() =>
|
|
||||||
{
|
|
||||||
var bi = DateTime.Now.AddDays(-15);
|
|
||||||
|
|
||||||
var uid = User.GetUserId();
|
|
||||||
|
|
||||||
var dat = _context.HairCutQueries
|
|
||||||
.Include(q => q.Prestation)
|
|
||||||
.Include(q => q.Client)
|
|
||||||
.Include(q => q.PerformerProfile)
|
|
||||||
.Include(q => q.Location)
|
|
||||||
.Where(q => q.ClientId == uid
|
|
||||||
&& (q.EventDate == null || q.EventDate > bi))
|
|
||||||
;
|
|
||||||
info = dat.ToArray().Select(q => new HaircutQueryClientInfo(q));
|
|
||||||
});
|
|
||||||
|
|
||||||
return Ok(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: api/HairCutQueriesApi/5
|
|
||||||
[HttpGet("{id}", Name = "GetHairCutQuery")]
|
|
||||||
public async Task<IActionResult> GetHairCutQuery([FromRoute] long id)
|
|
||||||
{
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
{
|
|
||||||
return HttpBadRequest(ModelState);
|
|
||||||
}
|
|
||||||
|
|
||||||
HairCutQuery hairCutQuery = await _context.HairCutQueries.SingleAsync(m => m.Id == id);
|
|
||||||
|
|
||||||
if (hairCutQuery == null)
|
|
||||||
{
|
|
||||||
return HttpNotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(hairCutQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT: api/HairCutQueriesApi/5
|
|
||||||
[HttpPut("{id}")]
|
|
||||||
public async Task<IActionResult> PutHairCutQuery([FromRoute] long id, [FromBody] HairCutQuery hairCutQuery)
|
|
||||||
{
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
{
|
|
||||||
return HttpBadRequest(ModelState);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id != hairCutQuery.Id)
|
|
||||||
{
|
|
||||||
return HttpBadRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
_context.Entry(hairCutQuery).State = EntityState.Modified;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!HairCutQueryExists(id))
|
|
||||||
{
|
|
||||||
return HttpNotFound();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST: api/HairCutQueriesApi
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<IActionResult> PostHairCutQuery([FromBody] HairCutQuery hairCutQuery)
|
|
||||||
{
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
{
|
|
||||||
return HttpBadRequest(ModelState);
|
|
||||||
}
|
|
||||||
|
|
||||||
_context.HairCutQueries.Add(hairCutQuery);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
catch (DbUpdateException)
|
|
||||||
{
|
|
||||||
if (HairCutQueryExists(hairCutQuery.Id))
|
|
||||||
{
|
|
||||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CreatedAtRoute("GetHairCutQuery", new { id = hairCutQuery.Id }, hairCutQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE: api/HairCutQueriesApi/5
|
|
||||||
[HttpDelete("{id}")]
|
|
||||||
public async Task<IActionResult> DeleteHairCutQuery([FromRoute] long id)
|
|
||||||
{
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
{
|
|
||||||
return HttpBadRequest(ModelState);
|
|
||||||
}
|
|
||||||
|
|
||||||
HairCutQuery hairCutQuery = await _context.HairCutQueries.SingleAsync(m => m.Id == id);
|
|
||||||
if (hairCutQuery == null)
|
|
||||||
{
|
|
||||||
return HttpNotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
_context.HairCutQueries.Remove(hairCutQuery);
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
return Ok(hairCutQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
_context.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool HairCutQueryExists(long id)
|
|
||||||
{
|
|
||||||
return _context.HairCutQueries.Count(e => e.Id == id) > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,188 +1,249 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PayPal.Api;
|
|
||||||
using PayPal.Exception;
|
using PayPal.Exception;
|
||||||
using Yavsc.Models.Billing;
|
using Yavsc.Models.Billing;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PayPal.PayPalAPIInterfaceService.Model;
|
||||||
|
using PayPal.PayPalAPIInterfaceService;
|
||||||
|
using Yavsc.ViewModels.PayPal;
|
||||||
|
using Yavsc.Models;
|
||||||
|
using Microsoft.Data.Entity;
|
||||||
|
using System.Linq;
|
||||||
|
using Yavsc.Models.Payment;
|
||||||
|
|
||||||
namespace Yavsc.Helpers
|
namespace Yavsc.Helpers
|
||||||
{
|
{
|
||||||
public static class PayPalHelpers
|
public static class PayPalHelpers
|
||||||
{
|
{
|
||||||
private static OAuthTokenCredential payPaylCredential=null;
|
private static Dictionary<string,string> payPalProperties = null;
|
||||||
public static OAuthTokenCredential PayPaylCredential
|
public static Dictionary<string,string> GetPayPalProperties() {
|
||||||
{
|
if (payPalProperties==null) {
|
||||||
get
|
|
||||||
{
|
payPalProperties = new Dictionary<string,string>();
|
||||||
if (payPaylCredential==null)
|
// Don't do:
|
||||||
{
|
// payPalProperties.Add("mode", Startup.PayPalSettings.Mode);
|
||||||
Dictionary<string,string> config = new Dictionary<string,string>();
|
// Instead, set the endpoint parameter.
|
||||||
// config.Add("mode",Startup.PayPalSettings.Mode);
|
if (Startup.PayPalSettings.Mode == "production") {
|
||||||
// config.Add("clientId",Startup.PayPalSettings.ClientId);
|
// use nvp end point: https://api-3t.paypal.com/nvp
|
||||||
// config.Add("clientSecret",Startup.PayPalSettings.Secret);
|
payPalProperties.Add("endpoint", "https://api-3t.paypal.com/nvp");
|
||||||
// config.Add("user",Startup.PayPalSettings.APIUserId);
|
|
||||||
// https://api-3t.paypal.com/nvp
|
} else {
|
||||||
config.Add("USER",Startup.PayPalSettings.APIUserId);
|
payPalProperties.Add("endpoint", "https://api-3t.sandbox.paypal.com/nvp");
|
||||||
config.Add("SIGNATURE",Startup.PayPalSettings.APISignature);
|
}
|
||||||
config.Add("PWD",Startup.PayPalSettings.APIPassword);
|
payPalProperties.Add("clientId", Startup.PayPalSettings.ClientId);
|
||||||
payPaylCredential = new OAuthTokenCredential(config);
|
payPalProperties.Add("clientSecret", Startup.PayPalSettings.ClientSecret);
|
||||||
|
|
||||||
|
int numClient = 0;
|
||||||
|
if (Startup.PayPalSettings.Accounts!=null)
|
||||||
|
foreach (var account in Startup.PayPalSettings.Accounts) {
|
||||||
|
numClient++;
|
||||||
|
payPalProperties.Add ($"account{numClient}.apiUsername",account.ApiUsername);
|
||||||
|
payPalProperties.Add ($"account{numClient}.apiPassword",account.ApiPassword);
|
||||||
|
payPalProperties.Add ($"account{numClient}.apiSignature",account.Signature);
|
||||||
}
|
}
|
||||||
return payPaylCredential;
|
|
||||||
}
|
}
|
||||||
|
return payPalProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static APIContext CreateAPIContext()
|
public class PayPalOAuth2Token
|
||||||
{
|
{
|
||||||
var accessToken = PayPaylCredential.GetAccessToken();
|
public string scope;
|
||||||
var apiContext = new APIContext(accessToken);
|
public string nonce;
|
||||||
return apiContext;
|
public string access_token;
|
||||||
}
|
public string token_type;
|
||||||
|
|
||||||
public class PaymentUrls {
|
public string app_id;
|
||||||
public string Details { get; set; }
|
public string expires_in;
|
||||||
public string Cancel { get; set; }
|
|
||||||
|
|
||||||
public string CGV { get; set; }
|
|
||||||
}
|
|
||||||
public static PaymentUrls GetPaymentUrls(this HttpRequest request, string controllerName, string id )
|
|
||||||
{
|
|
||||||
var result =new PaymentUrls {
|
|
||||||
Details = request.ToAbsolute($"{controllerName}/Details/{id}") ,
|
|
||||||
Cancel = request.ToAbsolute($"{controllerName}/ClientCancel/{id}"),
|
|
||||||
CGV = request.ToAbsolute($"{controllerName}/CGV")
|
|
||||||
};
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
private static PayPalOAuth2Token token = null;
|
||||||
|
private static PayPalAPIInterfaceServiceService payPalService = null;
|
||||||
|
public static PayPalAPIInterfaceServiceService PayPalService {
|
||||||
|
get {
|
||||||
|
if (payPalService==null)
|
||||||
|
payPalService = new PayPal.PayPalAPIInterfaceService.PayPalAPIInterfaceServiceService(GetPayPalProperties());
|
||||||
|
return payPalService;
|
||||||
|
}}
|
||||||
|
|
||||||
public static Payment CreatePayment(this HttpRequest request, string controllerName, APIContext apiContext, NominativeServiceCommand query, string intent = "sale", ILogger logger=null)
|
[Obsolete("use the PayPalService property")]
|
||||||
|
internal static async Task<string> GetAccessToken()
|
||||||
{
|
{
|
||||||
var queryType = query.GetType().Name;
|
|
||||||
var transaction = new Transaction
|
|
||||||
{
|
|
||||||
description = query.Description,
|
|
||||||
invoice_number = query.Id.ToString(),
|
|
||||||
custom = query.GetType().Name + "/"+ query.Id.ToString()
|
|
||||||
};
|
|
||||||
|
|
||||||
var urls = request.GetPaymentUrls(controllerName, query.Id.ToString() );
|
|
||||||
|
|
||||||
transaction.order_url = urls.Details;
|
if (token == null)
|
||||||
|
{
|
||||||
|
token = new PayPalOAuth2Token();
|
||||||
|
|
||||||
// transaction.item_list.shipping_address.city
|
using (HttpClient client = new HttpClient())
|
||||||
// country_code default_address id
|
|
||||||
// line1 line2 preferred_address recipient_name state status type
|
|
||||||
/* transaction.item_list = new ItemList();
|
|
||||||
if (query.Client.PostalAddress!=null) {
|
|
||||||
var address = query.Client.PostalAddress?.Address;
|
|
||||||
if (address!=null) {
|
|
||||||
var parts = new Stack<string> ( address.Split(',') );
|
|
||||||
var country = parts.Pop().Trim();
|
|
||||||
var city = parts.Pop().Trim().Split(' ');
|
|
||||||
var line1 = parts.First().Trim();
|
|
||||||
var line2 = string.Join(" - ",parts.Skip(1));
|
|
||||||
transaction.item_list.shipping_address = new ShippingAddress {
|
|
||||||
line1 = line1,
|
|
||||||
line2 = line2,
|
|
||||||
city = city[1],
|
|
||||||
postal_code = city[0],
|
|
||||||
country_code = country == "France" ? "fr" : country
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
transaction.item_list.shipping_phone_number = query.Client.PhoneNumber;
|
|
||||||
var items = query.GetBillItems();
|
|
||||||
transaction.item_list.items = items.Select(i => new Item {
|
|
||||||
name = i.Name,
|
|
||||||
description = i.Description,
|
|
||||||
quantity = i.Count.ToString(),
|
|
||||||
price = i.UnitaryCost.ToString("F2"),
|
|
||||||
currency = "EUR",
|
|
||||||
sku = "sku"
|
|
||||||
// postback_data=
|
|
||||||
// supplementary_data=
|
|
||||||
}).ToList();
|
|
||||||
*/ var total = query.GetBillItems().Addition().ToString("F2");
|
|
||||||
transaction.amount = new Amount {
|
|
||||||
currency = "EUR",
|
|
||||||
total = total
|
|
||||||
};
|
|
||||||
var payment = new Payment
|
|
||||||
{
|
{
|
||||||
intent = intent, // "sale", "order", "authorize"
|
|
||||||
payer = new Payer
|
var uriString = Startup.PayPalSettings.Mode == "production" ?
|
||||||
{
|
"https://api.paypal.com/v1/oauth2/token" : "https://api.sandbox.paypal.com/v1/oauth2/token";
|
||||||
payment_method = "paypal"
|
|
||||||
},
|
client.DefaultRequestHeaders.Add("Accept", "application/json");
|
||||||
transactions = new List<Transaction> { transaction },
|
client.DefaultRequestHeaders.Add("Accept-Language", "en_US");
|
||||||
redirect_urls = new RedirectUrls
|
|
||||||
|
|
||||||
|
string oAuthCredentials = Convert.ToBase64String(Encoding.Default.GetBytes(Startup.PayPalSettings.ClientId + ":" + Startup.PayPalSettings.ClientSecret));
|
||||||
|
|
||||||
|
var h_request = new HttpRequestMessage(HttpMethod.Post, uriString);
|
||||||
|
|
||||||
|
h_request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", oAuthCredentials);
|
||||||
|
var keyValues = new List<KeyValuePair<string, string>>();
|
||||||
|
keyValues.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));
|
||||||
|
h_request.Content = new FormUrlEncodedContent(keyValues);
|
||||||
|
|
||||||
|
using (var response = await client.SendAsync(h_request))
|
||||||
{
|
{
|
||||||
return_url = urls.Details,
|
if (response.IsSuccessStatusCode)
|
||||||
cancel_url = urls.Cancel
|
{
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
Console.WriteLine(content);
|
||||||
|
token = JsonConvert.DeserializeObject<PayPalOAuth2Token>(content);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new PayPalException($"{response.StatusCode}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
Payment result = null;
|
}
|
||||||
try {
|
|
||||||
result = Payment.Create(apiContext,payment);
|
|
||||||
}
|
|
||||||
catch (PaymentsException ex) {
|
|
||||||
logger.LogError (ex.Message);
|
|
||||||
}
|
}
|
||||||
return result;
|
return token?.access_token ?? null;
|
||||||
|
//return PayPalCredential.GetAccessToken();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Payment CreatePayment(this HttpRequest request, string controllerName, APIContext apiContext, Estimate estimation)
|
public class PaymentUrls
|
||||||
{
|
{
|
||||||
var urls = request.GetPaymentUrls( controllerName, estimation.Id.ToString() );
|
public string ReturnUrl { get; set; }
|
||||||
var payment = Payment.Create(apiContext,
|
public string CancelUrl { get; set; }
|
||||||
new Payment
|
public string CGVUrl { get; set; }
|
||||||
{
|
}
|
||||||
intent = "order", // "sale", "order", "authorize"
|
public static PaymentUrls GetPaymentUrls(this HttpRequest request, string controllerName, string id)
|
||||||
payer = new Payer
|
|
||||||
{
|
|
||||||
payment_method = "paypal"
|
|
||||||
},
|
|
||||||
transactions = new List<Transaction>
|
|
||||||
{
|
|
||||||
new Transaction
|
|
||||||
{
|
{
|
||||||
description = "Transaction description.",
|
var result = new PaymentUrls
|
||||||
invoice_number = estimation.Id.ToString(),
|
|
||||||
amount = new Amount
|
|
||||||
{
|
{
|
||||||
currency = "EUR",
|
ReturnUrl = request.ToAbsolute($"{controllerName}/Confirmation/{id}"),
|
||||||
total = "0.11",
|
CancelUrl = request.ToAbsolute($"{controllerName}/ClientCancel/{id}"),
|
||||||
details = new Details
|
CGVUrl = request.ToAbsolute($"{controllerName}/CGV")
|
||||||
{
|
};
|
||||||
tax = "0.01",
|
return result;
|
||||||
shipping = "0.02",
|
|
||||||
subtotal = "0.08"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
item_list = new ItemList
|
|
||||||
{
|
|
||||||
items = new List<Item>
|
|
||||||
{
|
|
||||||
new Item
|
|
||||||
{
|
|
||||||
name = "nah",
|
|
||||||
currency = "EUR",
|
|
||||||
price = "0.02",
|
|
||||||
quantity = "4",
|
|
||||||
sku = "sku"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
redirect_urls = new RedirectUrls
|
private static string MerchantUserId { get {
|
||||||
|
return Startup.PayPalSettings.Accounts[0].ApiUsername;
|
||||||
|
}}
|
||||||
|
public static SetExpressCheckoutResponseType CreatePayment(this HttpRequest request, string controllerName, NominativeServiceCommand query, string intent = "sale", ILogger logger = null)
|
||||||
|
{
|
||||||
|
var items = query.GetBillItems();
|
||||||
|
var total = items.Addition().ToString("F2");
|
||||||
|
var queryType = query.GetType().Name;
|
||||||
|
var coreq = new SetExpressCheckoutReq {};
|
||||||
|
var urls = request.GetPaymentUrls(controllerName, query.Id.ToString());
|
||||||
|
coreq.SetExpressCheckoutRequest = new SetExpressCheckoutRequestType{
|
||||||
|
DetailLevel = new List<DetailLevelCodeType?> { DetailLevelCodeType.RETURNALL },
|
||||||
|
SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType
|
||||||
{
|
{
|
||||||
return_url = urls.Details,
|
PaymentDetails = items.Select(i => new PaymentDetailsType{
|
||||||
cancel_url = urls.Cancel
|
OrderTotal = new BasicAmountType {
|
||||||
|
currencyID = CurrencyCodeType.EUR,
|
||||||
|
value = (i.Count * i.UnitaryCost).ToString("F2")
|
||||||
|
},
|
||||||
|
OrderDescription = i.Description
|
||||||
|
}).ToList(),
|
||||||
|
InvoiceID = queryType + "/" + query.Id.ToString(),
|
||||||
|
OrderDescription = query.Description, CancelURL = urls.CancelUrl, ReturnURL = urls.ReturnUrl
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
var response = PayPalService.SetExpressCheckout( coreq, MerchantUserId );
|
||||||
|
|
||||||
return payment;
|
// transaction.item_list.shipping_address.city
|
||||||
|
// country_code default_address id
|
||||||
|
// line1 line2 preferred_address recipient_name state status type
|
||||||
|
/* transaction.item_list = new ItemList();
|
||||||
|
if (query.Client.PostalAddress!=null) {
|
||||||
|
var address = query.Client.PostalAddress?.Address;
|
||||||
|
if (address!=null) {
|
||||||
|
var parts = new Stack<string> ( address.Split(',') );
|
||||||
|
var country = parts.Pop().Trim();
|
||||||
|
var city = parts.Pop().Trim().Split(' ');
|
||||||
|
var line1 = parts.First().Trim();
|
||||||
|
var line2 = string.Join(" - ",parts.Skip(1));
|
||||||
|
transaction.item_list.shipping_address = new ShippingAddress {
|
||||||
|
line1 = line1,
|
||||||
|
line2 = line2,
|
||||||
|
city = city[1],
|
||||||
|
postal_code = city[0],
|
||||||
|
country_code = country == "France" ? "fr" : country
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transaction.item_list.shipping_phone_number = query.Client.PhoneNumber;
|
||||||
|
var items = query.GetBillItems();
|
||||||
|
transaction.item_list.items = items.Select(i => new Item {
|
||||||
|
name = i.Name,
|
||||||
|
description = i.Description,
|
||||||
|
quantity = i.Count.ToString(),
|
||||||
|
price = i.UnitaryCost.ToString("F2"),
|
||||||
|
currency = "EUR",
|
||||||
|
sku = "sku"
|
||||||
|
// postback_data=
|
||||||
|
// supplementary_data=
|
||||||
|
}).ToList();
|
||||||
|
*/
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<PaymentInfo> GetCheckoutInfo(
|
||||||
|
this ApplicationDbContext context,
|
||||||
|
string token)
|
||||||
|
{
|
||||||
|
return await CreatePaymentViewModel(context,token,GetExpressCheckoutDetails(token));
|
||||||
|
}
|
||||||
|
private static GetExpressCheckoutDetailsResponseType GetExpressCheckoutDetails(string token)
|
||||||
|
{
|
||||||
|
GetExpressCheckoutDetailsReq req = new GetExpressCheckoutDetailsReq{
|
||||||
|
GetExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType {
|
||||||
|
Token = token
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return PayPalService.GetExpressCheckoutDetails(req,Startup.PayPalSettings.Accounts[0].ApiUsername);
|
||||||
|
}
|
||||||
|
public static async Task<PaymentInfo> ConfirmPayment(
|
||||||
|
this ApplicationDbContext context,
|
||||||
|
string userId,
|
||||||
|
string payerId,
|
||||||
|
string token)
|
||||||
|
{
|
||||||
|
var details = GetExpressCheckoutDetails(token);
|
||||||
|
var payment = new PayPalPayment{
|
||||||
|
ExecutorId = userId,
|
||||||
|
PaypalPayerId = payerId,
|
||||||
|
CreationToken = token
|
||||||
|
};
|
||||||
|
context.PayPalPayments.Add(payment);
|
||||||
|
await context.SaveChangesAsync(userId);
|
||||||
|
// GetCheckoutInfo(,token);
|
||||||
|
return new PaymentInfo { DbContent = payment, DetailsFromPayPal = details };
|
||||||
|
}
|
||||||
|
public static async Task<PaymentInfo> CreatePaymentViewModel (
|
||||||
|
this ApplicationDbContext context,
|
||||||
|
string token, GetExpressCheckoutDetailsResponseType fromPayPal)
|
||||||
|
{
|
||||||
|
return new PaymentInfo {
|
||||||
|
DbContent = await context.PayPalPayments.SingleOrDefaultAsync(
|
||||||
|
p=>p.CreationToken==token),
|
||||||
|
DetailsFromPayPal = fromPayPal
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@
|
|||||||
|
using Microsoft.Data.Entity.Migrations;
|
||||||
|
|
||||||
|
namespace Yavsc.Migrations
|
||||||
|
{
|
||||||
|
public partial class paypalToDeprecated : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameTable( name: "PaypalPayment", newName: "PayPalPayment");
|
||||||
|
migrationBuilder.RenameColumn ( name:"PaypalPaymentId", table: "PayPalPayment", newName:"CreationToken" );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn ( newName :"PaypalPaymentId", table: "PayPalPayment", name:"CreationToken" );
|
||||||
|
migrationBuilder.RenameTable( newName: "PaypalPayment", name: "PayPalPayment");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
namespace Yavsc.Services
|
||||||
|
{
|
||||||
|
public interface IBankInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +1,30 @@
|
|||||||
namespace Yavsc
|
namespace Yavsc
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// PayPal NV/SOAP API Credentials
|
||||||
|
/// </summary>
|
||||||
public class PayPalSettings {
|
public class PayPalSettings {
|
||||||
|
/// <summary>
|
||||||
|
/// supported values: <c>sandbox</c> or <c>production</c>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public string Mode { get; set; }
|
public string Mode { get; set; }
|
||||||
public string Secret { get; set; }
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string ClientId { get; set; }
|
public string ClientId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// For sandbox only?
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ClientSecret { get; set; }
|
||||||
|
public string ApplicationId { get; set; }
|
||||||
|
public class ClassicPayPalAccountApiCredential {
|
||||||
|
public string Signature { get; set; }
|
||||||
|
public string ApiUsername { get; set; }
|
||||||
|
public string ApiPassword { get; set; }
|
||||||
|
|
||||||
// NV/SOAP Api - Signature
|
}
|
||||||
public string UserId { get; set; }
|
public ClassicPayPalAccountApiCredential[] Accounts { get; set; }
|
||||||
public string Password { get; set; }
|
|
||||||
public string Signature { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
using Microsoft.AspNet.Mvc;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using Yavsc.Models.Billing;
|
||||||
|
|
||||||
|
namespace Yavsc.ViewComponents
|
||||||
|
{
|
||||||
|
public class PayPalButtonViewComponent : ViewComponent
|
||||||
|
{
|
||||||
|
public IViewComponentResult Invoke(NominativeServiceCommand command, string apiControllerName , string controllerName)
|
||||||
|
{
|
||||||
|
ViewBag.CreatePaymentUrl = Request.ToAbsolute($"api/{apiControllerName}/createpayment/"+command.Id);
|
||||||
|
ViewBag.ExecutePaymentUrl = Request.ToAbsolute("api/payment/execute");
|
||||||
|
ViewBag.Urls=Request.GetPaymentUrls(controllerName,command.Id.ToString());
|
||||||
|
return View ( command);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,11 +1,14 @@
|
|||||||
using PayPal.Api;
|
|
||||||
|
|
||||||
|
using PayPal.PayPalAPIInterfaceService.Model;
|
||||||
using Yavsc.Models.Payment;
|
using Yavsc.Models.Payment;
|
||||||
|
|
||||||
namespace Yavsc.ViewModels.PayPal
|
namespace Yavsc.ViewModels.PayPal
|
||||||
{
|
{
|
||||||
public class PaymentInfo
|
public class PaymentInfo
|
||||||
{
|
{
|
||||||
public PaypalPayment DbContent { get; set; }
|
public PayPalPayment DbContent { get; set; }
|
||||||
public Payment FromPaypal { get; set; }
|
|
||||||
|
public virtual GetExpressCheckoutDetailsResponseType DetailsFromPayPal { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt> Le paiment @ViewData["id"] a échoué
|
||||||
|
</dt>
|
||||||
|
<dd> @ViewData["error"]
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
@ -1,20 +0,0 @@
|
|||||||
@using PayPal.Api
|
|
||||||
@model Payment
|
|
||||||
|
|
||||||
<dl>
|
|
||||||
<dt> État du paiment
|
|
||||||
</dt>
|
|
||||||
<dd> @SR[Model.state] @Model.failure_reason
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
</dt>
|
|
||||||
<dd>@Model.payment_instruction
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
@if (Model.state=="created") {
|
|
||||||
<a href="@Model.GetApprovalUrl()">Autoriser le paiement</a>
|
|
||||||
}
|
|
||||||
@{ var refundUrl = Model.GetHateoasLink("refund"); }
|
|
||||||
@if (refundUrl!=null) {
|
|
||||||
<a href="@refundUrl">Rembourser ce paiement</a>
|
|
||||||
}
|
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
@model NominativeServiceCommand
|
||||||
|
@inject IOptions<PayPalSettings> PayPalSettings
|
||||||
|
@Model.PaymentId
|
||||||
|
@if (Model!=null && Model.PaymentId!=null) {
|
||||||
|
|
||||||
|
@if (Model.Regularisation.Executor.Id == User.GetUserId()) {
|
||||||
|
<text>
|
||||||
|
Votre paiment
|
||||||
|
</text>
|
||||||
|
} else {
|
||||||
|
<text>
|
||||||
|
Le paiment de @Html.DisplayFor(m=>m.Regularisation.Executor.UserName)
|
||||||
|
</text>
|
||||||
|
}
|
||||||
|
<text> :
|
||||||
|
</text><a asp-controller="Manage" asp-action="PaymentInfo" asp-route-id="@Model.Regularisation.PaypalPaymentId">@Model.Regularisation.PaypalPaymentId</a>
|
||||||
|
|
||||||
|
} else {
|
||||||
|
<div id="paypalzone"></div>
|
||||||
|
<script>
|
||||||
|
var CREATE_PAYMENT_URL = '@ViewBag.CreatePaymentUrl';
|
||||||
|
var EXECUTE_PAYMENT_URL = '@ViewBag.ExecutePaymentUrl';
|
||||||
|
var PAYPAL_ENV = '@PayPalSettings.Value.Mode';
|
||||||
|
var APP_ID = '@PayPalSettings.Value.ApplicationId';
|
||||||
|
|
||||||
|
|
||||||
|
paypal.checkout.setup(APP_ID, {
|
||||||
|
environment: PAYPAL_ENV,
|
||||||
|
container: '#paypalzone',
|
||||||
|
click: function () {
|
||||||
|
paypal.checkout.initXO();
|
||||||
|
var action = $.post(CREATE_PAYMENT_URL)
|
||||||
|
.done(function (data) {
|
||||||
|
paypal.checkout.startFlow(data.token)
|
||||||
|
})
|
||||||
|
.fail(function () {
|
||||||
|
paypal.checkout.closeFlow()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
}
|
||||||
@ -1,55 +0,0 @@
|
|||||||
@model PaypalPayment
|
|
||||||
@inject IOptions<PayPalSettings> PayPalSettings
|
|
||||||
@if (Model!=null && Model.PaypalPaymentId!=null) {
|
|
||||||
|
|
||||||
@if (Model.Executor.Id == User.GetUserId()) {
|
|
||||||
<text>
|
|
||||||
Votre paiment
|
|
||||||
</text>
|
|
||||||
} else {
|
|
||||||
<text>
|
|
||||||
Le paiment de @Html.DisplayFor(m=>m.Executor.UserName)
|
|
||||||
</text>
|
|
||||||
}
|
|
||||||
<text> :
|
|
||||||
</text><a asp-controller="Manage" asp-action="PaymentInfo" asp-route-id="@Model.PaypalPaymentId">@Model.PaypalPaymentId</a>
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
<div id="paypal-button"></div>
|
|
||||||
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
|
|
||||||
<script>
|
|
||||||
var CREATE_PAYMENT_URL = '@ViewBag.CreatePaymentUrl';
|
|
||||||
var EXECUTE_PAYMENT_URL = '@ViewBag.ExecutePaymentUrl';
|
|
||||||
var PAYPAL_ENV = '@PayPalSettings.Value.Mode';
|
|
||||||
|
|
||||||
paypal.Button.render({
|
|
||||||
|
|
||||||
env: PAYPAL_ENV, // 'production', Optional: specify 'sandbox' environment
|
|
||||||
commit: true,
|
|
||||||
payment: function(resolve, reject) {
|
|
||||||
|
|
||||||
return paypal.request.post(CREATE_PAYMENT_URL)
|
|
||||||
.then(function(data) { resolve(data.id); })
|
|
||||||
.catch(function(err) { reject(err); });
|
|
||||||
},
|
|
||||||
|
|
||||||
onAuthorize: function(data) {
|
|
||||||
|
|
||||||
// Note: you can display a confirmation page before executing
|
|
||||||
|
|
||||||
return paypal.request.post(EXECUTE_PAYMENT_URL,
|
|
||||||
{ paymentID: data.paymentID, payerID: data.payerID })
|
|
||||||
|
|
||||||
.then(function(data) {
|
|
||||||
document.location = '@ViewBag.Urls.Details';
|
|
||||||
/* Go to a success page */ })
|
|
||||||
.catch(function(err) {
|
|
||||||
document.location = '/Manage/PaymentInfo/'+data.paymentID;
|
|
||||||
/* Go to an error page */ });
|
|
||||||
}
|
|
||||||
|
|
||||||
}, '#paypal-button');
|
|
||||||
</script>
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,167 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="210mm"
|
||||||
|
height="297mm"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.5 r10040"
|
||||||
|
sodipodi:docname="meche-cheveux.svg">
|
||||||
|
<defs
|
||||||
|
id="defs4">
|
||||||
|
<inkscape:perspective
|
||||||
|
sodipodi:type="inkscape:persp3d"
|
||||||
|
inkscape:vp_x="0 : 526.18109 : 1"
|
||||||
|
inkscape:vp_y="0 : 1000 : 0"
|
||||||
|
inkscape:vp_z="744.09448 : 526.18109 : 1"
|
||||||
|
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
|
||||||
|
id="perspective3240" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.5454241"
|
||||||
|
inkscape:cx="-145.39699"
|
||||||
|
inkscape:cy="570.82595"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:window-width="1670"
|
||||||
|
inkscape:window-height="771"
|
||||||
|
inkscape:window-x="105"
|
||||||
|
inkscape:window-y="240"
|
||||||
|
inkscape:window-maximized="0" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Calque 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<path
|
||||||
|
style="fill:#ac9393;stroke:#000000;stroke-width:1.33444129999999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 313.07765,585.55788 c 69.3417,-92.10668 -205.277,-404.02027 -78.52163,-399.82392 126.75538,4.19636 181.08502,340.81426 78.52163,399.82392 z"
|
||||||
|
id="path2985"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="czc" />
|
||||||
|
<path
|
||||||
|
style="fill:#483737;stroke:#000000;stroke-width:1.33444129999999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="M 130.28057,582.08153 C 233.20136,530.12747 124.80014,128.93588 236.63638,188.74548 348.47263,248.5551 248.36507,574.50264 130.28057,582.08153 z"
|
||||||
|
id="path2985-3"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="czc" />
|
||||||
|
<path
|
||||||
|
style="fill:#6c5353;stroke:#000000;stroke-width:1.3344413px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 247.97601,534.96113 c 75.96164,-86.72798 -174.84487,-418.09124 -48.74663,-404.535 126.09823,13.55625 155.39208,353.26965 48.74663,404.535 z"
|
||||||
|
id="path2985-3-6"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="czc" />
|
||||||
|
<path
|
||||||
|
style="fill:#ac9393;stroke:#ffffff;stroke-width:1.00382698px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="M 301.72304,326.2129 C 345.70788,240.72782 56.68077,198.78469 166.36779,139.55137 276.05481,80.318076 379.88582,243.19485 301.72304,326.2129 z"
|
||||||
|
id="path2985-3-7-5"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="czc" />
|
||||||
|
<path
|
||||||
|
style="fill:#483737;stroke:#ffffff;stroke-width:1.3344413px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="M 180.69589,531.81366 C 266.33952,454.6315 56.287482,96.045874 179.91288,124.35296 c 123.62543,28.30715 112.72218,369.10686 0.78301,407.4607 z"
|
||||||
|
id="path2985-3-7"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="czc" />
|
||||||
|
<path
|
||||||
|
style="fill:#6c5353;stroke:#ffffff;stroke-width:0.53339744px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="M 107.06331,222.38985 C 74.793607,186.12917 238.88465,138.19113 170.64146,120.75367 102.39828,103.31623 55.191539,190.61605 107.06331,222.38985 z"
|
||||||
|
id="path2985-3-7-5-3"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="czc" />
|
||||||
|
<path
|
||||||
|
style="fill:#ffaaaa;stroke:#000000;stroke-width:0.4433642px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 470.54061,448.07463 c -0.81906,-20.22961 -0.34929,-85.5725 -0.28738,-88.80549 0.22028,-11.50539 14.28826,-23.38239 18.96815,-28.16485 6.69381,-6.84051 10.63367,-24.1413 10.63367,-24.1413 0,0 7.66108,1.59484 15.99558,0.32228 -0.57479,10.79807 10.56992,19.98425 15.69374,26.00513 4.085,4.80019 17.72735,17.93302 17.72842,24.6608 l 0.0144,90.98561 c 0.002,7.64377 -79.07713,5.85978 -78.74662,-0.86218 z"
|
||||||
|
id="path3238"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cssccsssc" />
|
||||||
|
<path
|
||||||
|
style="fill:#806600;stroke:#000000;stroke-width:0.24125907px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 399.7668,385.77497 c 0,0 21.53755,19.2682 25.90887,18.54582 4.37133,-0.72237 48.06813,-50.91255 46.42734,-54.66976 -1.64079,-3.75722 -26.6823,-22.503 -26.6823,-22.503 0,0 21.12978,19.04623 18.25285,21.75963 -2.87694,2.7134 -25.38156,-12.1564 -25.38156,-12.1564 0,0 19.76193,17.40327 17.29569,20.28334 -2.16694,2.53055 -23.92968,-11.8921 -23.92968,-11.8921 0,0 21.10376,16.50059 18.04829,20.4778 -2.8429,3.70055 -24.74241,-11.95019 -24.74241,-11.95019 0,0 19.83028,16.13067 17.50778,19.33061 -1.66812,2.29833 -23.32596,-11.57609 -23.32596,-11.57609 0,0 20.11175,16.71856 18.33828,19.0103 -1.7735,2.29174 -22.79144,-13.01186 -22.79144,-13.01186 0,0 20.60175,16.25034 18.71649,18.87566 -1.65355,2.30266 -23.51521,-12.9419 -23.51521,-12.9419 0,0 18.80224,16.34655 17.04569,18.53661 -1.84308,2.29794 -22.67837,-11.88866 -22.67837,-11.88866 0,0 20.19488,14.82119 17.5525,17.89665 -2.64238,3.07545 -22.04685,-12.12646 -22.04685,-12.12646 z"
|
||||||
|
id="path3236"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="csscscscscsczcscsczc" />
|
||||||
|
<g
|
||||||
|
id="g3225"
|
||||||
|
transform="matrix(0.32321071,-0.27398935,0.27398935,0.32321071,62.443723,389.20207)">
|
||||||
|
<path
|
||||||
|
sodipodi:nodetypes="zzsssczz"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path3107-1"
|
||||||
|
d="m 611.08052,628.77068 c -11.35007,22.10407 -56.01094,59.25314 -83.44352,62.76065 -27.43258,3.50751 -41.51006,-12.1071 -39.78047,-34.59172 1.72958,-22.48462 15.56627,-39.78048 34.59172,-39.78048 19.02544,0 62.2175,0.80819 75.92567,-31.26515 l 96.41541,-225.58545 c 0.43194,16.48111 -1.23715,42.56061 -9.44327,62.75307 -8.20613,20.19246 -62.91548,183.60502 -74.26554,205.70908 z"
|
||||||
|
style="fill:#c8beb7;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-1.4565539,0,0,1.3670916,1456.7998,-410.12805)"
|
||||||
|
d="m 656.90489,779.51813 c 0,9.35069 -6.84445,16.93093 -15.28752,16.93093 -8.44307,0 -15.28752,-7.58024 -15.28752,-16.93093 0,-9.3507 6.84445,-16.93094 15.28752,-16.93094 8.44307,0 15.28752,7.58024 15.28752,16.93094 z"
|
||||||
|
sodipodi:ry="16.930933"
|
||||||
|
sodipodi:rx="15.287524"
|
||||||
|
sodipodi:cy="779.51813"
|
||||||
|
sodipodi:cx="641.61737"
|
||||||
|
id="path3111-2"
|
||||||
|
style="fill:#ffffff;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<g
|
||||||
|
transform="matrix(0.75214983,0.65899214,-0.65899214,0.75214983,652.97101,-319.95333)"
|
||||||
|
id="g3203"
|
||||||
|
style="fill:#c8beb7">
|
||||||
|
<path
|
||||||
|
style="fill:#c8beb7;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 554.77368,756.10744 c 11.35007,22.10407 56.01094,59.25314 83.44352,62.76065 27.43258,3.50751 41.51006,-12.1071 39.78047,-34.59172 -1.72958,-22.48462 -15.56627,-39.78048 -34.59172,-39.78048 -19.02544,0 -62.2175,0.80819 -75.92567,-31.26515 L 471.06487,487.64529 c -0.43194,16.48111 1.23715,42.56061 9.44327,62.75307 8.20613,20.19246 62.91548,183.60502 74.26554,205.70908 z"
|
||||||
|
id="path3107-1-9"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="zzsssczz" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:#ffffff;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||||
|
id="path3111-2-3"
|
||||||
|
sodipodi:cx="641.61737"
|
||||||
|
sodipodi:cy="779.51813"
|
||||||
|
sodipodi:rx="15.287524"
|
||||||
|
sodipodi:ry="16.930933"
|
||||||
|
d="m 656.90489,779.51813 c 0,9.35069 -6.84445,16.93093 -15.28752,16.93093 -8.44307,0 -15.28752,-7.58024 -15.28752,-16.93093 0,-9.3507 6.84445,-16.93094 15.28752,-16.93094 8.44307,0 15.28752,7.58024 15.28752,16.93094 z"
|
||||||
|
transform="matrix(1.4565539,0,0,1.3670916,-290.94556,-282.79129)" />
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
transform="translate(351.33384,-132.23635)"
|
||||||
|
d="m 248.43053,750.76202 c 0,4.05032 -3.28343,7.33375 -7.33374,7.33375 -4.05032,0 -7.33375,-3.28343 -7.33375,-7.33375 0,-4.05031 3.28343,-7.33374 7.33375,-7.33374 4.05031,0 7.33374,3.28343 7.33374,7.33374 z"
|
||||||
|
sodipodi:ry="7.3337426"
|
||||||
|
sodipodi:rx="7.3337426"
|
||||||
|
sodipodi:cy="750.76202"
|
||||||
|
sodipodi:cx="241.09679"
|
||||||
|
id="path3219"
|
||||||
|
style="fill:#808080;fill-opacity:1;stroke:#666666;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path3223"
|
||||||
|
d="m 588.90551,616.11187 6.48217,4.86163"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 9.5 KiB |
@ -0,0 +1,33 @@
|
|||||||
|
+(function($, paypal, PAYPAL_ENV, CREATE_PAYMENT_URL, EXECUTE_PAYMENT_URL) {
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
paypal.Button.render({
|
||||||
|
|
||||||
|
env: PAYPAL_ENV, // 'production', Optional: specify 'sandbox' environment
|
||||||
|
commit: true,
|
||||||
|
payment: function(resolve, reject) {
|
||||||
|
|
||||||
|
return paypal.request.post(CREATE_PAYMENT_URL)
|
||||||
|
.then(function(data) { resolve(data.id); })
|
||||||
|
.catch(function(err) { reject(err); });
|
||||||
|
},
|
||||||
|
|
||||||
|
onAuthorize: function(data) {
|
||||||
|
|
||||||
|
// Note: you can display a confirmation page before executing
|
||||||
|
|
||||||
|
return paypal.request.post(EXECUTE_PAYMENT_URL, { paymentID: data.paymentID, payerID: data.payerID })
|
||||||
|
|
||||||
|
.then(function(data) {
|
||||||
|
document.location = '@ViewBag.Urls.Details';
|
||||||
|
/* Go to a success page */
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
document.location = '/Manage/PaymentInfo/' + data.paymentID + '/?error=' + err;
|
||||||
|
/* Go to an error page */
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}, '#paypal-button');
|
||||||
|
})
|
||||||
|
})(jQuery);
|
||||||
@ -0,0 +1 @@
|
|||||||
|
+function(n,t,e,o,u){n(document).ready(function(){t.Button.render({env:e,commit:!0,payment:function(n,e){return t.request.post(o).then(function(t){n(t.id)})["catch"](function(n){e(n)})},onAuthorize:function(n){return t.request.post(u,{paymentID:n.paymentID,payerID:n.payerID}).then(function(n){document.location="@ViewBag.Urls.Details"})["catch"](function(t){document.location="/Manage/PaymentInfo/"+n.paymentID+"/?error="+t})}},"#paypal-button")})}(jQuery);
|
||||||
Loading…
Reference in New Issue