Example #1
0
 public function makePayment()
 {
     $payment = $this->getPayment();
     $request = new MakePaymentRequest();
     $billTransaction = new BillTransaction();
     //        $billTransaction->setBillType('Bill Payment');
     $billTransaction->setID1(1);
     $billTransaction->setAmountToApplyToBill(static::$amount);
     $request->getBillTransactions()->setBillTransaction(array($billTransaction));
     $tokenToCharge = new TokenToCharge();
     $tokenToCharge->setAmount(static::$amount);
     $tokenToCharge->setCardProcessingMethod(CardProcessingMethod::UNASSIGNED);
     $tokenToCharge->setExpectedFeeAmount(static::$feeAmount);
     $tokenToCharge->setToken(static::$token);
     $request->getTokensToCharge()->setTokenToCharge(array($tokenToCharge));
     $transaction = new Transaction();
     $transaction->setAmount(static::$amount);
     $transaction->setFeeAmount(static::$feeAmount);
     $request->setTransaction($transaction);
     $paymentDetails = new PaymentDetails();
     $paymentDetails->setMerchantName($GLOBALS['__PAYUM_HEARTLAND_MERCHANT_NAME']);
     $paymentDetails->setRequest($request);
     $captureRequest = new CaptureRequest($paymentDetails);
     $payment->execute($captureRequest);
     $statusRequest = new BinaryMaskStatusRequest($captureRequest->getModel());
     $payment->execute($statusRequest);
     /** @var GetTokenResponse $response */
     $response = $statusRequest->getModel()->getResponse();
     $this->assertTrue($statusRequest->isSuccess(), $paymentDetails->getMessages());
 }
Example #2
0
 /**
  * @test
  */
 public function shouldAllowCaptureMakePaymentRequest()
 {
     $payment = $this->getPayment();
     $request = new MakePaymentRequest();
     $billTransaction = new BillTransaction();
     //        $billTransaction->setBillType('Bill Payment');
     $billTransaction->setID1(1);
     $billTransaction->setAmountToApplyToBill(1.0);
     $request->getBillTransactions()->setBillTransaction(array($billTransaction));
     $blearTextCardToCharge = new ClearTextCardToCharge();
     $blearTextCardToCharge->setAmount(1.0);
     $blearTextCardToCharge->setCardProcessingMethod(CardProcessingMethod::CREDIT);
     $blearTextCardToCharge->setExpectedFeeAmount(0.03);
     $blearTextCardToCharge->getClearTextCreditCard()->setCardNumber('5473500000000014');
     $now = new DateTime('+1 year');
     $blearTextCardToCharge->getClearTextCreditCard()->setExpirationMonth($now->format('m'));
     $blearTextCardToCharge->getClearTextCreditCard()->setExpirationYear($now->format('Y'));
     $blearTextCardToCharge->getClearTextCreditCard()->setVerificationCode(123);
     $request->getClearTextCreditCardsToCharge()->setClearTextCardToCharge(array($blearTextCardToCharge));
     $request->setIncludeReceiptInResponse(false);
     $request->getTransaction()->setAmount(1.0);
     $request->getTransaction()->setFeeAmount(0.03);
     $request->getTransaction()->setTransactionDate(null);
     $paymentDetails = new PaymentDetails();
     $paymentDetails->setMerchantName($GLOBALS['__PAYUM_HEARTLAND_MERCHANT_NAME']);
     $paymentDetails->setRequest($request);
     $captureRequest = new CaptureRequest($paymentDetails);
     $payment->execute($captureRequest);
     $statusRequest = new BinaryMaskStatusRequest($captureRequest->getModel());
     $payment->execute($statusRequest);
     $model = $statusRequest->getModel();
     $this->assertTrue($statusRequest->isSuccess());
     $this->assertNotEmpty($model['transactionId']);
 }