|
| 1 | +<?php |
| 2 | + |
| 3 | +// Using Composer-generated autoload file. |
| 4 | +require 'vendor/autoload.php'; |
| 5 | + |
| 6 | +// Or, uncomment the line below if you're not using Composer autoloader. |
| 7 | +// require_once('lib/CybsSoapClient.php'); |
| 8 | + |
| 9 | +try { |
| 10 | + $client = new CybsSoapClient(array('trace'=>1)); |
| 11 | + |
| 12 | + $request = $client->createRequest(); |
| 13 | + |
| 14 | + // Before using this example, replace the generic value with your own. |
| 15 | + $request->merchantReferenceCode = "your_merchant_reference_code"; |
| 16 | + |
| 17 | + // To help us troubleshoot any problems that you may encounter, |
| 18 | + // please include the following information about your PHP application. |
| 19 | + $request->clientLibrary = "PHP"; |
| 20 | + $request->clientLibraryVersion = phpversion(); |
| 21 | + $request->clientEnvironment = php_uname(); |
| 22 | + |
| 23 | + // This section contains a sample transaction request for the authorization |
| 24 | + // service with complete billing, payment card, and purchase (two items) information. |
| 25 | + $ccAuthService = new stdClass(); |
| 26 | + $ccAuthService->run = "true"; |
| 27 | + $request->ccAuthService = $ccAuthService; |
| 28 | + |
| 29 | + $billTo = new stdClass(); |
| 30 | + $billTo->firstName = "John"; |
| 31 | + $billTo->lastName = "Doe"; |
| 32 | + $billTo->street1 = "1295 Charleston Road"; |
| 33 | + $billTo->city = "Mountain View"; |
| 34 | + $billTo->state = "CA"; |
| 35 | + $billTo->postalCode = "94043"; |
| 36 | + $billTo->country = "US"; |
| 37 | + $billTo->email = "null@cybersource.com"; |
| 38 | + $billTo->ipAddress = "10.7.111.111"; |
| 39 | + $request->billTo = $billTo; |
| 40 | + |
| 41 | + $card = new stdClass(); |
| 42 | + $card->accountNumber = "4111111111111111"; |
| 43 | + $card->expirationMonth = "12"; |
| 44 | + $card->expirationYear = "2020"; |
| 45 | + $request->card = $card; |
| 46 | + |
| 47 | + $purchaseTotals = new stdClass(); |
| 48 | + $purchaseTotals->currency = "USD"; |
| 49 | + $request->purchaseTotals = $purchaseTotals; |
| 50 | + |
| 51 | + $item0 = new stdClass(); |
| 52 | + $item0->unitPrice = "12.34"; |
| 53 | + $item0->quantity = "2"; |
| 54 | + $item0->id = "0"; |
| 55 | + |
| 56 | + $item1 = new stdClass(); |
| 57 | + $item1->unitPrice = "56.78"; |
| 58 | + $item1->id = "1"; |
| 59 | + |
| 60 | + $request->item = array($item0, $item1); |
| 61 | + |
| 62 | + $reply = $client->runTransaction($request); |
| 63 | + |
| 64 | + // This section will show all the reply fields. |
| 65 | + var_dump($reply); |
| 66 | + |
| 67 | +} catch (SoapFault $exception) { |
| 68 | + var_dump($exception); |
| 69 | +} |
| 70 | + |
| 71 | + |
0 commit comments