Skip to content
akDeveloper edited this page Jul 14, 2011 · 8 revisions
require_once('path/to/lib/merchant.php');

Merchant_Billing_Base::mode('test'); # Remove this on production mode

try {

  $gateway = new Merchant_Billing_YourPaymentGateway( array(
    'login' => 'login_id',
    'password' => 'password'
  ));

  # Create a credit card object if you need it.
  $credit_card = new Merchant_Billing_CreditCard( array(
    "first_name" => "John",
    "last_name" => "Doe",
    "number" => "41111111111111",
    "month" => "12",
    "year" => "2012",
    "verification_value" => "123"
    )
  );

  # Extra options for transaction
  $options = array(
    'order_id' => 'REF' . $gateway->generate_unique_id(),
    'description' => 'Test Transaction',
    'address' => array(
      'address1' => '1234 Street',
      'zip' => '98004',
      'state' => 'WA'
    )
  );

  if ( $credit_card->is_valid() ) {

    # Authorize transaction
    $response = $gateway->authorize('100', $credit_card, $options);
    if ( $response->success() ) {
      echo 'Success Authorize';
    } else {
      echo $response->message();
    }
  }
} catch (Exception $e) {
  echo $e->getMessage();
}
Clone this wiki locally