MediaWiki fundraising/REL1_35
status.php
Go to the documentation of this file.
1#!/usr/bin/env php
2<?php
3
4$IP = getenv( 'MW_INSTALL_PATH' );
5if ( $IP === false ) {
6 $IP = __DIR__ . '/../../../..';
7}
8
9// If you get errors on this next line, set (and export) your MW_INSTALL_PATH var.
10require_once "$IP/maintenance/Maintenance.php";
11
12// Asks the AstroPay API for info about a particular donation
14 public function __construct() {
15 parent::__construct();
16
17 $this->requireExtension( 'Donation Interface' );
18
19 $this->addArg( 'id', 'Contribution tracking ID', true );
20 }
21
22 public function execute() {
23 $oid = $this->getArg( 0 );
24 $parts = explode( '.', $oid );
25 $ctid = $parts[0];
26 $gateway_opts = [
27 'batch_mode' => true,
28 'external_data' => [
29 'order_id' => $this->getArg( 'id' ),
30 'contribution_tracking_id' => $ctid,
31 // Dummy data to satisfy validation :P
32 'payment_method' => 'cc',
33 'country' => 'BR',
34 'currency' => 'BRL',
35 'amount' => 10,
36 'email' => 'dummy@example.org',
37 ],
38 ];
39 $this->output( "Checking order $oid\n" );
40 $adapter = new AstroPayAdapter( $gateway_opts );
41 $result = $adapter->do_transaction( 'PaymentStatus' );
42 $this->output( print_r( $result->getData(), true ) );
43 }
44}
45
46$maintClass = AstroPayStatusQuery::class;
47require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
AstroPayAdapter Implementation of GatewayAdapter for processing payments via AstroPay.
execute()
Do the actual work.
Definition status.php:22
__construct()
Default constructor.
Definition status.php:14
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
Add some args that are needed.
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
output( $out, $channel=null)
Throw some output to the user.
getArg( $argId=0, $default=null)
Get an argument.
$IP
Definition status.php:4
$maintClass
Definition status.php:46