diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 51ddfcf..64283f1 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -23,7 +23,37 @@ public function getData() $data['type'] = $this->getType(); $data['amount'] = $this->getAmount(); $data['currency'] = $this->getCurrency(); - $data['callbackUrls'] = []; + + $data = array_merge($data, $this->getStoredCardData()); + $data = array_merge($data, $this->getRecurringOptionsData()); + $data = array_merge($data, $this->getMiscOptionsData()); + $data = array_merge($data, $this->getCallbackUrlsData()); + + return $data; + } + + public function sendData($data) + { + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + 'Authorization' => 'Basic ' . $this->getAuthorization(), + ]; + + $httpResponse = $this->httpClient->request('POST', $this->getEndpoint('sessions'), $headers, json_encode($data)); + + try { + $responseData = json_decode($httpResponse->getBody()->getContents()); + } catch (\Exception $exception) { + $responseData = []; + } + + return $this->response = new PurchaseResponse($this, $responseData ?? []); + } + + protected function getStoredCardData() + { + $data = []; if ( (bool) $this->getCreateToken() ) { $data['storeCard'] = true; @@ -33,36 +63,38 @@ public function getData() $data['storedCardIndicator'] = $this->getStoredCardIndicator(); } - if ( $this->getRecurringExpiry() ) { - $data['recurringExpiry'] = $this->getRecurringExpiry(); - } - - if ( $this->getRecurringFrequency() ) { - $data['recurringFrequency'] = $this->getRecurringFrequency(); - } - if ( $this->getToken() || $this->getCardReference() ) { $data['cardId'] = $this->getToken() ?? $this->getCardReference(); } - if ( is_array($this->getPaymentMethods()) ) { - $data['methods'] = $this->getPaymentMethods(); - } - if ( is_array($this->getCardTypes()) ) { $data['cardTypes'] = $this->getCardTypes(); } - if ( is_array($this->getMetadata()) ) { - $data['metaData'] = $this->getMetadata(); - } + return $data; + } - $merchantReference = $this->getMerchantReference() ?? $this->getDescription(); + protected function getRecurringOptionsData() + { + $data = []; - if ( $merchantReference ) { - $data['merchantReference'] = $merchantReference; + if ( $this->getRecurringExpiry() ) { + $data['recurringExpiry'] = $this->getRecurringExpiry(); + } + + if ( $this->getRecurringFrequency() ) { + $data['recurringFrequency'] = $this->getRecurringFrequency(); } + return $data; + } + + protected function getCallbackUrlsData() + { + $data = [ + 'callbackUrls' => [] + ]; + if ( $this->getReturnUrl() ) { $data['callbackUrls']['approved'] = $this->getReturnUrl(); } @@ -82,22 +114,24 @@ public function getData() return $data; } - public function sendData($data) + protected function getMiscOptionsData() { - $headers = [ - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'Authorization' => 'Basic ' . $this->getAuthorization(), - ]; + $data = []; - $httpResponse = $this->httpClient->request('POST', $this->getEndpoint('sessions'), $headers, json_encode($data)); + if ( is_array($this->getPaymentMethods()) ) { + $data['methods'] = $this->getPaymentMethods(); + } - try { - $responseData = json_decode($httpResponse->getBody()->getContents()); - } catch (\Exception $exception) { - $responseData = []; + if ( is_array($this->getMetadata()) ) { + $data['metaData'] = $this->getMetadata(); } - return $this->response = new PurchaseResponse($this, $responseData ?? []); + $merchantReference = $this->getMerchantReference() ?? $this->getDescription(); + + if ( $merchantReference ) { + $data['merchantReference'] = $merchantReference; + } + + return $data; } } diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php index 3dc7d8f..c408ad6 100644 --- a/tests/GatewayTest.php +++ b/tests/GatewayTest.php @@ -3,6 +3,7 @@ namespace Omnipay\WindcaveHpp; use Omnipay\Tests\GatewayTestCase; +use Omnipay\Common\Message\NotificationInterface; class GatewayTest extends GatewayTestCase { @@ -16,15 +17,128 @@ public function setUp(): void $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); $this->options = [ + 'apiUsername' => 'merchant', + 'apiKey' => 'apikey', 'amount' => '1.45', - 'apiUsername' => 'Test_Merchant', - 'apiKey' => 'ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890', 'currency' => 'NZD', 'cancelUrl' => 'https://www.example.com/cancel', 'notifyUrl' => 'https://www.example.com/notify', 'returnUrl' => 'https://www.example.com/return', - 'transactionId' => '123abc', + 'transactionId' => 'transaction123', 'testMode' => true, + 'description' => 'Test Transaction', + 'type' => 'purchase' ]; } + + public function testPurchaseSuccess() + { + $this->setMockHttpResponse('PurchaseSuccess.txt'); + + $request = $this->gateway->purchase($this->options); + $response = $request->send(); + + $this->assertFalse($response->isSuccessful()); + $this->assertTrue($response->isRedirect()); + $this->assertSame('GET', $response->getRedirectMethod()); + $this->assertSame('https://uat.windcave.com/pxmi3/session1234', $response->getRedirectUrl()); + $this->assertSame([], $response->getRedirectData()); + } + + public function testCompletePurchaseSuccess() + { + $this->setMockHttpResponse('CompletePurchaseSuccess.txt'); + + $request = $this->gateway->completePurchase([ + 'apiUsername' => $this->options['apiUsername'], + 'apiKey' => $this->options['apiKey'], + 'sessionId' => 'session123', + 'testMode' => true, + ]); + + $this->getHttpRequest()->request->set('sessionId','session123'); + + $response = $request->send(); + + $this->assertTrue($response->isSuccessful()); + $this->assertSame('APPROVED', $response->getResponseText()); + $this->assertSame('session123', $response->getSessionId()); + $this->assertSame('merchantRef123', $response->getTransactionId()); + $this->assertSame('transaction123', $response->getTransactionReference()); + $this->assertSame('411111......1111', $response->getCard()['cardNumber']); + } + + public function testAcceptNotificationPaid() + { + $this->setMockHttpResponse('CompletePurchaseSuccess.txt'); + + $this->getHttpRequest()->request->set('sessionId','session123'); + + $notification = $this->gateway->acceptNotification([ + 'apiUsername' => $this->options['apiUsername'], + 'apiKey' => $this->options['apiKey'], + 'sessionId' => 'session123', + 'testMode' => true, + ]); + + $this->assertSame(NotificationInterface::STATUS_COMPLETED, $notification->getTransactionStatus()); + $this->assertSame('transaction123', $notification->getTransactionReference()); + } + + + public function testAcceptNotificationFailed() + { + $this->setMockHttpResponse('CompletePurchaseFailed.txt'); + + $this->getHttpRequest()->request->set('sessionId','session123'); + + $notification = $this->gateway->acceptNotification([ + 'apiUsername' => $this->options['apiUsername'], + 'apiKey' => $this->options['apiKey'], + 'sessionId' => 'SESSION123', + 'testMode' => true, + ]); + + $this->assertSame(NotificationInterface::STATUS_FAILED, $notification->getTransactionStatus()); + } + + public function testRefundSuccess() + { + $this->setMockHttpResponse('RefundSuccess.txt'); + + $request = $this->gateway->refund([ + 'apiUsername' => $this->options['apiUsername'], + 'apiKey' => $this->options['apiKey'], + 'amount' => '1.00', + 'currency' => 'GBP', + 'transactionReference' => 'refundtransaction123', + 'testMode' => true, + ]); + + $response = $request->send(); + + $this->assertTrue($response->isSuccessful()); + $this->assertSame('refundtransaction123', $response->getTransactionReference()); + $this->assertSame('APPROVED', $response->getMessage()); + } + + public function testRefundFailed() + { + $this->setMockHttpResponse('RefundFailed.txt'); + + $request = $this->gateway->refund([ + 'apiUsername' => $this->options['apiUsername'], + 'apiKey' => $this->options['apiKey'], + 'amount' => '1.00', + 'currency' => 'GBP', + 'transactionReference' => 'refundtransaction123', + 'testMode' => true, + ]); + + $response = $request->send(); + + $this->assertFalse($response->isSuccessful()); + $this->assertSame('refundtransaction123', $response->getTransactionReference()); + $this->assertSame('DECLINED', $response->getMessage()); + } } diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php new file mode 100644 index 0000000..9a720d6 --- /dev/null +++ b/tests/Message/PurchaseRequestTest.php @@ -0,0 +1,126 @@ +options = [ + 'apiUsername' => 'merchant', + 'apiKey' => 'apikey', + 'amount' => '1.45', + 'currency' => 'NZD', + 'returnUrl' => 'https://example.com/return', + 'cancelUrl' => 'https://example.com/cancel', + 'notifyUrl' => 'https://example.com/notify', + 'transactionId' => 'transaction123', + 'testMode' => true, + ]; + + $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize($this->options); + } + + public function testApiKeys(): void + { + $this->request->setApiUsername('user123'); + $this->request->setApiKey('key123'); + + $this->assertSame('user123', $this->request->getApiUsername()); + $this->assertSame('key123', $this->request->getApiKey()); + } + + public function testRequiredParameters(): void + { + $data = $this->request->getData(); + + $this->assertArrayHasKey('amount', $data); + $this->assertArrayHasKey('currency', $data); + } + + public function testRedirect(): void + { + $this->setMockHttpResponse('PurchaseSuccess.txt'); + + $response = $this->request->send(); + + $this->assertFalse($response->isSuccessful()); + $this->assertTrue($response->isRedirect()); + $this->assertSame('GET', $response->getRedirectMethod()); + $this->assertSame('https://uat.windcave.com/pxmi3/session1234', $response->getRedirectUrl()); + $this->assertSame([], $response->getRedirectData()); + } + + public function testReturnUrls(): void + { + $this->request->setReturnUrl('https://example.com/return'); + $this->request->setDeclineUrl('https://example.com/decline'); + $this->request->setCancelUrl('https://example.com/cancel'); + $this->request->setNotifyUrl('https://example.com/notify'); + + $data = $this->request->getData(); + + $this->assertSame('https://example.com/return', $data['callbackUrls']['approved']); + $this->assertSame('https://example.com/decline', $data['callbackUrls']['declined']); + $this->assertSame('https://example.com/cancel', $data['callbackUrls']['cancelled']); + $this->assertSame('https://example.com/notify', $data['notificationUrl']); + } + + public function testCreateTokenSetsStoreCardTrue(): void + { + $this->request->setCreateToken(true); + $data = $this->request->getData(); + $this->assertArrayHasKey('storeCard', $data); + $this->assertTrue($data['storeCard']); + } + + public function testStoredCardIndicator(): void + { + $this->request->setStoredCardIndicator('credentialonfileinitial'); + $data = $this->request->getData(); + $this->assertSame('credentialonfileinitial', $data['storedCardIndicator']); + } + + public function testRecurringFields(): void + { + $this->request->setRecurringFrequency('monthly'); + $this->request->setRecurringExpiry('9999-12-31'); + $data = $this->request->getData(); + $this->assertSame('monthly', $data['recurringFrequency']); + $this->assertSame('9999-12-31', $data['recurringExpiry']); + } + + public function testCardIdFromToken(): void + { + $this->request->setToken('tok_abc'); + $data = $this->request->getData(); + $this->assertSame('tok_abc', $data['cardId']); + } + + public function testCardIdFromCardReference(): void + { + $this->request->setToken(null); + $this->request->setCardReference('card_ref_123'); + $data = $this->request->getData(); + $this->assertSame('card_ref_123', $data['cardId']); + } + + public function testPaymentMethodsAndCardTypesAndMetadata(): void + { + $this->request->setPaymentMethods(['card', 'alipay']); + $this->request->setCardTypes(['visa', 'mastercard']); + $this->request->setMetadata(['key' => 'value']); + + $data = $this->request->getData(); + + $this->assertSame(['card', 'alipay'], $data['methods']); + $this->assertSame(['visa', 'mastercard'], $data['cardTypes']); + $this->assertSame(['key' => 'value'], $data['metaData']); + } +} \ No newline at end of file diff --git a/tests/Message/PurchaseResponseTest.php b/tests/Message/PurchaseResponseTest.php new file mode 100644 index 0000000..addf66f --- /dev/null +++ b/tests/Message/PurchaseResponseTest.php @@ -0,0 +1,36 @@ +getMockRequest(), (object) [ + 'links' => [ + (object) ['rel' => 'self', 'href' => 'https://uat.windcave.com/api/v1/sessions/session1234', 'method' => 'GET'], + (object) ['rel' => 'hpp', 'href' => 'https://uat.windcave.com/pxmi3/session1234', 'method' => 'REDIRECT'], + (object) ['rel' => 'hpp', 'href' => 'https://uat.windcave.com/api/v1/sessions/session1234', 'method' => 'PATCH'], + ], + ]); + + $this->assertTrue($response->isRedirect()); + $this->assertSame('GET', $response->getRedirectMethod()); + $this->assertSame( + 'https://uat.windcave.com/pxmi3/session1234', + $response->getRedirectUrl() + ); + } + + public function testGetRedirectUrlThrowsWhenMissing(): void + { + $this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class); + + $resp = new PurchaseResponse($this->getMockRequest(), (object) ['links' => [(object) ['rel' => 'self', 'href' => 'x']]]); + + $resp->getRedirectUrl(); + } +} \ No newline at end of file diff --git a/tests/Message/RefundRequestTest.php b/tests/Message/RefundRequestTest.php new file mode 100644 index 0000000..6cb4988 --- /dev/null +++ b/tests/Message/RefundRequestTest.php @@ -0,0 +1,63 @@ +options = [ + 'apiUsername' => 'merchant', + 'apiKey' => 'apikey', + 'amount' => '1.45', + 'currency' => 'NZD', + ]; + + $this->request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize($this->options); + $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); + } + + public function testApiKeys(): void + { + $this->request->setApiUsername('user123'); + $this->request->setApiKey('key123'); + + $this->assertSame('user123', $this->request->getApiUsername()); + $this->assertSame('key123', $this->request->getApiKey()); + } + + public function testRequiredParameters(): void + { + $this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class); + $data = $this->request->getData(); + + $this->assertArrayHasKey('amount', $data); + $this->assertArrayHasKey('currency', $data); + } + + public function testRefundSuccess(): void + { + $this->setMockHttpResponse('RefundSuccess.txt'); + + $request = $this->gateway->refund([ + 'apiUsername' => 'merchant', + 'apiKey' => 'apikey', + 'amount' => '1.45', + 'currency' => 'NZD', + 'transactionReference' => 'refundtransaction123', + 'testMode' => true, + ]); + + $response = $request->send(); + + $this->assertTrue($response->isSuccessful()); + $this->assertSame('refundtransaction123', $response->getTransactionReference()); + $this->assertSame('APPROVED', $response->getMessage()); + } +} \ No newline at end of file diff --git a/tests/Message/RefundResponseTest.php b/tests/Message/RefundResponseTest.php new file mode 100644 index 0000000..a0653bb --- /dev/null +++ b/tests/Message/RefundResponseTest.php @@ -0,0 +1,36 @@ +getMockRequest(), (object) [ + 'id' => 'refundtransaction123', + 'type' => 'refund', + 'responseText' => 'APPROVED', + 'authorised' => true + ]); + + $this->assertTrue($response->isSuccessful()); + $this->assertSame('refundtransaction123', $response->getTransactionReference()); + $this->assertSame('APPROVED', $response->getMessage()); + } + + public function testRefundFailure() + { + $response = new RefundResponse($this->getMockRequest(), (object) [ + 'id' => 'refundtransaction123', + 'type' => 'refund', + 'responseText' => 'DECLINED', + 'authorised' => true + ]); + + $this->assertFalse($response->isSuccessful()); + $this->assertSame('refundtransaction123', $response->getTransactionReference()); + $this->assertSame('DECLINED', $response->getMessage()); + } +} \ No newline at end of file diff --git a/tests/Mock/CompletePurchaseFailed.txt b/tests/Mock/CompletePurchaseFailed.txt new file mode 100644 index 0000000..3e3d4fe --- /dev/null +++ b/tests/Mock/CompletePurchaseFailed.txt @@ -0,0 +1,108 @@ +HTTP/1.1 200 OK +Date: Thu, 01 May 2025 01:43:28 GMT +Content-Type: application/json; charset=utf-8 + +{ + "id": "session123", + "state": "complete", + "type": "purchase", + "amount": "20.00", + "currency": "GBP", + "currencyNumeric": 826, + "merchantReference": "merchantRef1234", + "methods": [ + "card", + "paypal", + "applepay", + "googlepay", + "klarna" + ], + "expires": "2025-08-20T21:45:26Z", + "callbackUrls": { + "approved": "http://www.example.com/return", + "declined": "http://www.example.com/decline", + "cancelled": "http://www.example.com/cancel" + }, + "notificationUrl": "http://www.example.com/notify", + "storeCard": false, + "clientType": "internet", + "links": [ + { + "href": "https://uat.windcave.com/api/v1/sessions/session123", + "rel": "self", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/api/v1/transactions/transaction123", + "rel": "transaction", + "method": "GET" + } + ], + "transactions": [ + { + "id": "transaction123", + "username": "merchant", + "authorised": true, + "allowRetry": false, + "retryIndicator": "", + "reCo": "00", + "responseText": "FAILED", + "authCode": "019533", + "acquirer": { + "name": "Undefined", + "mid": "10000000", + "tid": "10001548", + "reCo": "00", + "responseText": "FAILED" + }, + "type": "purchase", + "method": "card", + "localTimeZone": "UK_GMT", + "dateTimeUtc": "2025-08-17T22:06:51Z", + "dateTimeLocal": "2025-08-17T23:06:51+01:00", + "settlementDate": "2025-08-18", + "amount": "20.00", + "balanceAmount": "0.00", + "currency": "GBP", + "currencyNumeric": 826, + "clientType": "internet", + "merchantReference": "merchantRef123", + "card": { + "cardNumber2": "1111111111111111", + "cardHolderName": "WHPP", + "cardNumber": "411111......1111", + "dateExpiryMonth": "05", + "dateExpiryYear": "28", + "type": "visa" + }, + "cvc2ResultCode": "U", + "storedCardIndicator": "single", + "notificationUrl": "http://www.example.com/notify", + "sessionId": "session123", + "browser": { + "ipAddress": "192.168.1.1", + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36" + }, + "isSurcharge": false, + "amountTotal": "20.00", + "liabilityIndicator": "standard", + "links": [ + { + "href": "https://uat.windcave.com/api/v1/transactions/transaction123", + "rel": "self", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/api/v1/sessions/session123", + "rel": "session", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/api/v1/transactions", + "rel": "refund", + "method": "POST" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/Mock/CompletePurchaseSuccess.txt b/tests/Mock/CompletePurchaseSuccess.txt new file mode 100644 index 0000000..bc56d96 --- /dev/null +++ b/tests/Mock/CompletePurchaseSuccess.txt @@ -0,0 +1,108 @@ +HTTP/1.1 200 OK +Date: Thu, 01 May 2025 01:43:28 GMT +Content-Type: application/json; charset=utf-8 + +{ + "id": "session123", + "state": "complete", + "type": "purchase", + "amount": "20.00", + "currency": "GBP", + "currencyNumeric": 826, + "merchantReference": "merchantRef1234", + "methods": [ + "card", + "paypal", + "applepay", + "googlepay", + "klarna" + ], + "expires": "2025-08-20T21:45:26Z", + "callbackUrls": { + "approved": "http://www.example.com/return", + "declined": "http://www.example.com/decline", + "cancelled": "http://www.example.com/cancel" + }, + "notificationUrl": "http://www.example.com/notify", + "storeCard": false, + "clientType": "internet", + "links": [ + { + "href": "https://uat.windcave.com/api/v1/sessions/session123", + "rel": "self", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/api/v1/transactions/transaction123", + "rel": "transaction", + "method": "GET" + } + ], + "transactions": [ + { + "id": "transaction123", + "username": "merchant", + "authorised": true, + "allowRetry": false, + "retryIndicator": "", + "reCo": "00", + "responseText": "APPROVED", + "authCode": "019533", + "acquirer": { + "name": "Undefined", + "mid": "10000000", + "tid": "10001548", + "reCo": "00", + "responseText": "APPROVED" + }, + "type": "purchase", + "method": "card", + "localTimeZone": "UK_GMT", + "dateTimeUtc": "2025-08-17T22:06:51Z", + "dateTimeLocal": "2025-08-17T23:06:51+01:00", + "settlementDate": "2025-08-18", + "amount": "20.00", + "balanceAmount": "0.00", + "currency": "GBP", + "currencyNumeric": 826, + "clientType": "internet", + "merchantReference": "merchantRef123", + "card": { + "cardNumber2": "1111111111111111", + "cardHolderName": "WHPP", + "cardNumber": "411111......1111", + "dateExpiryMonth": "05", + "dateExpiryYear": "28", + "type": "visa" + }, + "cvc2ResultCode": "U", + "storedCardIndicator": "single", + "notificationUrl": "http://www.example.com/notify", + "sessionId": "session123", + "browser": { + "ipAddress": "192.168.1.1", + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36" + }, + "isSurcharge": false, + "amountTotal": "20.00", + "liabilityIndicator": "standard", + "links": [ + { + "href": "https://uat.windcave.com/api/v1/transactions/transaction123", + "rel": "self", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/api/v1/sessions/session123", + "rel": "session", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/api/v1/transactions", + "rel": "refund", + "method": "POST" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/Mock/PurchaseSuccess.txt b/tests/Mock/PurchaseSuccess.txt new file mode 100644 index 0000000..5e1d4b4 --- /dev/null +++ b/tests/Mock/PurchaseSuccess.txt @@ -0,0 +1,25 @@ +HTTP/1.1 200 OK +Date: Thu, 01 May 2025 01:43:28 GMT +Content-Type: application/json; charset=utf-8 + +{ + "id": "000003000808885103d0e8240fe03294", + "state": "init", + "links": [ + { + "href": "https://uat.windcave.com/api/v1/sessions/session1234", + "rel": "self", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/pxmi3/session1234", + "rel": "hpp", + "method": "REDIRECT" + }, + { + "href": "https://uat.windcave.com/api/v1/sessions/session1234", + "rel": "cancel", + "method": "PATCH" + } + ] +} \ No newline at end of file diff --git a/tests/Mock/RefundFailed.txt b/tests/Mock/RefundFailed.txt new file mode 100644 index 0000000..eea1ac0 --- /dev/null +++ b/tests/Mock/RefundFailed.txt @@ -0,0 +1,55 @@ +HTTP/1.1 200 OK +Date: Thu, 01 May 2025 01:43:28 GMT +Content-Type: application/json; charset=utf-8 + +{ + "id": "refundtransaction123", + "username": "merchant", + "authorised": true, + "allowRetry": false, + "retryIndicator": "", + "reCo": "00", + "responseText": "DECLINED", + "authCode": "001412", + "acquirer": { + "name": "Undefined", + "reCo": "", + "responseText": "" + }, + "type": "refund", + "method": "card", + "localTimeZone": "UK_GMT", + "dateTimeUtc": "2025-08-19T01:34:55Z", + "dateTimeLocal": "2025-08-19T02:34:55+01:00", + "settlementDate": "2025-08-19", + "amount": "1.00", + "balanceAmount": "0.00", + "currency": "GBP", + "currencyNumeric": 826, + "clientType": "internet", + "merchantReference": "test1755567267ref", + "card": { + "cardNumber2": "9310200000000010", + "cardHolderName": "WHPP", + "cardNumber": "411111......1111", + "dateExpiryMonth": "02", + "dateExpiryYear": "29", + "type": "visa" + }, + "cvc2ResultCode": "P", + "isSurcharge": false, + "amountTotal": "1.00", + "liabilityIndicator": "standard", + "links": [ + { + "href": "https://uat.windcave.com/api/v1/transactions/00000004018b76c6", + "rel": "self", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/api/v1/transactions/00000004018b74de", + "rel": "parent", + "method": "GET" + } + ] +} \ No newline at end of file diff --git a/tests/Mock/RefundSuccess.txt b/tests/Mock/RefundSuccess.txt new file mode 100644 index 0000000..04e043d --- /dev/null +++ b/tests/Mock/RefundSuccess.txt @@ -0,0 +1,57 @@ +HTTP/1.1 200 OK +Date: Thu, 01 May 2025 01:43:28 GMT +Content-Type: application/json; charset=utf-8 + +{ + "id": "refundtransaction123", + "username": "merchant", + "authorised": true, + "allowRetry": false, + "retryIndicator": "", + "reCo": "00", + "responseText": "APPROVED", + "authCode": "001412", + "acquirer": { + "name": "Undefined", + "mid": "10000000", + "tid": "10001548", + "reCo": "00", + "responseText": "APPROVED" + }, + "type": "refund", + "method": "card", + "localTimeZone": "UK_GMT", + "dateTimeUtc": "2025-08-19T01:34:55Z", + "dateTimeLocal": "2025-08-19T02:34:55+01:00", + "settlementDate": "2025-08-19", + "amount": "1.00", + "balanceAmount": "0.00", + "currency": "GBP", + "currencyNumeric": 826, + "clientType": "internet", + "merchantReference": "test1755567267ref", + "card": { + "cardNumber2": "9310200000000010", + "cardHolderName": "WHPP", + "cardNumber": "411111......1111", + "dateExpiryMonth": "02", + "dateExpiryYear": "29", + "type": "visa" + }, + "cvc2ResultCode": "P", + "isSurcharge": false, + "amountTotal": "1.00", + "liabilityIndicator": "standard", + "links": [ + { + "href": "https://uat.windcave.com/api/v1/transactions/00000004018b76c6", + "rel": "self", + "method": "GET" + }, + { + "href": "https://uat.windcave.com/api/v1/transactions/00000004018b74de", + "rel": "parent", + "method": "GET" + } + ] +} \ No newline at end of file