|
5 | 5 | use Illuminate\Http\Request;
|
6 | 6 | use Illuminate\Support\Facades\Auth;
|
7 | 7 | use App\Models\Cart;
|
| 8 | +use Shetabit\Multipay\Invoice; |
| 9 | +use Shetabit\Payment\Facade\Payment; |
| 10 | + |
| 11 | + |
| 12 | +// Create new invoice. |
| 13 | +$invoice = new Invoice; |
| 14 | + |
| 15 | +// Set invoice amount. |
| 16 | +$invoice->amount(1000); |
| 17 | + |
| 18 | +// Add invoice details: There are 4 syntax available for this. |
| 19 | +// 1 |
| 20 | +$invoice->detail(['detailName' => 'your detail goes here']); |
| 21 | +// 2 |
| 22 | +$invoice->detail('detailName','your detail goes here'); |
| 23 | +// 3 |
| 24 | +$invoice->detail(['name1' => 'detail1','name2' => 'detail2']); |
| 25 | +// 4 |
| 26 | +$invoice->detail('detailName1','your detail1 goes here') |
| 27 | + ->detail('detailName2','your detail2 goes here'); |
| 28 | + |
| 29 | +// Create new invoice. |
| 30 | +$invoice = (new Invoice)->amount(1000); |
| 31 | + |
| 32 | +// Purchase the given invoice. |
| 33 | +Payment::purchase($invoice,function($driver, $transactionId) { |
| 34 | + // We can store $transactionId in database. |
| 35 | +}); |
| 36 | + |
| 37 | +// Purchase method accepts a callback function. |
| 38 | +Payment::purchase($invoice, function($driver, $transactionId) { |
| 39 | + // We can store $transactionId in database. |
| 40 | +}); |
| 41 | + |
| 42 | +// You can specify callbackUrl |
| 43 | +Payment::callbackUrl('http://yoursite.com/verify')->purchase( |
| 44 | + $invoice, |
| 45 | + function($driver, $transactionId) { |
| 46 | + // We can store $transactionId in database. |
| 47 | + } |
| 48 | +); |
| 49 | + |
8 | 50 |
|
9 | 51 | class CartController extends Controller
|
10 | 52 | {
|
|
0 commit comments