Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion BuckarooSdk.Tests/Services/PayPal/PayPalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,77 @@ public void ExtraInfoTest()
{
//define properties
});


var response = request.Execute();
}

[TestMethod]
public void AuthorizeTest()
{
var request = this._sdkClient.CreateRequest()
.Authenticate(Constants.TestSettings.WebsiteKey, Constants.TestSettings.SecretKey, false, new CultureInfo("nl-NL"))
.TransactionRequest()
.SetBasicFields(new TransactionBase
{
Currency = "EUR",
AmountDebit = 0.02m,
Invoice = $"SDK_TEST_{DateTime.Now.Ticks}",
Description = "PAYPAL_AUTHORIZE_SDK_UNITTEST",
})
.PayPal()
.Authorize(new PayPalAuthorizeRequest()
{
//define properties
BuyerEmail = "techsup@buckaroo.nl",
ProductName = "haardhout",
});

var paymentResponse = request.Execute();
}

[TestMethod]
public void CaptureTest()
{
var request = this._sdkClient.CreateRequest()
.Authenticate(Constants.TestSettings.WebsiteKey, Constants.TestSettings.SecretKey, false, new CultureInfo("nl-NL"))
.TransactionRequest()
.SetBasicFields(new TransactionBase
{
Currency = "EUR",
AmountDebit = 0.02m,
Invoice = $"SDK_TEST_{DateTime.Now.Ticks}",
Description = "PAYPAL_CAPTURE_SDK_UNITTEST",
//OriginalTransactionKey of a successful Authorize transaction is required at runtime
})
.PayPal()
.Capture(new PayPalCaptureRequest()
{
//define properties
});

var response = request.Execute();
}

[TestMethod]
public void CancelAuthorizeTest()
{
var request = this._sdkClient.CreateRequest()
.Authenticate(Constants.TestSettings.WebsiteKey, Constants.TestSettings.SecretKey, false, new CultureInfo("nl-NL"))
.TransactionRequest()
.SetBasicFields(new TransactionBase
{
Currency = "EUR",
AmountDebit = 0.02m,
Invoice = $"SDK_TEST_{DateTime.Now.Ticks}",
Description = "PAYPAL_CANCELAUTHORIZE_SDK_UNITTEST",
//OriginalTransactionKey of a successful Authorize transaction is required at runtime
})
.PayPal()
.CancelAuthorize(new PayPalCancelAuthorizeRequest()
{
//define properties
});

var response = request.Execute();
}
}
Expand Down
10 changes: 10 additions & 0 deletions BuckarooSdk/Services/PayPal/PayPalAuthorizeRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace BuckarooSdk.Services.PayPal
{
public class PayPalAuthorizeRequest
{
public string ProductName { get; set; }
public string BillingAgreementDescription { get; set; }
public string PageStyle { get; set; }
public string BuyerEmail { get; set; }
}
}
18 changes: 18 additions & 0 deletions BuckarooSdk/Services/PayPal/PayPalAuthorizeResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using static BuckarooSdk.Constants.Services;

namespace BuckarooSdk.Services.PayPal
{
public class PayPalAuthorizeResponse : ActionResponse
{
public override ServiceNames ServiceNames => ServiceNames.PayPal;
public string PayerEmail { get; set;}
public string NoteText { get; set; }
public string PayerStatus { get; set; }
public string PayerCountry { get; set; }
public string PayPalTransactionId { get; set; }
public string PayerFirstName { get; set; }
public string PayerMiddleName { get; set; }
public string PayerLastName { get; set; }

}
}
10 changes: 10 additions & 0 deletions BuckarooSdk/Services/PayPal/PayPalCancelAuthorizeRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace BuckarooSdk.Services.PayPal
{
/// <summary>
/// A PayPal CancelAuthorize Request does not have request parameters.
/// The authorization is identified through the basic OriginalTransactionKey field.
/// </summary>
public class PayPalCancelAuthorizeRequest
{
}
}
12 changes: 12 additions & 0 deletions BuckarooSdk/Services/PayPal/PayPalCancelAuthorizeResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using static BuckarooSdk.Constants.Services;

namespace BuckarooSdk.Services.PayPal
{
/// <summary>
/// A PayPal CancelAuthorizeResponse does not have response parameters
/// </summary>
public class PayPalCancelAuthorizeResponse : ActionResponse
{
public override ServiceNames ServiceNames => ServiceNames.PayPal;
}
}
10 changes: 10 additions & 0 deletions BuckarooSdk/Services/PayPal/PayPalCaptureRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace BuckarooSdk.Services.PayPal
{
/// <summary>
/// A PayPal Capture Request does not have request parameters.
/// The authorization is identified through the basic OriginalTransactionKey field.
/// </summary>
public class PayPalCaptureRequest
{
}
}
18 changes: 18 additions & 0 deletions BuckarooSdk/Services/PayPal/PayPalCaptureResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using static BuckarooSdk.Constants.Services;

