Does the hosted payment support the subscription payment?
we have tried the subscription payment using php sdk by hosted method,
in this we cannot see the subscription created in the webhook url.
the code we have tried shown below,
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName($config->get('api_login_id'));
$merchantAuthentication->setTransactionKey($config->get('transaction_key'));
// Create the subscription request
$subscription = new AnetAPI\ARBSubscriptionType();
$subscription->setName("Premium Subscription");
$paymentSchedule = new AnetAPI\PaymentScheduleType();
$interval = new AnetAPI\PaymentScheduleType\IntervalAType();
$interval->setLength(1);
$interval->setUnit('days');
$paymentSchedule->setInterval($interval);
$paymentSchedule->setStartDate(new DateTime(Carbon::today()->format('Y-m-d')));
$paymentSchedule->setTotalOccurrences(30);
$paymentSchedule->setTrialOccurrences(0);
$subscription->setPaymentSchedule($paymentSchedule);
$subscription->setAmount(1.00);
// Create a transaction request to pass along with the subscription
$transactionRequest = new AnetAPI\TransactionRequestType();
$transactionRequest->setTransactionType("authCaptureTransaction");
$transactionRequest->setAmount("1.00");
// Set the subscription details in the transaction request
$order = new AnetAPI\OrderType();
$order->setInvoiceNumber("1111222233344");
$order->setDescription("Daily Subscription Invoice");
$transactionRequest->setOrder($order);
// Set up the hosted payment request settings
$setting1 = new AnetAPI\SettingType();
$setting1->setSettingName("hostedPaymentButtonOptions");
$setting1->setSettingValue("{\"text\": \"Subscribe\"}");
$setting2 = new AnetAPI\SettingType();
$setting2->setSettingName("hostedPaymentReturnOptions");
//$setting2->setSettingValue("{\"showReceipt\": false, \"url\": \"" .route('authorize.success') . "\", \"urlText\": \"Redirecting...\", \"cancelUrl\": \"" . route('authorize.cancel') . "\", \"cancelUrlText\": \"Cancel\"}");
$setting2->setSettingValue("{\"showReceipt\": true, \"url\": \"" .$url . "\", \"urlText\": \"Redirecting...\", \"cancelUrl\": \"" . $url . "\", \"cancelUrlText\": \"Cancel\"}");
$request = new AnetAPI\GetHostedPaymentPageRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setTransactionRequest($transactionRequest);
$request->addToHostedPaymentSettings($setting1);
$request->addToHostedPaymentSettings($setting2);
$controller = new AnetController\GetHostedPaymentPageController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
we have got the token, $response->getToken(). then post the token to the url :https://accept.authorize.net/payment/payment
then payment form appears and after the successful payment,
subscription not creating, only notifies the 'net.authorize.payment.authcapture.created' event type in our webhook.
Please check this issue? we need to solve this asap.
โ06-23-2024 11:01 PM