/** * @param int $dataProviderIndex * @param string $operation * @param string $responseCode * @param array $additionalPaymentData * @param string $expectedResponse * @param string $keyNameForActualResponse * @param string $expectedExceptionMessage * @param bool $isOutput * * @dataProvider providerTestRavenFullSuite */ public function testRavenFullSuite($dataProviderIndex, $operation, $responseCode, array $additionalPaymentData = null, $expectedResponse, $keyNameForActualResponse, $expectedExceptionMessage, $isOutput = false) { $this->isOutput = $isOutput; try { $rvn = new Raven(self::ACCESSKEY_ID, self::ACCESSKEY_SECRET); //See Programmatic Magic Cards for details: //https://docs.deepcovelabs.com/card/#testing-with-the-programmatic-magic-cards //Add "PaymentReference"=>"ApprovedTest_20160303_1720_0[US:VI:Approved]" // "PaymentReference"=> {ClientReference(text)}[{CountryCode}:{SchemeCode}:{ResponseCode}] $clientReference = "Test_" . $dataProviderIndex . "_" . gmdate('Ymd'); date_default_timezone_set('utc'); $expiry_date = (new \DateTime('now'))->add(new \DateInterval('P2Y'))->format('my'); $payment_data = array_merge(self::BASE_PAYMENT_DATA, ["ExpiryDate" => $expiry_date, "PaymentReference" => $clientReference . $responseCode]); if (!empty($additionalPaymentData)) { $payment_data = array_merge($payment_data, $additionalPaymentData); } $req = new Request($operation, $payment_data); $resp = $rvn->send($req); $this->assertEquals($expectedResponse, $resp->get($keyNameForActualResponse)); //Echo output $this->echoOutput($dataProviderIndex, $req, $resp); } catch (Exceptions\ResponseException $e) { $this->assertEquals($expectedExceptionMessage, $e->getMessage()); $this->echoOutput($dataProviderIndex, $req); $this->echoExceptions($e); } catch (Exceptions\SignatureException $e) { $this->assertEquals($expectedExceptionMessage, $e->getMessage()); $this->echoOutput($dataProviderIndex, $req); $this->echoExceptions($e); } }
* Raven Magic Card Example * Version: * v2.3.0 * Purpose: * Demonstrates how to use the Raven Helper library to report on past payments * and the events associated with them. * Usage: * Open command prompt in containing directory and run "php payment_reporting.php". * See: * For full documentation see "https://docs.deepcovelabs.com/card/#payments-reporting-endpoint" */ require '../vendor/autoload.php'; use Raven\Raven; date_default_timezone_set('UTC'); # First, instantiate the SDK with your AccessKey_ID and AccessKey_Secret. $rvn = new Raven('ernest', 'all good men die young'); $helloResp = $rvn->hello(); $endTime = new DateTime(); $startTime = new DateTime(); // setting it 1 day $startTime->sub(new DateInterval('P1D')); // ReportRequest Data $reportData = ["ReportFormat" => "RavenPaymentFile_v1.0", "StartTime" => $startTime->format('Y-m-d\\TH:i:s'), "EndTime" => $endTime->format('Y-m-d\\TH:i:s'), "ResultFields" => 'RoutingNumber PaymentType Amount Currency CardNumber ApprovalCode']; $reportRequest = new \Raven\Request('payments', $reportData); echo "Raven operation: " . $reportRequest->getOperation() . "\n"; echo "Request: " . json_encode($reportRequest->all(), JSON_PRETTY_PRINT) . "\n"; $reportResp = $rvn->send($reportRequest); echo "Response: " . json_encode($reportResp->all(), JSON_PRETTY_PRINT) . "\n"; $pmtReportLines = explode("\r", $reportResp->get("Report")); echo "\n"; foreach ($pmtReportLines as $reportLine) {
* 3. The result response from the backend, eg 'Approved', 'Declined' etc for valid payments. * Payments that are invalid are unaffected, for example those whose PRN does not accept * certain cards. * For example, including the string '[CA:VI:Approved]' in the PaymentReference field of a * payment forces the payment card to be a Canadian Visa card, and attempts to force the Raven * backend to approve the payment. * Usage: * Open command prompt in containing directory and run "php programic_magic_card.php". * See: * For full documentation see "https://docs.deepcovelabs.com/card/#article-all-rapi-endpoints" */ require '../vendor/autoload.php'; use Raven\Raven; date_default_timezone_set('UTC'); # First, instantiate the SDK with your AccessKey_ID and AccessKey_Secret. $rvn = new Raven('ernest', 'all good men die young'); // Payment processing request reused several times $paymentData = ["RoutingNumber" => "987743", "Currency" => "USD", "CardNumber" => "4242424242424242", "ExpiryDate" => "0919", "PaymentType" => "cc_debit", "Amount" => 4321]; # Set Magic Card for canadian payment $paymentReq = new \Raven\Request('submit', $paymentData); $paymentReq->set('PaymentReference', 'approvedtest[CA:VI:Approved]'); echo "Request: " . json_encode($paymentReq->all(), JSON_PRETTY_PRINT) . "\n"; $paymentResp = $rvn->send($paymentReq); echo "Response: " . json_encode($paymentResp->all(), JSON_PRETTY_PRINT) . "\n"; # Submit an intentionally unsuccessful canadian payment $paymentReq = new \Raven\Request('submit', $paymentData); $paymentReq->set('PaymentReference', 'declinedtest[CA:VI:Declined]'); echo "Request: " . json_encode($paymentReq->all(), JSON_PRETTY_PRINT) . "\n"; $paymentResp = $rvn->send($paymentReq); echo "Response: " . json_encode($paymentResp->all(), JSON_PRETTY_PRINT) . "\n"; # Submit a US payment that fails because US cards are not allowed on gaming PRNs