Configuration
For configuration code samples, see our Configuration Code for SDKs article.
Initiate
AlternativePaymentMethod paymentMethod = new AlternativePaymentMethod(AlternativePaymentType.SOFORTUBERWEISUNG);
paymentMethod.setReturnUrl("https://www.example.com/returnUrl");
paymentMethod.setStatusUpdateUrl("https://www.example.com/statusUrl");
paymentMethod.setDescriptor("Test Transaction");
paymentMethod.setCountry("DE");
paymentMethod.setAccountHolderName("James Mason");
try {
Transaction response =
paymentMethod
.charge(10.01)
.withCurrency("EUR")
.execute();
// response-.getAlternativePaymentResponse().getRedirectUrl()
// => the redirectUrl for Step2;
} catch (ApiException e) {
// TODO: Add your error handling here
}
<?php
$paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG);
$paymentMethod->returnUrl = 'https://www.example.com/returnUrl';
$paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl';
$paymentMethod->descriptor = 'Test Transaction';
$paymentMethod->country = 'DE';
$paymentMethod->accountHolderName = 'James Mason';
try {
$response = $paymentMethod->charge(10.01)
->withCurrency("EUR")
->execute();
// $response->alternativePaymentResponse->redirectUrl => the redirectUrl for Step2;
} catch (ApiException $e) {
// TODO: Add your error handling here
}
AlternativePaymentMethod paymentMethod = new AlternativePaymentMethod();
paymentMethod.AlternativePaymentMethodType = AlternativePaymentType.SOFORT;
paymentMethod.ReturnUrl = "https://www.example.com/returnUrl";
paymentMethod.StatusUpdateUrl = "https://www.example.com/statusUrl";
paymentMethod.Descriptor = "Test Transaction";
paymentMethod.Country = "DE";
paymentMethod.AccountHolderName = "James Mason";
try {
Transaction response =
paymentMethod
.Charge(10.01m)
.WithCurrency("EUR")
.Execute();
//response.AlternativePaymentResponse.RedirectUrl;
// => the redirectUrl for Step2;
}
catch (ApiException e)
{
// TODO: Add your error handling here
}
Refund
String transactionId = "TRN_h5AfTNboHCEHcUuR2peRgAi5GKcWna_29b0db7c835f";
Transaction transaction = Transaction.fromId(transactionId, PaymentMethodType.APM);
AlternativePaymentResponse apr = new AlternativePaymentResponse();
apr.setProviderName(AlternativePaymentType.SOFORTUBERWEISUNG.toString());
apr.setProviderReference("SMKGK7K2BLEUA");
transaction.setAlternativePaymentResponse(apr);
try{
Transaction response = transaction.refund(new BigDecimal("10.01"))
.withCurrency("EUR")
.execute();
String responseCode = response.getResponseCode(); // SUCCESS
String message = response.getResponseMessage(); // CAPTURED
}
catch(ApiException e) {
// TODO: Add your error handling here
}
// the transaction id
$transactionId = "TRN_h5AfTNboHCEHcUuR2peRgAi5GKcWna_29b0db7c835f";
// create the rebate transaction object
$transaction = Transaction::fromId($transactionId, null, PaymentMethodType::APM);
$transaction->alternativePaymentResponse = new AlternativePaymentResponse();
$transaction->alternativePaymentResponse->providerName = AlternativePaymentType::SOFORTUBERWEISUNG;
$transaction->alternativePaymentResponse->providerReference = 'SMKGK7K2BLEUA';
try {
$response = $transaction->refund(10.01)
->withCurrency("EUR")
->execute();
$responseCode = $response->responseCode; // SUCCESS
$message = $response->responseMessage; // CAPTURED
} catch (ApiException $e) {
// TODO: Add your error handling here
}
string transactionId = "TRN_h5AfTNboHCEHcUuR2peRgAi5GKcWna_29b0db7c835f";
Transaction transaction = Transaction.FromId(transactionId, PaymentMethodType.APM);
transaction.AlternativePaymentResponse = new AlternativePaymentResponse {
ProviderName = AlternativePaymentType.SOFORTUBERWEISUNG.ToString(),
ProviderReference = "SMKGK7K2BLEUA"
};
try {
Transaction response = transaction.Refund(10.01m)
.WithCurrency("EUR")
.Execute();
String responseCode = response.ResponseCode; // SUCCESS
String message = response.ResponseMessage; // CAPTURED
}
catch (ApiException e) {
// TODO: Add your error handling here
}
Test Pay
JAVA
AlternativePaymentMethod paymentMethod = new AlternativePaymentMethod(AlternativePaymentType.TESTPAY);
paymentMethod.setReturnUrl("https://www.example.com/returnUrl");
paymentMethod.setStatusUpdateUrl("https://www.example.com/statusUrl");
paymentMethod.setDescriptor("Test Transaction");
paymentMethod.setCountry("DE");
paymentMethod.setAccountHolderName("James Mason");
try {
Transaction response =
paymentMethod
.charge(10.01)
.withCurrency("EUR")
.execute();
// $response->alternativePaymentResponse->redirectUrl => the redirectUrl for Step2;
} catch (ApiException $e) {
// TODO: Add your error handling here
}
<?php
$paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::TEST_PAY);
$paymentMethod->returnUrl = 'https://www.example.com/returnUrl';
$paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl';
$paymentMethod->descriptor = 'Test Transaction';
$paymentMethod->country = 'DE';
$paymentMethod->accountHolderName = 'James Mason';
try {
$response = $paymentMethod->charge(10.01)
->withCurrency("EUR")
->execute();
// $response->alternativePaymentResponse->redirectUrl => the redirectUrl for Step2;
} catch (ApiException $e) {
// TODO: Add your error handling here
}
AlternativePaymentMethod paymentMethod = new AlternativePaymentMethod();
paymentMethod.AlternativePaymentMethodType = AlternativePaymentType.TESTPAY;
paymentMethod.ReturnUrl = "https://www.example.com/returnUrl";
paymentMethod.StatusUpdateUrl = "https://www.example.com/statusUrl";
paymentMethod.Descriptor = "Test Transaction";
paymentMethod.Country = "DE";
paymentMethod.AccountHolderName = "James Mason";
try
{
Transaction response =
paymentMethod
.Charge(10.01m)
.WithCurrency("EUR")
.Execute();
//response?.AlternativePaymentResponse.RedirectUrl => the redirectUrl for Step2;
}
catch (ApiException e) {
// TODO: Add your error handling here
}
Internal Title
SDK, GP-API
Show Content Nav
On
Tags