Hi,
we have a website with customers and we want to implement your charging system but I am having trouble to use your Web Service API.
I need a little help with the PHP SDK.
https://github.com/wallee-payment/php-sdk
Sadly there is just an example for a simple one time payment,
but we need an integration with subscribers and subscriptions.
I also read the documentation: https://app-wallee.com/de-de/doc/subscription/subscriptions#_web_service_api
But I am not understanding why its not working.
Below my code in php, maybe you can tell me what I am doing wrong.
I want that the customer is redirect to your system and choose the payment method first and then paying the price which we defined in our product.
I am getting always this error when I am executing initializeSubscriberPresent() : "The subscription with the id xxx could not be found"
But the subscription is existing, I can see it when I am logged in in your backend.
<?php
require_once('vendor/autoload.php');
// Configuration
$spaceId = 'xxxx';
$userId = 'xxxx';
$secret = 'xxx';
// Setup API client
$client = new \Wallee\Sdk\ApiClient($userId, $secret);
$tokenCreate = new \Wallee\Sdk\Model\TokenCreate();
$tokenCreate->setCustomerId($companyData["customerId"]);
$tokenCreate->setExternalId($companyData["paymentHash"]);
$tokenCreate->setEnabledForOneClickPayment(true);
$tokenCreate->setTokenReference("dsgmodul".$companyData["module"]);
$token = $client->getTokenService()->create($spaceId,$tokenCreate);
$billingAddress = new \Wallee\Sdk\Model\Address();
$billingAddress->setEmailAddress($companyData["email"]);
$billingAddress->setOrganizationName($companyData["organizationName"]);
$billingAddress->setStreet($companyData["street"]);
$billingAddress->setPostcode($companyData["postcode"]);
$billingAddress->setCity($companyData["city"]);
$billingAddress->setCountry("DE");
$subscriberCreate = new \Wallee\Sdk\Model\SubscriberCreate();
$subscriberCreate->setEmailAddress($companyData["email"]);
$subscriberCreate->setExternalId($companyData["customerId"]);
$subscriberCreate->setBillingAddress($billingAddress);
$subscriber = $client->getSubscriberService()->create($spaceId,$subscriberCreate);
$subscriptionModel = new \Wallee\Sdk\Model\SubscriptionPending();
$subscriptionModel->setToken($token);
$subscriptionModel->setSubscriber($subscriber->getId());
$subscriptionModel->setReference("Test_123");
$subscriptionCreateRequest = new \Wallee\Sdk\Model\SubscriptionCreateRequest();
$subscriptionCreateRequest->setSubscription($subscriptionModel);
$subscriptionCreateRequest->setProduct(476);
$subscriptionCreateRequest->setCurrency("EUR");
$subscription = $client->getSubscriptionService()->create($spaceId,$subscriptionCreateRequest);
$successUrl = "http://xxxx";
$failedUrl = "http://xxxx";
$subscriptionInit = $client->getSubscriptionService()->initializeSubscriberPresent($spaceId,$subscription->getId(),$successUrl,$failedUrl);
$transaction = $subscriptionInit->getTransaction();
// Create Payment Page URL:
$redirectionUrl = $client->getTransactionPaymentPageService()->paymentPageUrl($spaceId, $transaction->getId());
header('Location: ' . $redirectionUrl);