/// <summary> /// Processes the Authorize and AuthorizeAndCapture transactions /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to be paid</param> /// <param name="payment">The <see cref="IPayment"/> record</param> /// <param name="args"></param> /// <returns>The <see cref="IPaymentResult"/></returns> public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, ProcessorArgumentCollection args) { var setExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType { ReturnURL = String.Format("{0}/App_Plugins/Merchello.PayPal/PayPalExpressCheckout.html?InvoiceKey={1}&PaymentKey={2}&PaymentMethodKey={3}", GetWebsiteUrl(), invoice.Key, payment.Key, payment.PaymentMethodKey), CancelURL = "http://localhost/cancel", PaymentDetails = new List <PaymentDetailsType> { GetPaymentDetails(invoice) } }; var setExpressCheckout = new SetExpressCheckoutReq(); var setExpressCheckoutRequest = new SetExpressCheckoutRequestType(setExpressCheckoutRequestDetails); setExpressCheckout.SetExpressCheckoutRequest = setExpressCheckoutRequest; var config = new Dictionary <string, string> { { "mode", "sandbox" }, { "account1.apiUsername", _settings.ApiUsername }, { "account1.apiPassword", _settings.ApiPassword }, { "account1.apiSignature", _settings.ApiSignature } }; var service = new PayPalAPIInterfaceServiceService(config); var responseSetExpressCheckoutResponseType = service.SetExpressCheckout(setExpressCheckout); // If this were using a service we might want to store some of the transaction data in the ExtendedData for record payment.ExtendedData.SetValue("RedirectUrl", "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + responseSetExpressCheckoutResponseType.Token); return(new PaymentResult(Attempt <IPayment> .Succeed(payment), invoice, false)); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, DoDirectPaymentResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "DoDirectPayment"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary <string, string> responseParams = new Dictionary <string, string>(); responseParams.Add("Correlation Id", response.CorrelationID); responseParams.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Transaction Id", response.TransactionID); responseParams.Add("Payment status", response.PaymentStatus.ToString()); if (response.PendingReason != null) { responseParams.Add("Pending reason", response.PendingReason.ToString()); } } CurrContext.Items.Add("Response_keyResponseObject", responseParams); Server.Transfer("../APIResponse.aspx"); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, BillOutstandingAmountResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "BillOutstandingAmount"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary <string, string> keyResponseParameters = new Dictionary <string, string>(); keyResponseParameters.Add("Correlation Id", response.CorrelationID); keyResponseParameters.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); keyResponseParameters.Add("Profile ID", response.BillOutstandingAmountResponseDetails.ProfileID); } CurrContext.Items.Add("Response_keyResponseObject", keyResponseParameters); Server.Transfer("../APIResponse.aspx"); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, BAUpdateResponseType response) { Dictionary <string, string> keyResponseParameters = new Dictionary <string, string>(); keyResponseParameters.Add("API Status", response.Ack.ToString()); HttpContext CurrContext = HttpContext.Current; if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); keyResponseParameters.Add("Billing Agreement Status", response.BAUpdateResponseDetails.BillingAgreementStatus.ToString()); keyResponseParameters.Add("Billing Agreement description", response.BAUpdateResponseDetails.BillingAgreementDescription); } CurrContext.Items.Add("Response_keyResponseObject", keyResponseParameters); CurrContext.Items.Add("Response_apiName", "BillAgreementUpdate"); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); CurrContext.Items.Add("Response_redirectURL", null); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object ReverseTransactionRequestType request = new ReverseTransactionRequestType(); request.ReverseTransactionRequestDetails = new ReverseTransactionRequestDetailsType(); request.ReverseTransactionRequestDetails.TransactionID = transactionID.Value; // Invoke the API ReverseTransactionReq wrapper = new ReverseTransactionReq(); wrapper.ReverseTransactionRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the ReverseTransaction method in service wrapper object ReverseTransactionResponseType ReverseTransactionResponse = service.ReverseTransaction(wrapper); // Check for API return status setKeyResponseObjects(service, ReverseTransactionResponse); }
public ActionResult GetExpressCheckout(string token, string orderId) { var config = ConfigManager.Instance.GetProperties(); var service = new PayPalAPIInterfaceServiceService(config); var request = new GetExpressCheckoutDetailsReq { GetExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType { Token = token } }; var response = service.GetExpressCheckoutDetails(request); if (response.Ack.ToString().Trim().ToUpper().Equals(AckCodeType.SUCCESS.ToString())) { _orderService = new OrderService(); var isMarked = _orderService.MarkOrderAsPaid(orderId); // TODO process this exception if (!isMarked) { throw new Exception("Order was not marked as paid"); } return(SuccessTransaction()); } return(ErrorTransaction()); }
private void processResponse(PayPalAPIInterfaceServiceService service, EnterBoardingResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "EnterBoarding"); if (response.Token != null) { string baseUrl = ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"].ToString().ToLower(); CurrContext.Items.Add("Response_redirectURL", baseUrl + "_partner-onboard-flow&onboarding_token=" + response.Token); } CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary <string, string> keyParameters = new Dictionary <string, string>(); keyParameters.Add("Correlation Id", response.CorrelationID); keyParameters.Add("API Result", response.Ack.ToString()); if (response.Errors != null && response.Errors.Count > 0) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); } if (!response.Ack.Equals(AckCodeType.FAILURE)) { } CurrContext.Items.Add("Response_keyResponseObject", keyParameters); Server.Transfer("../APIResponse.aspx"); }
// A helper method used by APIResponse.aspx that returns select response parameters // of interest. private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, SetExpressCheckoutResponseType setECResponse) { Dictionary <string, string> keyResponseParameters = new Dictionary <string, string>(); keyResponseParameters.Add("API Status", setECResponse.Ack.ToString()); HttpContext CurrContext = HttpContext.Current; if (setECResponse.Ack.Equals(AckCodeType.FAILURE) || (setECResponse.Errors != null && setECResponse.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", setECResponse.Errors); CurrContext.Items.Add("Response_redirectURL", null); } else { CurrContext.Items.Add("Response_error", null); keyResponseParameters.Add("EC token", setECResponse.Token); CurrContext.Items.Add("Response_redirectURL", ConfigManager.Instance.GetProperty("paypalUrl") + "_express-checkout&token=" + setECResponse.Token); } CurrContext.Items.Add("Response_keyResponseObject", keyResponseParameters); CurrContext.Items.Add("Response_apiName", "SetExpressCheckout"); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Server.Transfer("../APIResponse.aspx"); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, BMGetButtonDetailsResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "BMGetButtonDetails"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary <string, string> responseParams = new Dictionary <string, string>(); responseParams.Add("Correlation Id", response.CorrelationID); responseParams.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Button type", response.ButtonType.ToString()); responseParams.Add("Button code", response.ButtonCode.ToString()); for (int i = 0; i < response.ButtonVar.Count; i++) { responseParams.Add("Button var " + (i + 1), response.ButtonVar[i]); } } CurrContext.Items.Add("Response_keyResponseObject", responseParams); Server.Transfer("../APIResponse.aspx"); }
protected void Search_Submit(object sender, EventArgs e) { // Create request object GetTransactionDetailsRequestType request = new GetTransactionDetailsRequestType(); // (Required) Unique identifier of a transaction. // Note: The details for some kinds of transactions cannot be retrieved with GetTransactionDetails. You cannot obtain details of bank transfer withdrawals, for example. request.TransactionID = transactionId.Value; // Invoke the API GetTransactionDetailsReq wrapper = new GetTransactionDetailsReq(); wrapper.GetTransactionDetailsRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the GetTransactionDetails method in service wrapper object GetTransactionDetailsResponseType transactionDetails = service.GetTransactionDetails(wrapper); // Check for API return status processResponse(service, transactionDetails); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object CreateBillingAgreementRequestType request = new CreateBillingAgreementRequestType(); // (Required) The time-stamped token returned in the SetCustomerBillingAgreement response. // Note: The token expires after 3 hours. request.Token = token.Value; // Invoke the API CreateBillingAgreementReq wrapper = new CreateBillingAgreementReq(); wrapper.CreateBillingAgreementRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the CreateBillingAgreement method in service wrapper object CreateBillingAgreementResponseType billingAgreementResponse = service.CreateBillingAgreement(wrapper); // Check for API return status setKeyResponseObjects(service, billingAgreementResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object GetRecurringPaymentsProfileDetailsRequestType request = new GetRecurringPaymentsProfileDetailsRequestType(); // Required) Recurring payments profile ID returned in the CreateRecurringPaymentsProfile response. 19-character profile IDs are supported for compatibility with previous versions of the PayPal API. request.ProfileID = profileId.Value; // Invoke the API GetRecurringPaymentsProfileDetailsReq wrapper = new GetRecurringPaymentsProfileDetailsReq(); wrapper.GetRecurringPaymentsProfileDetailsRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the GetRecurringPaymentsProfileDetails method in service wrapper object GetRecurringPaymentsProfileDetailsResponseType recurringPaymentsProfileDetailsResponse = service.GetRecurringPaymentsProfileDetails(wrapper); // Check for API return status setKeyResponseObjects(service, recurringPaymentsProfileDetailsResponse); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, ManagePendingTransactionStatusResponseType response) { Dictionary <string, string> responseParams = new Dictionary <string, string>(); HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_keyResponseObject", responseParams); CurrContext.Items.Add("Response_apiName", "ManagePendingTransactionStatus"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Transaction Id", response.TransactionID); responseParams.Add("Status", response.Status); } Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object BAUpdateRequestType request = new BAUpdateRequestType(); request.ReferenceID = referenceId.Value; if (billingAgreementStatus.SelectedIndex != 0) { request.BillingAgreementStatus = (MerchantPullStatusCodeType) Enum.Parse(typeof(MerchantPullStatusCodeType), billingAgreementStatus.SelectedValue); } if (billingAgreementText.Value != "") { request.BillingAgreementDescription = billingAgreementText.Value; } // Invoke the API BillAgreementUpdateReq wrapper = new BillAgreementUpdateReq(); wrapper.BAUpdateRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); BAUpdateResponseType billingAgreementResponse = service.BillAgreementUpdate(wrapper); // Check for API return status setKeyResponseObjects(service, billingAgreementResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object DoAuthorizationRequestType request = new DoAuthorizationRequestType(); request.TransactionID = transactionId.Value; CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); request.Amount = new BasicAmountType(currency, amount.Value); // Invoke the API DoAuthorizationReq wrapper = new DoAuthorizationReq(); wrapper.DoAuthorizationRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); DoAuthorizationResponseType doAuthorizationResponse = service.DoAuthorization(wrapper); // Check for API return status setKeyResponseObjects(service, doAuthorizationResponse); }
protected void Submit_Click(object sender, EventArgs e) { PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); GetExpressCheckoutDetailsReq getECWrapper = new GetExpressCheckoutDetailsReq(); getECWrapper.GetExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType(token.Value); GetExpressCheckoutDetailsResponseType getECResponse = service.GetExpressCheckoutDetails(getECWrapper); // Create request object DoExpressCheckoutPaymentRequestType request = new DoExpressCheckoutPaymentRequestType(); DoExpressCheckoutPaymentRequestDetailsType requestDetails = new DoExpressCheckoutPaymentRequestDetailsType(); request.DoExpressCheckoutPaymentRequestDetails = requestDetails; requestDetails.PaymentDetails = getECResponse.GetExpressCheckoutDetailsResponseDetails.PaymentDetails; requestDetails.Token = token.Value; requestDetails.PayerID = payerId.Value; requestDetails.PaymentAction = (PaymentActionCodeType) Enum.Parse(typeof(PaymentActionCodeType), paymentAction.SelectedValue); // Invoke the API DoExpressCheckoutPaymentReq wrapper = new DoExpressCheckoutPaymentReq(); wrapper.DoExpressCheckoutPaymentRequest = request; DoExpressCheckoutPaymentResponseType doECResponse = service.DoExpressCheckoutPayment(wrapper); // Check for API return status setKeyResponseObjects(service, doECResponse); }
// GET: PayPal public ActionResult PayPalCreateRequest(string orderId) { var config = ConfigManager.Instance.GetProperties(); var service = new PayPalAPIInterfaceServiceService(config); var setExpressCheckoutRequestType = new SetExpressCheckoutRequestType { SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType() { OrderTotal = new BasicAmountType(CurrencyCodeType.USD, "20"), CancelURL = GlobalSettings.PayPalSettings.PayPalCancelUrl, ReturnURL = GlobalSettings.PayPalSettings.PayPalReturnUrl + "/?orderId=" + orderId, } }; var request = new SetExpressCheckoutReq { SetExpressCheckoutRequest = setExpressCheckoutRequestType }; var response = service.SetExpressCheckout(request); if (!response.Ack.ToString().Trim().ToUpper().Equals(AckCodeType.FAILURE.ToString()) && !response.Ack.ToString().Trim().ToUpper().Equals(AckCodeType.FAILUREWITHWARNING.ToString())) { var redirectUrl = GlobalSettings.PayPalSettings.PayPalRedirectUrl + "_express-checkout&token=" + response.Token; return(Redirect(redirectUrl)); } return(ErrorTransaction()); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, GetRecurringPaymentsProfileDetailsResponseType response) { Dictionary <string, string> responseParams = new Dictionary <string, string>(); responseParams.Add("API Status", response.Ack.ToString()); HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_redirectURL", null); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); GetRecurringPaymentsProfileDetailsResponseDetailsType profileDetails = response.GetRecurringPaymentsProfileDetailsResponseDetails; responseParams.Add("Profile description", profileDetails.Description); responseParams.Add("Profile status", profileDetails.ProfileStatus.ToString()); responseParams.Add("Subscriber name", profileDetails.RecurringPaymentsProfileDetails.SubscriberName); responseParams.Add("Billing start date", profileDetails.RecurringPaymentsProfileDetails.BillingStartDate); responseParams.Add("Next billing date", profileDetails.RecurringPaymentsSummary.NextBillingDate); responseParams.Add("Payment amount", profileDetails.RegularRecurringPaymentsPeriod.Amount.value + profileDetails.RegularRecurringPaymentsPeriod.Amount.currencyID.ToString()); } CurrContext.Items.Add("Response_keyResponseObject", responseParams); CurrContext.Items.Add("Response_apiName", "GetRecurringPaymentsProfileDetails"); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object EnterBoardingRequestType request = new EnterBoardingRequestType(); EnterBoardingRequestDetailsType boardingDetails = new EnterBoardingRequestDetailsType(); boardingDetails.ProductList = productList.Value; boardingDetails.ProgramCode = programCode.Value; boardingDetails.ImageUrl = imageUrl.Value; request.EnterBoardingRequestDetails = boardingDetails; // Invoke the API EnterBoardingReq wrapper = new EnterBoardingReq(); wrapper.EnterBoardingRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); EnterBoardingResponseType enterBoardingResponse = service.EnterBoarding(wrapper); // Check for API return status processResponse(service, enterBoardingResponse); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, BillUserResponseType response) { Dictionary <string, string> responseParams = new Dictionary <string, string>(); HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_keyResponseObject", responseParams); CurrContext.Items.Add("Response_apiName", "BillUser"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Transaction Id", response.BillUserResponseDetails.PaymentInfo.TransactionID); responseParams.Add("Gross amount", response.BillUserResponseDetails.PaymentInfo.GrossAmount.value + response.BillUserResponseDetails.PaymentInfo.GrossAmount.currencyID); responseParams.Add("Fees amount", response.BillUserResponseDetails.PaymentInfo.FeeAmount.value + response.BillUserResponseDetails.PaymentInfo.FeeAmount.currencyID); } Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object // GetPalDetails does not require you to pass any data other than your credentials GetPalDetailsRequestType request = new GetPalDetailsRequestType(); // Invoke the API GetPalDetailsReq wrapper = new GetPalDetailsReq(); wrapper.GetPalDetailsRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the GetPalDetails method in service wrapper object GetPalDetailsResponseType palDetails = service.GetPalDetails(wrapper); // Check for API return status setKeyResponseParams(service, palDetails); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object DoUATPAuthorizationRequestType request = new DoUATPAuthorizationRequestType(); request.UATPDetails = new UATPDetailsType(); request.UATPDetails.UATPNumber = uatpNumber.Value; request.UATPDetails.ExpMonth = Int32.Parse(expMonth.Value); request.UATPDetails.ExpYear = Int32.Parse(expYear.Value); request.TransactionEntity = (TransactionEntityType) Enum.Parse(typeof(TransactionEntityType), transactionEntity.SelectedValue); CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyID.Value); request.Amount = new BasicAmountType(currency, amount.Value); // Invoke the API DoUATPAuthorizationReq wrapper = new DoUATPAuthorizationReq(); wrapper.DoUATPAuthorizationRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); DoUATPAuthorizationResponseType response = service.DoUATPAuthorization(wrapper); // Check for API return status setKeyResponseObjects(service, response); }
public override RefundProcessPaymentResult RefundProcessPayment(RefundProcessPaymentEvaluationContext context) { if (context == null || context.Payment == null) { throw new ArgumentNullException("paymentEvaluationContext"); } RefundProcessPaymentResult retVal = new RefundProcessPaymentResult(); if (context.Payment.IsApproved && (context.Payment.PaymentStatus == PaymentStatus.Paid || context.Payment.PaymentStatus == PaymentStatus.Cancelled)) { try { var config = GetConfigMap(); var service = new PayPalAPIInterfaceServiceService(config); RefundTransactionReq refundTransctionRequest = GetRefundTransactionRequest(context.Payment); service.RefundTransaction(refundTransctionRequest); } catch (Exception ex) { retVal.ErrorMessage = ex.Message; } } return(new RefundProcessPaymentResult { ErrorMessage = "Not implemented yet" }); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object BMManageButtonStatusRequestType request = new BMManageButtonStatusRequestType(); // (Required) The ID of the hosted button whose status you want to change. request.HostedButtonID = hostedID.Value; //(Required) The new status of the button. It is one of the following values: //DELETE - the button is deleted from PayPal request.ButtonStatus = (ButtonStatusType) Enum.Parse(typeof(ButtonStatusType), buttonStatus.SelectedValue); // Invoke the API BMManageButtonStatusReq wrapper = new BMManageButtonStatusReq(); wrapper.BMManageButtonStatusRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // (https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters) Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Creating service wrapper object to make an API call by loading configuration map. PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); BMManageButtonStatusResponseType response = service.BMManageButtonStatus(wrapper); // Check for API return status setKeyResponseObjects(service, response); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object GetBalanceRequestType request = new GetBalanceRequestType(); // (Optional) Indicates whether to return all currencies. It is one of the following values: // * 0 – Return only the balance for the primary currency holding. // * 1 – Return the balance for each currency holding. // Note: This field is available since version 51. Prior versions return only the balance for the primary currency holding. request.ReturnAllCurrencies = returnAllCurrencies.SelectedValue; // Invoke the API GetBalanceReq wrapper = new GetBalanceReq(); wrapper.GetBalanceRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the GetBalance method in service wrapper object GetBalanceResponseType getBalanceResponse = service.GetBalance(wrapper); // Check for API return status processResponse(service, getBalanceResponse); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, BMManageButtonStatusResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "BMManageButtonStatus"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary <string, string> responseParams = new Dictionary <string, string>(); // Correlation ID; it is used only by Developer Technical Support. // Note: // You must log and store this data for every response you receive. // PayPal Technical Support uses the information to assist with reported issues. responseParams.Add("Correlation Id", response.CorrelationID); responseParams.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); } CurrContext.Items.Add("Response_keyResponseObject", responseParams); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object BillOutstandingAmountRequestType request = new BillOutstandingAmountRequestType(); BillOutstandingAmountRequestDetailsType details = new BillOutstandingAmountRequestDetailsType(); request.BillOutstandingAmountRequestDetails = details; details.ProfileID = profileId.Value; if (currencyCode.SelectedIndex != 0 && amount.Value != "") { CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); details.Amount = new BasicAmountType(currency, amount.Value); } if (note.Value != "") { details.Note = note.Value; } // Invoke the API BillOutstandingAmountReq wrapper = new BillOutstandingAmountReq(); wrapper.BillOutstandingAmountRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); BillOutstandingAmountResponseType response = service.BillOutstandingAmount(wrapper); // Check for API return status setKeyResponseObjects(service, response); }
private void processResponse(PayPalAPIInterfaceServiceService service, GetBoardingDetailsResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "GetBoardingDetails"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary <string, string> keyParameters = new Dictionary <string, string>(); keyParameters.Add("Correlation Id", response.CorrelationID); keyParameters.Add("API Result", response.Ack.ToString()); if (response.Errors != null && response.Errors.Count > 0) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); } if (!response.Ack.Equals(AckCodeType.FAILURE)) { } CurrContext.Items.Add("Response_keyResponseObject", keyParameters); Server.Transfer("../APIResponse.aspx"); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, DoVoidResponseType doVoidResponse) { Dictionary <string, string> responseParams = new Dictionary <string, string>(); HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_keyResponseObject", responseParams); CurrContext.Items.Add("Response_apiName", "DoVoid"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); if (doVoidResponse.Ack.Equals(AckCodeType.FAILURE) || (doVoidResponse.Errors != null && doVoidResponse.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", doVoidResponse.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Authorization Id", doVoidResponse.AuthorizationID); //Selenium Test Case responseParams.Add("Acknowledgement", doVoidResponse.Ack.ToString()); } Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object UpdateRecurringPaymentsProfileRequestType request = new UpdateRecurringPaymentsProfileRequestType(); populateRequestObject(request); // Invoke the API UpdateRecurringPaymentsProfileReq wrapper = new UpdateRecurringPaymentsProfileReq(); wrapper.UpdateRecurringPaymentsProfileRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the UpdateRecurringPaymentsProfile method in service wrapper object UpdateRecurringPaymentsProfileResponseType updateRPProfileResponse = service.UpdateRecurringPaymentsProfile(wrapper); // Check for API return status setKeyResponseObjects(service, updateRPProfileResponse); }