-
-
- This payment type is available for Apple devices only. -
- Please refer to this page to learn all about the requirements for Apple Pay. -
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index d1643e6ce..a53af848f 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -51,4 +51,3 @@ jobs: report_paths: 'test-results/junit.xml' check_name: 'Integration Test Report' detailed_summary: true - fail_on_failure: true diff --git a/examples/Alipay/Constants.php b/examples/Alipay/Constants.php deleted file mode 100755 index a901fd7ee..000000000 --- a/examples/Alipay/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge to get the redirectUrl. - $charge = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $charge->getPaymentId(); - $_SESSION['ShortId'] = $charge->getShortId(); - - // Redirect to the Alipay page - if (!$charge->isError() && $charge->getRedirectUrl() !== null) { - redirect($charge->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Alipay/index.php b/examples/Alipay/index.php deleted file mode 100755 index 36a472e72..000000000 --- a/examples/Alipay/index.php +++ /dev/null @@ -1,77 +0,0 @@ - - - - -
- -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/Applepay/Constants.php b/examples/Applepay/Constants.php deleted file mode 100644 index 41f758055..000000000 --- a/examples/Applepay/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -typeId; -$transactionType = $jsonData->transaction_type ?? 'authorize'; - -// You will need the id of the payment type created in the frontend (index.php) -if (empty($paymentTypeId)) { - echo json_encode(['result' => false]); - return; -} - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create an Unzer object using your private key and register a debug handler if you want to. - $unzer = new Unzer(UNZER_PAPI_PRIVATE_KEY); - $unzer->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - switch ($transactionType) { - case 'charge': - $transaction = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL); - break; - default: - $transaction = $unzer->authorize(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL); - break; - } - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - if ($transaction->isSuccess()) { - echo json_encode(['transactionStatus' => 'success']); - return; - } - if ($transaction->isPending()) { - echo json_encode(['transactionStatus' => 'pending']); - return; - } -} catch (UnzerApiException $e) { - $_SESSION['merchantMessage'] = $e->getMerchantMessage(); - $_SESSION['clientMessage'] = $e->getClientMessage(); -} catch (RuntimeException $e) { - $_SESSION['merchantMessage'] = $e->getMessage(); -} - -echo json_encode(['transactionStatus' => 'error']); diff --git a/examples/Applepay/index.php b/examples/Applepay/index.php deleted file mode 100644 index 2765c13cb..000000000 --- a/examples/Applepay/index.php +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/Applepay/merchantvalidation.php b/examples/Applepay/merchantvalidation.php deleted file mode 100644 index fb3beb43b..000000000 --- a/examples/Applepay/merchantvalidation.php +++ /dev/null @@ -1,65 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - /* - * Just for demonstration purpose. - * It is NOT RECOMMENDED to get get the domain name this way on a production environment, because of security reasons. - */ - $domainName = $_SERVER['HTTP_HOST']; - - $applepaySession = new ApplepaySession(UNZER_EXAMPLE_APPLEPAY_MERCHANT_IDENTIFIER, 'PHP-SDK Example', $domainName); - $appleAdapter = new ApplepayAdapter(); - - $appleAdapter->init(UNZER_EXAMPLE_APPLEPAY_MERCHANT_CERT, UNZER_EXAMPLE_APPLEPAY_MERCHANT_CERT_KEY); - - // Send the applepay validation request. - $validationResponse = $appleAdapter->validateApplePayMerchant($merchantValidationURL, $applepaySession); - - // Return the validation response to your frontend. - print_r($validationResponse, 0); -} catch (RuntimeException | ApplepayMerchantValidationException $e) { - // Dont give internal error directly to the frontend. - throw new Exception('There has been an error validating the merchant. Please try again later.'); -} diff --git a/examples/Backend/CancelPaymentController.php b/examples/Backend/CancelPaymentController.php deleted file mode 100644 index f2a7e07ea..000000000 --- a/examples/Backend/CancelPaymentController.php +++ /dev/null @@ -1,80 +0,0 @@ -fetchPayment($paymentId); - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create an Unzer object using your private key and register a debug handler if you want to. - $unzer = new Unzer(UNZER_PAPI_PRIVATE_KEY); - $unzer->setDebugMode(true)->setDebugHandler($debugHandler); - - if ($payment->isCompleted()) { - $transaction = $unzer->cancelChargedPayment($paymentId); - $_SESSION['additionalPaymentInformation'] = 'Refund was successful.
'; - } else { - $transaction = $unzer->cancelAuthorizedPayment($paymentId); - $_SESSION['additionalPaymentInformation'] = 'Reversal was successful.
'; - } - - // You'll need to remember the paymentId for later in the ReturnController (in case of 3ds) - $_SESSION['ShortId'] = $transaction->getShortId(); - unset($_SESSION['isAuthorizeTransaction']); - - // Redirect to the failure page or to success depending on the state of the transaction - $redirect = !empty($transaction->getRedirectUrl()); - if (!$redirect && $transaction->isSuccess()) { - redirect(BACKEND_URL); - } elseif ($redirect && $transaction->isPending()) { - redirect(BACKEND_FAILURE_URL, 'Transaction initiated by merchant should not redirect to 3ds Page. The customer needs to - do the 3ds authentication first for that payment type.'); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(BACKEND_FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Backend/ChargePaymentController.php b/examples/Backend/ChargePaymentController.php deleted file mode 100644 index c2727a337..000000000 --- a/examples/Backend/ChargePaymentController.php +++ /dev/null @@ -1,73 +0,0 @@ -setDebugMode(true)->setDebugHandler($debugHandler); - - $transaction = $unzer->performChargeOnPayment($paymentId, new Charge()); - - // You'll need to remember the paymentId for later in the ReturnController (in case of 3ds) - $_SESSION['ShortId'] = $transaction->getShortId(); - unset($_SESSION['isAuthorizeTransaction']); - - // Redirect to the failure page or to success depending on the state of the transaction - $redirect = !empty($transaction->getRedirectUrl()); - if (!$redirect && $transaction->isSuccess()) { - $_SESSION['additionalPaymentInformation'] = 'Charge was successful.
'; - redirect(BACKEND_URL); - } elseif ($redirect && $transaction->isPending()) { - redirect(BACKEND_FAILURE_URL, 'Transaction initiated by merchant should not redirect to 3ds Page. The customer needs to - do the 3ds authentication first for that payment type.'); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(BACKEND_FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Backend/Failure.php b/examples/Backend/Failure.php deleted file mode 100644 index c28d75a6e..000000000 --- a/examples/Backend/Failure.php +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - -- There has been an error performing the transaction - Merchant message (don\'t show this to the customer): ' . $_SESSION['merchantMessage'] . '
'; - } - if (isset($_SESSION['clientMessage']) && !empty($_SESSION['clientMessage'])) { - echo 'Client message (this is the error message for the customer): ' . $_SESSION['clientMessage'] . '
'; - } - if (isset($_SESSION['ShortId']) && !empty($_SESSION['ShortId'])) { - echo 'Please look for ShortId ' . $_SESSION['ShortId'] . ' in Unzer Insights to see the transaction.
'; - } - if (isset($_SESSION['PaymentId']) && !empty($_SESSION['PaymentId'])) { - echo 'The PaymentId of your transaction is \'' . $_SESSION['PaymentId'] . '\'.
'; - } - echo 'Back to Manage Payment page.
'; - ?> - - start again -The PaymentId of your transaction is \'' . $paymentId . '\'.
'; - } - - $unzer = new \UnzerSDK\Unzer(UNZER_PAPI_PRIVATE_KEY); - $payment = $unzer->fetchPayment($paymentId); - if ($shortId !== null) { - $defaultTransactionMessage = 'Please look for ShortId ' . $shortId . ' in Unzer Insights to see the transaction.
'; - $paylaterTransactionMessage = 'Please use the "descriptor" to look for the transaction in the Unzer Pay Later Merchant Portal.
'; - echo preg_match('/[\d]{4}.[\d]{4}.[\d]{4}/', $shortId) ? $defaultTransactionMessage : $paylaterTransactionMessage; - } - - if ($payment->getAmount()->getRemaining() > 0 && $payment->getAuthorization() !== null) { - echo 'You can use the payment ID to charge the payment.
-You can use the payment ID to cancel the payment.
-You can finalize a transaction in resumed state.
-Updating(PATCH) transaction was successful.
'; - redirect(BACKEND_URL); - } elseif ($redirect && $transaction->isPending()) { - redirect(BACKEND_FAILURE_URL, 'Transaction initiated by merchant should not redirect to 3ds Page. The customer needs to - do the 3ds authentication first for that payment type.'); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(BACKEND_FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Bancontact/Constants.php b/examples/Bancontact/Constants.php deleted file mode 100644 index c8bfd87ea..000000000 --- a/examples/Bancontact/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge transaction to get the redirectUrl. - $transaction = $unzer->charge(12.32, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the Bancontact page - if (!$transaction->isError() && $transaction->getRedirectUrl() !== null) { - redirect($transaction->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Bancontact/index.php b/examples/Bancontact/index.php deleted file mode 100644 index 28700cefb..000000000 --- a/examples/Bancontact/index.php +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/BankTransfer/Constants.php b/examples/BankTransfer/Constants.php deleted file mode 100644 index 92b31bb1d..000000000 --- a/examples/BankTransfer/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge transaction to get the redirectUrl. - $transaction = $unzer->charge(12.32, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the Sofort page - if (!$transaction->isError() && $transaction->getRedirectUrl() !== null) { - redirect($transaction->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/BankTransfer/index.php b/examples/BankTransfer/index.php deleted file mode 100644 index 5d173b450..000000000 --- a/examples/BankTransfer/index.php +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/Card/Constants.php b/examples/Card/Constants.php deleted file mode 100644 index f499e1c00..000000000 --- a/examples/Card/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge/authorize transaction - // The 3D secured flag can be used to switch between 3ds and non-3ds. - // If your merchant is only configured for one of those you can omit the flag. - $customer = CustomerFactory::createCustomer('Max', 'Mustermann'); - $customer->setEmail('test@test.com'); - - switch ($transactionType) { - case 'charge': - $transaction = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, $use3Ds); - break; - case 'payout': - $transaction = $unzer->payout(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer); - break; - default: - $transaction = $unzer->authorize(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, $use3Ds); - break; - } - - // You'll need to remember the paymentId for later in the ReturnController (in case of 3ds) - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the 3ds page or to success depending on the state of the transaction - $payment = $transaction->getPayment(); - $redirect = !empty($transaction->getRedirectUrl()); - - switch (true) { - case (!$redirect && $transaction->isSuccess()): - redirect(SUCCESS_URL); - break; - case (!$redirect && $transaction->isPending()): - redirect(PENDING_URL); - break; - case ($redirect && $transaction->isPending()): - redirect($transaction->getRedirectUrl()); - break; - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Card/index.php b/examples/Card/index.php deleted file mode 100644 index 87cb6c0b7..000000000 --- a/examples/Card/index.php +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/CardExtended/Constants.php b/examples/CardExtended/Constants.php deleted file mode 100644 index cd7efd897..000000000 --- a/examples/CardExtended/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge/authorize transaction - // For 3Ds2 compliance an email need to be set either in card type or in customer resource. - // If your merchant is only configured for one of those you can omit the flag. - $customer = CustomerFactory::createCustomer('Max', 'Mustermann'); - switch ($transactionType) { - case 'charge': - $transaction = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, true); - break; - case 'payout': - $transaction = $unzer->payout(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer); - break; - default: - $transaction = $unzer->authorize(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, true); - break; - } - - // You'll need to remember the paymentId for later in the ReturnController (in case of 3ds) - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the 3ds page or to success depending on the state of the transaction - $payment = $transaction->getPayment(); - $redirect = !empty($transaction->getRedirectUrl()); - - switch (true) { - case (!$redirect && $transaction->isSuccess()): - redirect(SUCCESS_URL); - break; - case (!$redirect && $transaction->isPending()): - redirect(PENDING_URL); - break; - case ($redirect && $transaction->isPending()): - redirect($transaction->getRedirectUrl()); - break; - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/CardExtended/index.php b/examples/CardExtended/index.php deleted file mode 100644 index cbd1ada4b..000000000 --- a/examples/CardExtended/index.php +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/CardRecurring/Constants.php b/examples/CardRecurring/Constants.php deleted file mode 100644 index 94e49993d..000000000 --- a/examples/CardRecurring/Constants.php +++ /dev/null @@ -1,13 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - $paymentType = $unzer->fetchPaymentType($paymentTypeId); - - $charge = (new Charge(12.99, 'EUR', MY_RETURN_CONTROLLER_URL)) - ->setRecurrenceType($recurrenceType, $paymentType); - - $transaction = $unzer->performCharge($charge, $paymentTypeId); - - // You'll need to remember the paymentId for later in the ReturnController (in case of 3ds) - $_SESSION['PaymentTypeId'] = $paymentTypeId; - $_SESSION['ShortId'] = $transaction->getShortId(); - $_SESSION['recurrenceType'] = $transaction->getRecurrenceType(); - - // Redirect to the 3ds page or to success depending on the state of the transaction - $redirect = !empty($transaction->getRedirectUrl()); - if (!$redirect && $transaction->isSuccess()) { - redirect(SUCCESS_URL); - } elseif ($redirect && $transaction->isPending()) { - redirect($transaction->getRedirectUrl()); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/CardRecurring/RecurringPaymentController.php b/examples/CardRecurring/RecurringPaymentController.php deleted file mode 100644 index b4d14bcb2..000000000 --- a/examples/CardRecurring/RecurringPaymentController.php +++ /dev/null @@ -1,77 +0,0 @@ -setDebugMode(true)->setDebugHandler($debugHandler); - - $customer = CustomerFactory::createCustomer('Max', 'Mustermann'); - $customer->setEmail('test@test.com'); - - $transaction = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, true, null, null, $recurrenceTyp); - - // You'll need to remember the paymentId for later in the ReturnController (in case of 3ds) - $_SESSION['PaymentTypeId'] = $paymentTypeId; - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the failure page or to success depending on the state of the transaction - $redirect = !empty($transaction->getRedirectUrl()); - if (!$redirect && $transaction->isSuccess()) { - redirect(SUCCESS_URL); - } elseif ($redirect && $transaction->isPending()) { - redirect(FAILURE_URL, 'Transaction initiated by merchant should not redirect to 3ds Page. The customer needs to - do the 3ds authentication first for that payment type.'); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/CardRecurring/ReturnController.php b/examples/CardRecurring/ReturnController.php deleted file mode 100644 index 6e7e014ac..000000000 --- a/examples/CardRecurring/ReturnController.php +++ /dev/null @@ -1,62 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed or is still in handled. - /** @var Card $paymentType */ - $paymentType = $unzer->fetchPaymentType($paymentTypeId); - - if ($paymentType->isRecurring()) { - redirect(SUCCESS_URL); - } - -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} - -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/CardRecurring/index.php b/examples/CardRecurring/index.php deleted file mode 100644 index 1bc34ef3c..000000000 --- a/examples/CardRecurring/index.php +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/Constants.php b/examples/Constants.php deleted file mode 100755 index be2f01a4b..000000000 --- a/examples/Constants.php +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
- The payment is in create state, meaning the Payment page was not used for a payment yet.
- The payment also stays in this state when the customer clicked the "Back to merchant" button or closed the browser tab.
- It is still active and could be used by the customer for the current payment.
- Payment page';
-
- if (!empty($additionalPaymentInformation)) {
- echo $additionalPaymentInformation;
- }
-
- if ($shortId !== null) {
- $defaultTransactionMessage = '
Please look for ShortId ' . $shortId . ' in Unzer Insights to see the transaction.
'; - $paylaterTransactionMessage = 'Please use the "descriptor" to look for the transaction in the Unzer Pay Later Merchant Portal.
'; - echo preg_match('/[\d]{4}.[\d]{4}.[\d]{4}/', $shortId) ? $defaultTransactionMessage : $paylaterTransactionMessage; - } - $paymentId = $_SESSION['PaymentId'] ?? null; - if ($paymentId !== null) { - echo 'The PaymentId is \'' . $paymentId . '\'.
'; - } - - if ($paymentTypeId !== null) { - echo 'The TypeId for the recurring payment is \'' . $paymentTypeId . '\'. You can use it - now for subsequent transactions.
- '; - } - ?> - - - - diff --git a/examples/EPSCharge/Constants.php b/examples/EPSCharge/Constants.php deleted file mode 100755 index 660fe965e..000000000 --- a/examples/EPSCharge/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge to get the redirectUrl. - $customer = CustomerFactory::createCustomer('Max', 'Mustermann'); - $charge = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $charge->getPaymentId(); - $_SESSION['ShortId'] = $charge->getShortId(); - - // Redirect to the EPS page of the selected bank - if (!$charge->isError() && $charge->getRedirectUrl() !== null) { - redirect($charge->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/EPSCharge/index.php b/examples/EPSCharge/index.php deleted file mode 100755 index b2edc4404..000000000 --- a/examples/EPSCharge/index.php +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/EmbeddedPayPage/Constants.php b/examples/EmbeddedPayPage/Constants.php deleted file mode 100644 index db6d5d52e..000000000 --- a/examples/EmbeddedPayPage/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // A customer with matching addresses is mandatory for Installment payment type - $address = (new Address()) - ->setName('Max Mustermann') - ->setStreet('Vangerowstr. 18') - ->setCity('Heidelberg') - ->setZip('69155') - ->setCountry('DE'); - - // Create a charge/authorize transaction - $customer = CustomerFactory::createCustomer('Max', 'Mustermann') - ->setSalutation(Salutations::MR) - ->setBirthDate('2000-02-12') - ->setLanguage('de') - ->setEmail('test@test.com'); - - // These are the mandatory parameters for the payment page ... - $paypage = new Paypage(119.00, 'EUR', RETURN_CONTROLLER_URL); - $orderId = 'o' . str_replace(['0.', ' '], '', microtime(false)); - - // Just for example purpose. Make sure to generate a unique ID. - $threatMetrixId = 'php-sdk-example_' . $orderId; - - // ... however you can customize the Payment Page using additional parameters. - $paypage->setShopName('My Test Shop') - ->setTagline('Try and stop us from being awesome!') - ->setTermsAndConditionUrl('https://www.unzer.com/en/') - ->setPrivacyPolicyUrl('https://www.unzer.com/de/datenschutz/') - ->setOrderId($orderId) - ->setLogoImage(UNZER_PP_LOGO_URL) - ->setAdditionalAttribute('riskData.threatMetrixId', $threatMetrixId) - ->setAdditionalAttribute('riskData.customerGroup', CustomerGroups::GOOD) - ->setAdditionalAttribute('riskData.confirmedAmount', 99.99) - ->setAdditionalAttribute('riskData.confirmedOrders', 2) - ->setAdditionalAttribute('riskData.registrationLevel', CustomerRegistrationLevel::REGISTERED) - ->setAdditionalAttribute('riskData.registrationDate ', '20160412') - ->setInvoiceId('i' . microtime(true)); - - // ... in order to enable Unzer Instalment you will need to set the effectiveInterestRate as well. - $paypage->setEffectiveInterestRate(4.99); - - // ... a Basket is mandatory for InstallmentSecured - $basketItem = (new BasketItem()) - ->setAmountPerUnitGross(119.00) - ->setVat(19.00) - ->setQuantity(1) - ->setBasketItemReferenceId('item1') - ->setTitle('Hat'); - - $basket = new Basket($orderId); - $basket->setTotalValueGross(119.00) - ->addBasketItem($basketItem) - ->setCurrencyCode('EUR'); - - if ($transactionType === 'charge') { - $unzer->initPayPageCharge($paypage, $customer, $basket); - } else { - // For demo purpose we set customer address for authorize only to enable instalment payment. - // That way e.g. Invoice secured will display customer form on payment page. - $customer - ->setShippingAddress($address) - ->setBillingAddress($address); - $unzer->initPayPageAuthorize($paypage, $customer, $basket); - } - - $_SESSION['PaymentId'] = $paypage->getPaymentId(); - echo json_encode(['token' => $paypage->getId()]); - die(); - -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} - -http_response_code(400); -echo json_encode(['merchant' => $merchantMessage, 'customer' => $clientMessage]); diff --git a/examples/EmbeddedPayPage/index.php b/examples/EmbeddedPayPage/index.php deleted file mode 100644 index 0fa9ab302..000000000 --- a/examples/EmbeddedPayPage/index.php +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - -- There has been an error completing the payment. - Merchant message (don\'t show this to the customer): ' . $_SESSION['merchantMessage'] . '
'; - } - if (isset($_SESSION['clientMessage']) && !empty($_SESSION['clientMessage'])) { - echo 'Client message (this is the error message for the customer): ' . $_SESSION['clientMessage'] . '
'; - } - if (isset($_SESSION['ShortId']) && !empty($_SESSION['ShortId'])) { - echo 'Please look for ShortId ' . $_SESSION['ShortId'] . ' in Unzer Insights to see the transaction.
'; - } - if (isset($_SESSION['PaymentId']) && !empty($_SESSION['PaymentId'])) { - echo 'The PaymentId of your transaction is \'' . $_SESSION['PaymentId'] . '\'.
'; - } - ?> - - start again -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/Googlepay/Constants.php b/examples/Googlepay/Constants.php deleted file mode 100644 index 863a4e4fb..000000000 --- a/examples/Googlepay/Constants.php +++ /dev/null @@ -1,9 +0,0 @@ -typeId; -$transactionType = $jsonData->transaction_type ?? 'authorize'; - -// You will need the id of the payment type created in the frontend (index.php) -if (empty($paymentTypeId)) { - echo json_encode(['result' => false]); - return; -} - -$transactionResult = [ - TRANSACTION_STATUS_KEY => 'error', - REDIRECT_URL_KEY => '' -]; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create an Unzer object using your private key and register a debug handler if you want to. - $unzer = new Unzer(UNZER_PAPI_PRIVATE_KEY); - $unzer->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - if ($transactionType === 'charge') { - $charge = new \UnzerSDK\Resources\TransactionTypes\Charge(12.32, 'EUR', RETURN_CONTROLLER_URL); - $transaction = $unzer->performCharge($charge, $paymentTypeId); - } else { - $authorize = new \UnzerSDK\Resources\TransactionTypes\Authorization(12.32, 'EUR', RETURN_CONTROLLER_URL); - $transaction = $unzer->performAuthorization($authorize, $paymentTypeId); - } - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - $redirectUrl = $transaction->getRedirectUrl(); - - if (!empty($redirectUrl)) { - $transactionResult[REDIRECT_URL_KEY] = $redirectUrl; - } - - if ($transaction->isSuccess()) { - $transactionResult[TRANSACTION_STATUS_KEY] = 'success'; - echo json_encode($transactionResult); - return; - } - if ($transaction->isPending()) { - $transactionResult[TRANSACTION_STATUS_KEY] = 'pending'; - - echo json_encode($transactionResult); - return; - } -} catch (UnzerApiException $e) { - $_SESSION['merchantMessage'] = $e->getMerchantMessage(); - $_SESSION['clientMessage'] = $e->getClientMessage(); -} catch (RuntimeException $e) { - $_SESSION['merchantMessage'] = $e->getMessage(); -} - -echo json_encode($transactionResult); diff --git a/examples/Googlepay/index.php b/examples/Googlepay/index.php deleted file mode 100644 index 86dc146a1..000000000 --- a/examples/Googlepay/index.php +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
-
Click here to open our test data in new tab.
- - - - - diff --git a/examples/IDeal/Constants.php b/examples/IDeal/Constants.php deleted file mode 100644 index 9278d8207..000000000 --- a/examples/IDeal/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge to get the redirectUrl. - $customer = CustomerFactory::createCustomer('Max', 'Mustermann'); - $charge = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $charge->getPaymentId(); - $_SESSION['ShortId'] = $charge->getShortId(); - - // Redirect to the iDeal page of the selected bank - if (!$charge->isError() && $charge->getRedirectUrl() !== null) { - redirect($charge->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/IDeal/index.php b/examples/IDeal/index.php deleted file mode 100644 index 82809c44f..000000000 --- a/examples/IDeal/index.php +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/InstallmentSecured/Constants.php b/examples/InstallmentSecured/Constants.php deleted file mode 100644 index 6607fcdb2..000000000 --- a/examples/InstallmentSecured/Constants.php +++ /dev/null @@ -1,13 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Use the quote or order id from your shop - $orderId = 'o' . str_replace(['0.', ' '], '', microtime(false)); - - /** @var InstallmentSecured $paymentType */ - $paymentType = $unzer->fetchPaymentType($paymentTypeId); - - // A customer with matching addresses is mandatory for Installment payment type - $address = (new Address()) - ->setName('Linda Heideich') - ->setStreet('Vangerowstr. 18') - ->setCity('Heidelberg') - ->setZip('69155') - ->setCountry('DE'); - $customer = CustomerFactory::createCustomer('Linda', 'Heideich') - ->setBirthDate('2000-02-12') - ->setBillingAddress($address) - ->setShippingAddress($address) - ->setEmail('linda.heideich@test.de'); - - // A Basket is mandatory for Installment Secured payment type - $basketItem = (new BasketItem()) - ->setAmountPerUnitGross(119.00) - ->setVat(19) - ->setQuantity(1) - ->setBasketItemReferenceId('item1') - ->setTitle('Hat'); - - $basket = new Basket($orderId); - $basket->setTotalValueGross(119.00) - ->addBasketItem($basketItem) - ->setCurrencyCode('EUR'); - - // initialize the payment - $authorize = $unzer->authorize( - $paymentType->getTotalPurchaseAmount(), - 'EUR', - $paymentType, - CONTROLLER_URL, - $customer, - $orderId, - null, - $basket - ); - - // You'll need to remember the shortId to show it on the success or failure page - $_SESSION['PaymentId'] = $authorize->getPaymentId(); - - // Redirect to the success or failure depending on the state of the transaction - if ($authorize->isSuccess()) { - redirect(CONFIRM_URL); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $authorize->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/InstallmentSecured/PlaceOrderController.php b/examples/InstallmentSecured/PlaceOrderController.php deleted file mode 100644 index da9b1fb1d..000000000 --- a/examples/InstallmentSecured/PlaceOrderController.php +++ /dev/null @@ -1,65 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - $payment = $unzer->fetchPayment($paymentId); - $charge = $payment->charge(); - - $_SESSION['ShortId'] = $charge->getShortId(); - - // Redirect to the success or failure depending on the state of the transaction - if ($charge->isSuccess()) { - redirect(SUCCESS_URL); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/InstallmentSecured/confirm.php b/examples/InstallmentSecured/confirm.php deleted file mode 100644 index a78076b5a..000000000 --- a/examples/InstallmentSecured/confirm.php +++ /dev/null @@ -1,115 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - $payment = $unzer->fetchPayment($paymentId); - - $PDFLink = $payment->getAuthorization()->getPDFLink(); - /** @var InstallmentSecured $type */ - $type = $payment->getPaymentType(); - $totalAmount = $type->getTotalAmount(); - $totalPurchaseAmount = $type->getTotalPurchaseAmount(); - $totalInterestAmount = $type->getTotalInterestAmount(); - $currency = $payment->getAmount()->getCurrency(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); - redirect(FAILURE_URL, $merchantMessage, $clientMessage); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); - redirect(FAILURE_URL, $merchantMessage, $clientMessage); -} -?> - - - - - -Click here to open our test data in new tab.
Click here to open our test data in new tab.
- - - - - - - diff --git a/examples/Klarna/Constants.php b/examples/Klarna/Constants.php deleted file mode 100644 index b3f45b3d5..000000000 --- a/examples/Klarna/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - $orderId = 'o' . str_replace(['0.', ' '], '', microtime(false)); - - // A Basket is mandatory for Invoice Secured payment type - $basketItem = (new BasketItem()) - ->setAmountPerUnitGross(119.00) - ->setVat(19.00) - ->setQuantity(1) - ->setBasketItemReferenceId('item1') - ->setTitle('Hat'); - - $basket = new Basket($orderId); - $basket->setTotalValueGross(119.00) - ->addBasketItem($basketItem) - ->setCurrencyCode('EUR'); - - // A customer is mandatory for Klarna payment type - $address = (new Address()) - ->setName('Max Universum') - ->setStreet('Hugo-Junkers-Str. 4') - ->setZip('60386') - ->setCity('Frankfurt am Main') - ->setCountry('DE') - ->setState('DE-BO') - ->setShippingType(ShippingTypes::EQUALS_BILLING); - - $customer = CustomerFactory::createCustomer('Peter', 'Universum') - ->setSalutation(Salutations::MR) - ->setCompany('Unzer GmbH') - ->setBirthDate('1989-12-24') - ->setEmail('peter.universum@universum-group.de') - ->setMobile('+49172123456') - ->setPhone('+4962216471100') - ->setBillingAddress($address) - ->setLanguage('de'); - - $transactionData = [119.00, 'EUR', RETURN_CONTROLLER_URL]; - $additionalTransactionData = [ - 'termsAndConditionUrl' => 'https://www.unzer.com/de/', - 'privacyPolicyUrl' => 'https://www.unzer.com/de/' - ]; - - // Create a authorize transaction to get the redirectUrl. - $authorizationInstance = (new Authorization(...$transactionData)) - ->setAdditionalTransactionData((object)$additionalTransactionData); - $transaction = $unzer->performAuthorization($authorizationInstance, $paymentTypeId, $customer, null, $basket); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - $_SESSION['isAuthorizeTransaction'] = true; - - // Redirect to the Klarna page - if (!$transaction->isError() && $transaction->getRedirectUrl() !== null) { - redirect($transaction->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Klarna/index.php b/examples/Klarna/index.php deleted file mode 100644 index 047c0bb72..000000000 --- a/examples/Klarna/index.php +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/PayPal/Constants.php b/examples/PayPal/Constants.php deleted file mode 100755 index 17a496a80..000000000 --- a/examples/PayPal/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - $paymentType = $unzer->fetchPaymentType($paymentTypeId); - $orderId = 'o' . str_replace(['0.', ' '], '', microtime(false)); - - $basketItem = (new BasketItem()) - ->setAmountPerUnitGross(12.32) - ->setVat(19.00) - ->setQuantity(1) - ->setBasketItemReferenceId('item1') - ->setTitle('Hat'); - - $basket = new Basket($orderId); - $basket->setTotalValueGross(12.32) - ->addBasketItem($basketItem) - ->setCurrencyCode('EUR'); - - // Create a charge/authorize transaction to get the redirectUrl. - if ($transactionType === 'charge') { - $charge = new Charge(12.32, 'EUR', RETURN_CONTROLLER_URL); - if ($useExpressCheckout) { - $charge->setCheckoutType('express', $paymentType); - } - $transaction = $unzer->performCharge($charge, $paymentType, null, null, $basket); - } else { - $authorize = new Authorization(12.32, 'EUR', RETURN_CONTROLLER_URL); - if ($useExpressCheckout) { - $authorize->setCheckoutType('express', $paymentType); - } - $transaction = $unzer->performAuthorization($authorize, $paymentType, null, null, $basket); - } - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the PayPal page - if (!$transaction->isError() && $transaction->getRedirectUrl() !== null) { - redirect($transaction->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/PayPal/index.php b/examples/PayPal/index.php deleted file mode 100755 index 0fb4842b2..000000000 --- a/examples/PayPal/index.php +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/PayPalRecurring/Constants.php b/examples/PayPalRecurring/Constants.php deleted file mode 100644 index 9ca9757a6..000000000 --- a/examples/PayPalRecurring/Constants.php +++ /dev/null @@ -1,13 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - $recurring = $unzer->activateRecurringPayment($paymentTypeId, MY_RETURN_CONTROLLER_URL); - - // You'll need to remember the paymentId for later in the ReturnController (in case of 3ds) - $_SESSION['PaymentTypeId'] = $paymentTypeId; - $_SESSION['ShortId'] = $recurring->getShortId(); - - // Redirect to the 3ds page or to success depending on the state of the transaction - if (empty($recurring->getRedirectUrl()) && $recurring->isSuccess()) { - redirect(SUCCESS_URL); - } elseif (!empty($recurring->getRedirectUrl()) && $recurring->isPending()) { - redirect($recurring->getRedirectUrl()); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $recurring->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/PayPalRecurring/ReturnController.php b/examples/PayPalRecurring/ReturnController.php deleted file mode 100644 index 14fbe87fc..000000000 --- a/examples/PayPalRecurring/ReturnController.php +++ /dev/null @@ -1,62 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed or is still in handled. - /** @var Card $paymentType */ - $paymentType = $unzer->fetchPaymentType($paymentTypeId); - - if ($paymentType->isRecurring()) { - redirect(SUCCESS_URL); - } - -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} - -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/PayPalRecurring/index.php b/examples/PayPalRecurring/index.php deleted file mode 100644 index 596034ba4..000000000 --- a/examples/PayPalRecurring/index.php +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/PayU/Constants.php b/examples/PayU/Constants.php deleted file mode 100644 index e8717edaf..000000000 --- a/examples/PayU/Constants.php +++ /dev/null @@ -1,13 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge transaction to get the redirectUrl. - $transaction = new \UnzerSDK\Resources\TransactionTypes\Charge(12.32, 'PLN', RETURN_CONTROLLER_URL); - $unzer->performCharge($transaction, $paymentTypeId); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the PayU page - if (!$transaction->isError() && $transaction->getRedirectUrl() !== null) { - redirect($transaction->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/PayU/index.php b/examples/PayU/index.php deleted file mode 100644 index ab5072b07..000000000 --- a/examples/PayU/index.php +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/PaylaterDirectDebit/Constants.php b/examples/PaylaterDirectDebit/Constants.php deleted file mode 100644 index a8a77f2d1..000000000 --- a/examples/PaylaterDirectDebit/Constants.php +++ /dev/null @@ -1,9 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Use the quote or order id from your shop - $orderId = 'o' . str_replace(['0.', ' '], '', microtime(false)); - - /** @var PaylaterDirectDebit $paymentType */ - $paymentType = $unzer->fetchPaymentType($paymentTypeId); - - // A customer with matching addresses is mandatory for Direct Debit payment type - $address = (new Address()) - ->setName('Linda Heideich') - ->setStreet('Vangerowstr. 18') - ->setCity('Heidelberg') - ->setZip('69155') - ->setCountry('DE'); - $customer = CustomerFactory::createCustomer('Linda', 'Heideich') - ->setBirthDate('2000-02-12') - ->setBillingAddress($address) - ->setShippingAddress($address) - ->setEmail('linda.heideich@test.de'); - - // A Basket is mandatory for Paylater Direct Debit payment type - $basketItem = (new BasketItem()) - ->setAmountPerUnitGross($orderAmount) - ->setVat(19) - ->setQuantity(1) - ->setBasketItemReferenceId('item1') - ->setTitle('Hat'); - - $currency = 'EUR'; - $basket = new Basket($orderId); - $basket->setTotalValueGross($orderAmount) - ->addBasketItem($basketItem) - ->setCurrencyCode($currency); - - $riskData = (new RiskData()) - ->setThreatMetrixId($threatMetrixId) - ->setCustomerGroup(CustomerGroups::GOOD) - ->setConfirmedAmount(99.99) - ->setConfirmedOrders(2) - ->setRegistrationLevel(CustomerRegistrationLevel::REGISTERED) - ->setRegistrationDate('20160412'); - - // initialize the payment - $authorize = (new Authorization($orderAmount, $currency, RETURN_CONTROLLER_URL)) - ->setRiskData($riskData); - - $unzer->performAuthorization( - $authorize, - $paymentType, - $customer, - null, - $basket - ); - - // You'll need to remember the shortId to show it on the success or failure page - $_SESSION['PaymentId'] = $authorize->getPaymentId(); - $_SESSION['ShortId'] = $authorize->getShortId(); - $_SESSION['additionalPaymentInformation'] = sprintf("Descriptor: %s", $authorize->getDescriptor()); - - // Redirect to the success or failure depending on the state of the transaction - if ($authorize->isSuccess()) { - redirect(SUCCESS_URL); - } - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $authorize->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/PaylaterDirectDebit/index.php b/examples/PaylaterDirectDebit/index.php deleted file mode 100644 index 430c41294..000000000 --- a/examples/PaylaterDirectDebit/index.php +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
-
Click here to open our test data in new tab.
-
Click here to open our test data in new tab.
- - - - - - - diff --git a/examples/Pending.php b/examples/Pending.php deleted file mode 100644 index 311a19c25..000000000 --- a/examples/Pending.php +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - -
- The payment transaction has been completed, however it has the state pending.
- The status of the payment is not definite at the moment.
- You can create the Order in your shop but should set its status to pending payment.
-
- Please use the webhook feature to be informed about later changes of the payment. - You should ship only if the status changes to success. - Please look for ShortId ' . $_SESSION['ShortId'] . ' in Unzer Insights to see the transaction.
'; - } - if (isset($_SESSION['PaymentId']) && !empty($_SESSION['PaymentId'])) { - echo 'The PaymentId of your transaction is \'' . $_SESSION['PaymentId'] . '\'.
'; - } - ?> - - start again -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/PostFinanceEfinance/Constants.php b/examples/PostFinanceEfinance/Constants.php deleted file mode 100644 index f8fa1bebd..000000000 --- a/examples/PostFinanceEfinance/Constants.php +++ /dev/null @@ -1,13 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge transaction to get the redirectUrl. - $transaction = new \UnzerSDK\Resources\TransactionTypes\Charge(12.32, 'CHF', RETURN_CONTROLLER_URL); - $unzer->performCharge($transaction, $paymentTypeId); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the PostFinance page - if (!$transaction->isError() && $transaction->getRedirectUrl() !== null) { - redirect($transaction->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/PostFinanceEfinance/index.php b/examples/PostFinanceEfinance/index.php deleted file mode 100644 index cf121b87d..000000000 --- a/examples/PostFinanceEfinance/index.php +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/Prepayment/Constants.php b/examples/Prepayment/Constants.php deleted file mode 100644 index 2f0965beb..000000000 --- a/examples/Prepayment/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - /** @var Prepayment $prepayment */ - $prepayment = $unzer->createPaymentType(new Prepayment()); - - $customer = CustomerFactory::createCustomer('Max', 'Mustermann'); - $orderId = 'o' . str_replace(['0.', ' '], '', microtime(false)); - - $transaction = $prepayment->charge(12.99, 'EUR', CONTROLLER_URL, $customer, $orderId); - - // You'll need to remember the shortId to show it on the success or failure page - $_SESSION['ShortId'] = $transaction->getShortId(); - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['additionalPaymentInformation'] = - sprintf( - "Please transfer the amount of %f %s to the following account:Click here to open our test data in new tab.
- - - - - - diff --git a/examples/ReturnController.php b/examples/ReturnController.php deleted file mode 100644 index 43951c907..000000000 --- a/examples/ReturnController.php +++ /dev/null @@ -1,128 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed. - $payment = $unzer->fetchPayment($paymentId); - $transaction = $payment->getInitialTransaction(); - - // Ensure that shortId is also set in case of payment pages. - if ($transaction !== null) { - $_SESSION['ShortId'] = $_SESSION['ShortId'] ?? $transaction->getShortId(); - } - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You show the success page. - // Goods can be shipped. - $redirectUrl = SUCCESS_URL; - } - - if ($payment->isCreate()) { - // The payment is in create state, meaning the customer clicked the "Back to Merchant" button. - // The Payment page was not used for a payment yet. - // It is still active and could be used by the customer for the current payment. - $_SESSION['paypageId'] = $payment->getPayPage()->getRedirectUrl(); - $redirectUrl = CREATE_URL; - } - - if ($payment->isPending()) { - if ($transaction->isSuccess() || $transaction->isResumed()) { - if ($transaction instanceof Authorization) { - // Payment is ready to be captured. - // Goods can be shipped later AFTER charge. - } else { - // Payment is not done yet (e.g. Prepayment) - // Goods can be shipped later after incoming payment (event). - } - - // In any case: - // * You can show the success page. - // * You can set order status to pending payment - $redirectUrl = SUCCESS_URL; - } elseif ($transaction->isPending()) { - // In cases of a redirect to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status after redirect into shop. - // In this case the payment and the transaction are pending at first and change to cancel or success later. - - // Use the webhooks feature to stay informed about changes of payment and transaction (e.g. cancel, success) - // then you can handle the states as shown above in transaction->isSuccess() branch. - $redirectUrl = PENDING_URL; - - // The initial transaction of invoice types will not change to success but stay pending. - $paymentType = $payment->getPaymentType(); - if ($paymentType instanceof Prepayment || $paymentType->isInvoiceType()) { - // Awaiting payment by the customer. - // Goods can be shipped immediately except for Prepayment type. - $redirectUrl = SUCCESS_URL; - } - } - } - - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order or cancel it if you already did. - // Redirect to an error page in your shop and show a message if you want. - - // Check the result message of the initial transaction to find out what went wrong. - if ($transaction instanceof AbstractTransactionType) { - // For better debugging log the error message in your error log - $merchantMessage = $transaction->getMessage()->getMerchant(); - $clientMessage = $transaction->getMessage()->getCustomer(); - } -} catch (UnzerApiException $e) { - // Write the merchant message to your log. - // Show the client message to the customer (it is localized). - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect($redirectUrl, $merchantMessage, $clientMessage); diff --git a/examples/SepaDirectDebitSecured/Constants.php b/examples/SepaDirectDebitSecured/Constants.php deleted file mode 100644 index ed51a8f61..000000000 --- a/examples/SepaDirectDebitSecured/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - $orderId = 'o' . str_replace(['0.', ' '], '', microtime(false)); - - // A Basket is mandatory for SEPA direct debit secured payment type - $basketItem = (new BasketItem()) - ->setAmountPerUnitGross(119.00) - ->setVat(19.00) - ->setQuantity(1) - ->setBasketItemReferenceId('item1') - ->setTitle('Hat'); - - $basket = new Basket($orderId); - $basket->setTotalValueGross(119.00) - ->addBasketItem($basketItem) - ->setCurrencyCode('EUR'); - - $transaction = $unzer->charge(119.0, 'EUR', $paymentTypeId, CONTROLLER_URL, $customerId, $orderId, null, $basket); - - // You'll need to remember the shortId to show it on the success or failure page - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the success or failure depending on the state of the transaction - $payment = $transaction->getPayment(); - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - - // To avoid redundant code this example redirects to the general ReturnController which contains the code example to handle payment results. - redirect(RETURN_CONTROLLER_URL); - -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/SepaDirectDebitSecured/index.php b/examples/SepaDirectDebitSecured/index.php deleted file mode 100644 index d3186a6ea..000000000 --- a/examples/SepaDirectDebitSecured/index.php +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - - diff --git a/examples/Sofort/Constants.php b/examples/Sofort/Constants.php deleted file mode 100644 index bd909cfb5..000000000 --- a/examples/Sofort/Constants.php +++ /dev/null @@ -1,12 +0,0 @@ -setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Create a charge transaction to get the redirectUrl. - $transaction = $unzer->charge(12.32, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL); - - // You'll need to remember the paymentId for later in the ReturnController - $_SESSION['PaymentId'] = $transaction->getPaymentId(); - $_SESSION['ShortId'] = $transaction->getShortId(); - - // Redirect to the Sofort page - if (!$transaction->isError() && $transaction->getRedirectUrl() !== null) { - redirect($transaction->getRedirectUrl()); - } - - // Check the result message of the charge to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (UnzerApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Sofort/index.php b/examples/Sofort/index.php deleted file mode 100644 index 67c98e1ad..000000000 --- a/examples/Sofort/index.php +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/Success.php b/examples/Success.php deleted file mode 100755 index 94a2475a9..000000000 --- a/examples/Success.php +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - -The order has been successfully placed.
- - Please look for ShortId ' . $shortId . ' in Unzer Insights to see the transaction.'; - $paylaterTransactionMessage = 'Please use the "descriptor" to look for the transaction in the Unzer Pay Later Merchant Portal.
'; - echo preg_match('/[\d]{4}.[\d]{4}.[\d]{4}/', $shortId) ? $defaultTransactionMessage : $paylaterTransactionMessage; - } - - $isManageable = false; - if ($paymentId !== null) { - echo 'The PaymentId of your transaction is \'' . $paymentId . '\'.
'; - $unzer = new Unzer(UNZER_PAPI_PRIVATE_KEY); - $payment = $unzer->fetchPayment($paymentId); - $isManageable = $payment->getPaymentType()->supportsDirectPaymentCancel() || $payment->getAuthorization() !== null; - } - - if ($paymentTypeId !== null) { - echo 'The TypeId for the recurring payment is \'' . $paymentTypeId . '\'. You can use it - now for subsequent transactions.
- '; - } - - if ($isManageable) { - echo 'As a merchant you can charge or cancel the Payment here: Manage Payment
'; - } - ?> - start again -' . nl2br($text) . '
'. - '' . nl2br($text) . '
'. - ''; -} - -function printError($text) -{ - printMessage('error', 'Error', $text); -} - -function printSuccess($title, $text) -{ - printMessage('success', $title, $text); -} - -function printInfo($title, $text) -{ - printMessage('info', $title, $text); -} - -?> - - - - - -' . nl2br($text) . '
'. - ''; -} - -function printError($text) -{ - printMessage('error', 'Error', $text); -} - -function printSuccess($title, $text) -{ - printMessage('success', $title, $text); -} - -function printInfo($title, $text) -{ - printMessage('info', $title, $text); -} - -?> - - - - - -Click here to open our test data in new tab.
- - - - - - diff --git a/examples/_enableExamples.php b/examples/_enableExamples.php deleted file mode 100755 index ccc844f65..000000000 --- a/examples/_enableExamples.php +++ /dev/null @@ -1,43 +0,0 @@ -'. - '' . nl2br($text) . '
'. - ''; -} -?> - - - - - -