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/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"); 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 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"); 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