Create transaction

To create a transaction, just provide an amount and an UID for the previously created payment method.

Simple card payment

If you have create a Card already, you can run a simple payment with just a few lines of code.

$transactionReq = Pencepay_Request_Transaction::build()
       ->creditCardUid('card_uid')
       ->amount(10.99)
       ->currencyCode('EUR');

$transaction = Pencepay_Transaction::create($transactionReq);

Result

Handling a result depends on a payment method used, here is an example for card authorization request.

if ($txn->status == 'CAPTURED') {
    // Transaction is approved
}

Create a card payment - full properties

This example shows the full use of our Transactions API.

By specifying saveInSafe setting option, separate objects will be created for certain fields in Pencepay platform (e.g. CreditCard, Customer, Address)

$transactionReq = Pencepay_Request_Transaction::build()
    ->orderId('123456')
    ->amount(10.99)
    ->currencyCode('EUR')
    ->customer()
        ->firstName('John')
        ->lastName('Hancock')
        ->email('hancock@server.com')
        ->done()
    ->billingAddress()
        ->city('Zagreb')
        ->postalCode('10000')
        ->countryCode('HR')
        ->done()
    ->creditCard()
        ->cardholderName('John Hancock')
        ->number('4350100010001002')
        ->cvv('313')
        ->expiryMonth(12)
        ->expiryYear(2016)
        ->done()
    ->settings()
        ->locale('hr-HR')
        ->reserveFundsOnly(true)
        ->saveInSafe(false)
        ->done();

Create a bank transfer

In order to perform a bank transfer, provide a paymentMethod and bic properties.

$transactionReq = Pencepay_Request_Transaction::build()
    ->paymentMethod('BANK_TRANSFER')
    ->bic('NWBKGB2L')
    ->orderId('123456')
    ->amount(10.99)
    ->currencyCode('EUR')
    ->customer()
        ->firstName('John')
        ->lastName('Hancock')
        ->email('hancock@server.com')
        ->done()
    ->billingAddress()
        ->city('Zagreb')
        ->postalCode('10000')
        ->countryCode('HR')
        ->done()
    ->settings()
        ->saveInSafe(false)
        ->done();

$transaction = Pencepay_Transaction::create($transactionReq);
$transaction->paymentInstructions; // Info about how to make a transfer