From 76879828d7a985064504f04a0af334d482257f62 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Date: Wed, 19 Jul 2023 21:15:12 +0530 Subject: [PATCH 1/4] Added CreateGooglePayTransaction --- .../create-google-pay-transaction.php | 113 ++++++++++++++++++ .../update-split-tender-group.php | 2 +- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 MobileInAppTransactions/create-google-pay-transaction.php diff --git a/MobileInAppTransactions/create-google-pay-transaction.php b/MobileInAppTransactions/create-google-pay-transaction.php new file mode 100644 index 0000000..75ecc36 --- /dev/null +++ b/MobileInAppTransactions/create-google-pay-transaction.php @@ -0,0 +1,113 @@ +setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); + $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); + + $refId = 'ref' . time(); + + $opaqueData = new AnetAPI\OpaqueDataType(); + $opaqueData->setDataDescriptor("COMMON.GOOGLE.INAPP.PAYMENT"); + $opaqueData->setDataValue("1234567890ABCDEF1111AAAA2222BBBB3333CCCC4444DDDD5555EEEE6666FFFF7777888899990000"); + $paymentType = new AnetAPI\PaymentType(); + $paymentType->setOpaqueData($opaqueData); + + $lineItem = new AnetAPI\LineItemType(); + $lineItem->setItemId("1"); + $lineItem->setName("vase"); + $lineItem->setDescription("Cannes logo"); + $lineItem->setQuantity(18); + $lineItem->setUnitPrice(45.00); + + $lineItemsArray = array(); + $lineItemsArray[0] = $lineItem; + + $tax = new AnetAPI\ExtendedAmountType(); + $tax->setAmount(5.00); + $tax->setName("level2 tax name"); + $tax->setDescription("level2 tax"); + + $userField = new AnetAPI\UserFieldType(); + $userFields = array(); + + $userField->setName("UserDefinedFieldName1"); + $userField->setValue("UserDefinedFieldValue1"); + $userFields[0] = $userField; + + $userField->setName("UserDefinedFieldName2"); + $userField->setValue("UserDefinedFieldValue2"); + $userFields[1] = $userField; + + $transactionRequestType = new AnetAPI\TransactionRequestType(); + $transactionRequestType->setTransactionType("authCaptureTransaction"); + $transactionRequestType->setAmount(151); + $transactionRequestType->setPayment($paymentType); + + $request = new AnetAPI\CreateTransactionRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + $request->setRefId($refId); + $request->setTransactionRequest( $transactionRequestType); + + $controller = new AnetController\CreateTransactionController($request); + $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); + + + if ($response != null) + { + if($response->getMessages()->getResultCode() == "Ok") + { + $tresponse = $response->getTransactionResponse(); + + if ($tresponse != null && $tresponse->getMessages() != null) + { + echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n"; + echo " AUTH CODE : " . $tresponse->getAuthCode() . "\n"; + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; + echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; + echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n"; + } + else + { + echo "Transaction Failed \n"; + if($tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + } + } + else + { + echo "Transaction Failed \n"; + $tresponse = $response->getTransactionResponse(); + if($tresponse != null && $tresponse->getErrors() != null) + { + echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; + echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; + } + else + { + echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; + echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; + } + } + } + else + { + echo "No response returned \n"; + } + + return $response; +} + +if(!defined('DONT_RUN_SAMPLES')) + createGooglePayTransaction(); +?> diff --git a/PaymentTransactions/update-split-tender-group.php b/PaymentTransactions/update-split-tender-group.php index c09310b..e386750 100644 --- a/PaymentTransactions/update-split-tender-group.php +++ b/PaymentTransactions/update-split-tender-group.php @@ -19,7 +19,7 @@ function updateSplitTenderGroup() $request = new AnetAPI\UpdateSplitTenderGroupRequest(); $request->setMerchantAuthentication($merchantAuthentication); - $request->setRefId($refId); + $request->setRefId($refId); $request->setSplitTenderId("115901"); $request->setSplitTenderStatus("voided"); From 1760330886e7945a9f21b1ecdf97123980ab8530 Mon Sep 17 00:00:00 2001 From: Gaidin Daishan Date: Thu, 22 Feb 2024 18:32:12 +0530 Subject: [PATCH 2/4] Updated dates used in requests --- RecurringBilling/create-subscription-from-customer-profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecurringBilling/create-subscription-from-customer-profile.php b/RecurringBilling/create-subscription-from-customer-profile.php index ce69254..8681182 100644 --- a/RecurringBilling/create-subscription-from-customer-profile.php +++ b/RecurringBilling/create-subscription-from-customer-profile.php @@ -29,7 +29,7 @@ function createSubscriptionFromCustomerProfile($intervalLength, $customerProfile $paymentSchedule = new AnetAPI\PaymentScheduleType(); $paymentSchedule->setInterval($interval); - $paymentSchedule->setStartDate(new DateTime('2020-08-30')); + $paymentSchedule->setStartDate(new DateTime('2035-08-30')); $paymentSchedule->setTotalOccurrences("12"); $paymentSchedule->setTrialOccurrences("1"); From 97a99c42c1eda1d887b0bd54ec6d0945dbfa1a35 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 22 Feb 2024 19:40:00 +0530 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99bb4ff..e929b5c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You can also run each sample directly from the command line. ``` e.g. ``` - $ php PaymentTransactions/charge-credit-card.php + $ php PaymentTransactions/authorize-credit-card.php ``` ### Installation Notes From 1c3610e348e410cc36dd56a0a7418080ef037a16 Mon Sep 17 00:00:00 2001 From: gnongsie Date: Thu, 25 Jul 2024 12:24:05 +0530 Subject: [PATCH 4/4] Modifications to keep up to date --- .gitignore | 3 +++ RecurringBilling/get-list-of-subscriptions.php | 10 ++++++---- SampleCodeList.txt | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1ed26d5..5e1ed6a 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ # Operating system files .DS_Store +/lib +/*.cache +/testslog diff --git a/RecurringBilling/get-list-of-subscriptions.php b/RecurringBilling/get-list-of-subscriptions.php index 44049d7..72330e8 100644 --- a/RecurringBilling/get-list-of-subscriptions.php +++ b/RecurringBilling/get-list-of-subscriptions.php @@ -22,7 +22,7 @@ function getListOfSubscriptions() $sorting->setOrderDescending(false); $paging = new AnetAPI\PagingType(); - $paging->setLimit("1000"); + $paging->setLimit("10"); $paging->setOffset("1"); $request = new AnetAPI\ARBGetSubscriptionListRequest(); @@ -39,10 +39,12 @@ function getListOfSubscriptions() if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { echo "SUCCESS: Subscription Details:" . "\n"; - foreach ($response->getSubscriptionDetails() as $subscriptionDetails) { - echo "Subscription ID: " . $subscriptionDetails->getId() . "\n"; - } echo "Total Number In Results:" . $response->getTotalNumInResultSet() . "\n"; + if ($response->getTotalNumInResultSet() > 0) { + foreach ($response->getSubscriptionDetails() as $subscriptionDetails) { + echo "Subscription ID: " . $subscriptionDetails->getId() . "\n"; + } + } } else { echo "ERROR : Invalid response\n"; $errorMessages = $response->getMessages()->getMessage(); diff --git a/SampleCodeList.txt b/SampleCodeList.txt index a41fd6f..5119f91 100644 --- a/SampleCodeList.txt +++ b/SampleCodeList.txt @@ -7,7 +7,7 @@ GetTransactionList,0,1 CreateAnApplePayTransaction,0,0 CreateAnAcceptTransaction,0,0 CreateAnAndroidPayTransaction,0,0 -decryptVisaSrcData,0,1 +decryptVisaSrcData,0,0 createVisaSrcTransaction,0,0 CaptureFundsAuthorizedThroughAnotherChannel,1,1 AuthorizeCreditCard,1,1