mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 08:17:32 -05:00 
			
		
		
		
	Gateways: Braintree: Credit card: Pay with new card
This commit is contained in:
		
							parent
							
								
									de33f510f6
								
							
						
					
					
						commit
						20fdbc19d5
					
				@ -0,0 +1,65 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Invoice Ninja (https://invoiceninja.com).
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @link https://github.com/invoiceninja/invoiceninja source repository
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @license https://www.elastic.co/licensing/elastic-license
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Tests\Browser\ClientPortal\Gateways\Braintree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\DataMapper\FeesAndLimits;
 | 
				
			||||||
 | 
					use App\Models\CompanyGateway;
 | 
				
			||||||
 | 
					use App\Models\GatewayType;
 | 
				
			||||||
 | 
					use Laravel\Dusk\Browser;
 | 
				
			||||||
 | 
					use Tests\Browser\Pages\ClientPortal\Login;
 | 
				
			||||||
 | 
					use Tests\DuskTestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CreditCardTest extends DuskTestCase
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    protected function setUp(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        parent::setUp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach (static::$browsers as $browser) {
 | 
				
			||||||
 | 
					            $browser->driver->manage()->deleteAllCookies();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->browse(function (Browser $browser) {
 | 
				
			||||||
 | 
					            $browser
 | 
				
			||||||
 | 
					                ->visit(new Login())
 | 
				
			||||||
 | 
					                ->auth();
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $cg = CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->firstOrFail();
 | 
				
			||||||
 | 
					        $fees_and_limits = $cg->fees_and_limits;
 | 
				
			||||||
 | 
					        $fees_and_limits->{GatewayType::CREDIT_CARD} = new FeesAndLimits();
 | 
				
			||||||
 | 
					        $cg->fees_and_limits = $fees_and_limits;
 | 
				
			||||||
 | 
					        $cg->save();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function testPayWithNewCard()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->browse(function (Browser $browser) {
 | 
				
			||||||
 | 
					            $browser
 | 
				
			||||||
 | 
					                ->visitRoute('client.invoices.index')
 | 
				
			||||||
 | 
					                ->click('@pay-now')
 | 
				
			||||||
 | 
					                ->press('Pay Now')
 | 
				
			||||||
 | 
					                ->clickLink('Credit Card')
 | 
				
			||||||
 | 
					                ->waitFor('#braintree-hosted-field-number', 60)
 | 
				
			||||||
 | 
					                ->waitFor('##braintree-hosted-field-expirationDate', 60)
 | 
				
			||||||
 | 
					                ->withinFrame('#braintree-hosted-field-number', function (Browser $browser) {
 | 
				
			||||||
 | 
					                    $browser->type('credit-card-number', '4111111111111111');
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                ->withinFrame('#braintree-hosted-field-expirationDate', function (Browser $browser) {
 | 
				
			||||||
 | 
					                    $browser->type('expiration', '04/25');
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                ->press('Pay Now')
 | 
				
			||||||
 | 
					                ->waitForText('Details of the payment', 60);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user