Код: Выделить всё
https://devtools-paypal.com/guide/recurring_payment_ec/dotnet?interactive=ON&env=sandbox
Код: Выделить всё
SetExpressCheckoutRequestDetailsType ecDetails = new SetExpressCheckoutRequestDetailsType();
ecDetails.ReturnURL = "https://devtools-paypal.com/guide/recurring_payment_ec/dotnet?success=true";
ecDetails.CancelURL = "https://devtools-paypal.com/guide/recurring_payment_ec/dotnet?cancel=true";
ecDetails.PaymentDetails = paymentDetails;
BillingCodeType billingCodeType = (BillingCodeType)EnumUtils.GetValue("RecurringPayments", typeof(BillingCodeType));
BillingAgreementDetailsType baType = new BillingAgreementDetailsType(billingCodeType);
baType.BillingAgreementDescription = "recurringbilling";
ecDetails.BillingAgreementDetails.Add(baType);
SetExpressCheckoutRequestType request = new SetExpressCheckoutRequestType();
request.Version = "104.0";
request.SetExpressCheckoutRequestDetails = ecDetails;
SetExpressCheckoutReq wrapper = new SetExpressCheckoutReq();
wrapper.SetExpressCheckoutRequest = request;
Dictionary sdkConfig = new Dictionary();
sdkConfig.Add("mode", "sandbox");
sdkConfig.Add("account1.apiUsername", "jb-us-seller_api1.paypal.com");
sdkConfig.Add("account1.apiPassword", "WX4WTU3S8MY44S7F");
sdkConfig.Add("account1.apiSignature", "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy");
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(sdkConfig);
SetExpressCheckoutResponseType setECResponse = service.SetExpressCheckout(wrapper);
Затем вызов в конце возвращает следующую строку:
Код: Выделить всё
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-4SD42613U5111594L
Затем, чтобы создать профиль регулярных платежей, связанный с соглашением о выставлении счетов, который был создан с помощью вызова SetExpressCheckout, выполните вызов API CreateRecurringPaymentsProfile с токеном, полученным в ответе API SetExpressCheckout, и BillingAgreementDescription, используемым в Запрос API SetExpressCheckout.
Код выглядит следующим образом:
Код: Выделить всё
CreateRecurringPaymentsProfileRequestType createRPProfileRequest = new CreateRecurringPaymentsProfileRequestType();
CreateRecurringPaymentsProfileRequestDetailsType createRPProfileRequestDetails = new CreateRecurringPaymentsProfileRequestDetailsType();
createRPProfileRequestDetails.Token = "EC-4SD42613U5111594L";
createRPProfileRequest.CreateRecurringPaymentsProfileRequestDetails = createRPProfileRequestDetails;
RecurringPaymentsProfileDetailsType profileDetails = new RecurringPaymentsProfileDetailsType("2016-010-31T00:00:00:000Z");
profileDetails.RecurringPaymentsProfileDetails = profileDetails;
int frequency = 10;
BasicAmountType paymentAmount = new BasicAmountType((CurrencyCodeType)EnumUtils.GetValue("USD", typeof(CurrencyCodeType)), "1.0");
BillingPeriodType period = (BillingPeriodType)EnumUtils.GetValue("Day", typeof(BillingPeriodType));
BillingPeriodDetailsType paymentPeriod = new BillingPeriodDetailsType(period, frequency, paymentAmount);
ScheduleDetailsType scheduleDetails = new ScheduleDetailsType();
scheduleDetails.Description = "recurringbilling";
scheduleDetails.PaymentPeriod = paymentPeriod;
profileDetails.ScheduleDetails = scheduleDetails;
CreateRecurringPaymentsProfileReq createRPProfileReq = new CreateRecurringPaymentsProfileReq();
createRPProfileReq.CreateRecurringPaymentsProfileRequest = createRPProfileRequest;
Dictionary sdkConfig = new Dictionary();
sdkConfig.Add("mode", "sandbox");
sdkConfig.Add("account1.apiUsername", "jb-us-seller_api1.paypal.com");
sdkConfig.Add("account1.apiPassword", "WX4WTU3S8MY44S7F");
sdkConfig.Add("account1.apiSignature", "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy");
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(sdkConfig);
CreateRecurringPaymentsProfileResponseType createRPProfileResponse = service.CreateRecurringPaymentsProfile(createRPProfileReq);
Код: Выделить всё
PROFILEID=I-0H1CDRF2NEWB&PROFILESTATUS=ActiveProfile&TIMESTAMP=2016-10-31T15:56:13Z&CORRELATIONID=a5fcc91e86a24&ACK=Success&VERSION=104.0&BUILD=24616352
Мой вопрос: как мне управлять подписками на ежемесячной/ежегодной основе (в зависимости от того, как пользователь решит, что он будет платить ежемесячно или ежегодно)?
Я думаю, здесь есть несколько сценариев из:
- Что, если пользователь аннулирует соглашение о выставлении счетов через PayPal? Должен ли я затем проверять статус подписки при каждом входе пользователя?
- Выставление счетов на стороне PayPal, вероятно, производится автоматически, или мне нужно каким-то образом создавать запрос на оплату каждые 1 месяц / 1 год, чтобы взимать с пользователя плату за использование премиальных услуг на моем веб-сайте???
Может ли кто-нибудь мне помочь?>
Подробнее здесь: https://stackoverflow.com/questions/403 ... k-with-net
Мобильная версия