|
4 | 4 |
|
5 | 5 | use Omnipay\Common\CreditCard;
|
6 | 6 | use Omnipay\PayPal\Message\ExpressAuthorizeRequest;
|
| 7 | +use Omnipay\PayPal\Support\InstantUpdateApi\BillingAgreement; |
7 | 8 | use Omnipay\PayPal\Support\InstantUpdateApi\ShippingOption;
|
8 | 9 | use Omnipay\Tests\TestCase;
|
9 | 10 |
|
@@ -372,4 +373,51 @@ public function testBadCallbackConfiguration()
|
372 | 373 | $this->request->getData();
|
373 | 374 | }
|
374 | 375 |
|
| 376 | + public function testGetDataWithSingleBillingAgreement() |
| 377 | + { |
| 378 | + $billingAgreement = new BillingAgreement(false, 'Some Stuff'); |
| 379 | + $this->request->setBillingAgreement($billingAgreement); |
| 380 | + |
| 381 | + $data = $this->request->getData(); |
| 382 | + |
| 383 | + $this->assertSame('MerchantInitiatedBillingSingleAgreement', $data['L_BILLINGTYPE0']); |
| 384 | + $this->assertSame('Some Stuff', $data['L_BILLINGAGREEMENTDESCRIPTION0']); |
| 385 | + } |
| 386 | + |
| 387 | + public function testGetDataWithRecurringBillingAgreement() |
| 388 | + { |
| 389 | + $billingAgreement = new BillingAgreement(true, 'Some Stuff'); |
| 390 | + $this->request->setBillingAgreement($billingAgreement); |
| 391 | + |
| 392 | + $data = $this->request->getData(); |
| 393 | + |
| 394 | + $this->assertSame('MerchantInitiatedBilling', $data['L_BILLINGTYPE0']); |
| 395 | + $this->assertSame('Some Stuff', $data['L_BILLINGAGREEMENTDESCRIPTION0']); |
| 396 | + } |
| 397 | + |
| 398 | + public function testGetDataWithBillingAgreementOptionalParameters() |
| 399 | + { |
| 400 | + $billingAgreement = new BillingAgreement(true, 'Some Stuff', 'InstantOnly', 'Some custom annotation'); |
| 401 | + $this->request->setBillingAgreement($billingAgreement); |
| 402 | + |
| 403 | + $data = $this->request->getData(); |
| 404 | + |
| 405 | + $this->assertSame('MerchantInitiatedBilling', $data['L_BILLINGTYPE0']); |
| 406 | + $this->assertSame('Some Stuff', $data['L_BILLINGAGREEMENTDESCRIPTION0']); |
| 407 | + $this->assertSame('InstantOnly', $data['L_PAYMENTTYPE0']); |
| 408 | + $this->assertSame('Some custom annotation', $data['L_BILLINGAGREEMENTCUSTOM0']); |
| 409 | + } |
| 410 | + |
| 411 | + /** |
| 412 | + * |
| 413 | + */ |
| 414 | + public function testGetDataWithBillingAgreementWrongPaymentType() |
| 415 | + { |
| 416 | + $this->setExpectedException( |
| 417 | + '\Omnipay\Common\Exception\InvalidRequestException', |
| 418 | + "The 'paymentType' parameter can be only 'Any' or 'InstantOnly'" |
| 419 | + ); |
| 420 | + |
| 421 | + $billingAgreement = new BillingAgreement(false, 'Some Stuff', 'BadType', 'Some custom annotation'); |
| 422 | + } |
375 | 423 | }
|
0 commit comments