namespace BuckarooSdk.Services.PayPal
{
public class PayPalCaptureResponse : ActionResponse
{
public override ServiceNames ServiceNames => ServiceNames.PayPal;
public string PayerEmail { get; set;}
public string NoteText { get; set; }
public string PayerStatus { get; set; }
public string PayerCountry { get; set; }
public string PayPalTransactionId { get; set; }
public string PayerFirstName { get; set; }
public string PayerMiddleName { get; set; }
public string PayerLastName { get; set; }

}
}
46 changes: 45 additions & 1 deletion BuckarooSdk/Services/PayPal/PayPalTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ConfiguredServiceTransaction PayRemainder(PayPalPayRemainderRequest reque
return configuredServiceTransaction;
}
/// <summary>
/// The extrainfo function creates a configured transaction with an PayPalExtraInfoRequest request,
/// The extrainfo function creates a configured transaction with an PayPalExtraInfoRequest request,
/// that is ready to be executed.
/// </summary>
/// <param name="request">A PayPalExtraInfoRequest</param>
Expand All @@ -82,6 +82,50 @@ public ConfiguredServiceTransaction ExtraInfo(PayPalExtraInfoRequest request)
var configuredServiceTransaction = new ConfiguredServiceTransaction(this.ConfiguredTransaction.BaseTransaction);
configuredServiceTransaction.BaseTransaction.AddService("PayPal", parameters, "Pay,ExtraInfo", "1");

return configuredServiceTransaction;
}
/// <summary>
/// The authorize function creates a configured transaction with an PayPalAuthorizeRequest request,
/// that is ready to be executed. An Authorize reserves the amount on the payer's account and must
/// later be settled via Capture or released via CancelAuthorize.
/// </summary>
/// <param name="request">A PayPalAuthorizeRequest</param>
/// <returns></returns>
public ConfiguredServiceTransaction Authorize(PayPalAuthorizeRequest request)
{
var parameters = ServiceHelper.CreateServiceParameters(request);
var configuredServiceTransaction = new ConfiguredServiceTransaction(this.ConfiguredTransaction.BaseTransaction);
configuredServiceTransaction.BaseTransaction.AddService("PayPal", parameters, "authorize", "1");

return configuredServiceTransaction;
}
/// <summary>
/// The capture function creates a configured transaction with an PayPalCaptureRequest request,
/// that is ready to be executed. Captures the funds from a previously created authorization,
/// identified by the basic OriginalTransactionKey field.
/// </summary>
/// <param name="request">A PayPalCaptureRequest</param>
/// <returns></returns>
public ConfiguredServiceTransaction Capture(PayPalCaptureRequest request)
{
var parameters = ServiceHelper.CreateServiceParameters(request);
var configuredServiceTransaction = new ConfiguredServiceTransaction(this.ConfiguredTransaction.BaseTransaction);
configuredServiceTransaction.BaseTransaction.AddService("PayPal", parameters, "capture", "1");

return configuredServiceTransaction;
}
/// <summary>
/// The cancelauthorize function creates a configured transaction with an PayPalCancelAuthorizeRequest request,
/// that is ready to be executed. Voids a previously created authorization, identified by the
/// basic OriginalTransactionKey field, releasing the reserved funds back to the payer.
/// </summary>
/// <param name="request">A PayPalCancelAuthorizeRequest</param>
/// <returns></returns>
public ConfiguredServiceTransaction CancelAuthorize(PayPalCancelAuthorizeRequest request)
{
var configuredServiceTransaction = new ConfiguredServiceTransaction(this.ConfiguredTransaction.BaseTransaction);
configuredServiceTransaction.BaseTransaction.AddService("PayPal", null, "cancelauthorize", "1");

return configuredServiceTransaction;
}
}
Expand Down
17 changes: 17 additions & 0 deletions BuckarooSdk/Services/PayPal/Push/PayPalAuthorizePush.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using static BuckarooSdk.Constants.Services;

namespace BuckarooSdk.Services.PayPal.Push
{
public class PayPalAuthorizePush : ActionPush
{
public override ServiceNames ServiceNames => ServiceNames.PayPal;

public string PayerStatus { get; set; }
public string NoteText { get; set; }
public string PayerEmail { get; set; }
public string PayerCountry { get; set; }
public string PayerFirstName { get; set; }
public string PayerLastName { get; set; }
public string PayerTransactionId { get; set; }
}
}
9 changes: 9 additions & 0 deletions BuckarooSdk/Services/PayPal/Push/PayPalCancelAuthorizePush.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using static BuckarooSdk.Constants.Services;

namespace BuckarooSdk.Services.PayPal.Push
{
public class PayPalCancelAuthorizePush : ActionPush
{
public override ServiceNames ServiceNames => ServiceNames.PayPal;
}
}
17 changes: 17 additions & 0 deletions BuckarooSdk/Services/PayPal/Push/PayPalCapturePush.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using static BuckarooSdk.Constants.Services;

namespace BuckarooSdk.Services.PayPal.Push
{
public class PayPalCapturePush : ActionPush
{
public override ServiceNames ServiceNames => ServiceNames.PayPal;

public string PayerStatus { get; set; }
public string NoteText { get; set; }
public string PayerEmail { get; set; }
public string PayerCountry { get; set; }
public string PayerFirstName { get; set; }
public string PayerLastName { get; set; }
public string PayerTransactionId { get; set; }
}
}