VendAPI
VendAPI copied to clipboard
Still active
WIll this php library still work? I notice there have not been updates in some time. thanks
It does work but there is no 2.0 support. I have forked a version of this for most 2.0 functions
Thank you for your response. A question on the api example. While I know what the VEND_ACCESS_TOKEN is, what is the VEND_TOKEN_TYPE? Thanks
That is always Bearer
$vend = new VendAPI\VendAPI('https://****.vendhq.com','Bearer', $config->VendToken);
The api has been working nicely for about 2 months now. A question came up, how do you set the sales to be complete / paid for in vend in the api? thanks
$sale = new \VendAPI\VendSale(null, $vend);
$sale->status = 'CLOSED';
great, thanks
On 5/20/20 12:01 PM, Kayne Middleton wrote:
|$sale = new \VendAPI\VendSale(null, $vend); $sale->status = 'CLOSED'; |
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brucealdridge/VendAPI/issues/34#issuecomment-631568133, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZUOCXXHV6CXEGSO2ZVRD3RSP5EVANCNFSM4KNL6F4A.
Actually, that is what is being used and Vend shows an open balance not zeron. Any ideas?
On 5/20/20 12:01 PM, Kayne Middleton wrote:
|$sale = new \VendAPI\VendSale(null, $vend); $sale->status = 'CLOSED'; |
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brucealdridge/VendAPI/issues/34#issuecomment-631568133, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZUOCXXHV6CXEGSO2ZVRD3RSP5EVANCNFSM4KNL6F4A.
Have you set the payment type and applied the payment to the transaction?
$payments = array();
$payments[] = array(
'retailer_payment_type_id' => '*****-****-****-****-**********', //Bank Transfer (closes order)
'amount' => $total
);
$sale->register_sale_products = $products;
$sale->register_sale_payments = $payments;
$sale->save();
awe, thanks
On 5/20/20 1:16 PM, Kayne Middleton wrote:
Have you set the payment type and applied the payment to the transaction?
` $payments = array(); $payments[] = array( 'retailer_payment_type_id' => '----*******', //Bank Transfer (closes order) 'amount' => $total );
$sale->register_sale_products = $products; $sale->register_sale_payments = $payments; $sale->save(); `
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brucealdridge/VendAPI/issues/34#issuecomment-631610305, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZUOCUN7R47YYLI2XOQ3J3RSQF7XANCNFSM4KNL6F4A.
This is not exactly what is needed. I am writing code to update vend after a website sale is done using woocommerce. All the orders have been paid for using a credit card service. Therefore "real" payments are not to be sent but rather credit of orders that have been done on the website.. The main reason to send order to Vend is to update (decrement) inventory stored in Vend. Any suggestion on how this might be done?
On 5/20/20 1:16 PM, Kayne Middleton wrote:
Have you set the payment type and applied the payment to the transaction?
` $payments = array(); $payments[] = array( 'retailer_payment_type_id' => '----*******', //Bank Transfer (closes order) 'amount' => $total );
$sale->register_sale_products = $products; $sale->register_sale_payments = $payments; $sale->save(); `
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brucealdridge/VendAPI/issues/34#issuecomment-631610305, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZUOCUN7R47YYLI2XOQ3J3RSQF7XANCNFSM4KNL6F4A.
I actually place the order into Vend after it has been paid by the credit card carrier. This solved the issue for me when I had this problem. Once the payment/ipn comes back then put the order into Vend with the payment attached. This means that if the product is not actually purchased the inventory does not go down. Otherwise you have to void the transaction.
"Once the payment/ipn comes back then put the order into Vend with the payment attached." Maybe this is where I getting tripped up. Your earlier email was :
$payments[] = array( 'retailer_payment_type_id' => '----*******', //Bank Transfer (closes order) 'amount' => $total );
I was useing register_id (as that is what vend doc said) and program crashed and I didn't know what "Bank Transfer (closes order)" meant.
Where do you get "payment attached"? I don't know 'retailer_payment_type_id' .
Really appreciate your time, thanks - Lou
On 5/21/20 12:47 PM, Kayne Middleton wrote:
I actually place the order into Vend after it has been paid by the credit card carrier. This solved the issue for me when I had this problem. Once the payment/ipn comes back then put the order into Vend with the payment attached. This means that if the product is not actually purchased the inventory does not go down. Otherwise you have to void the transaction.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brucealdridge/VendAPI/issues/34#issuecomment-632217893, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZUOCRN563GRH3UP44YF5TRSVLJ7ANCNFSM4KNL6F4A.
The retailer_payment_type_id is in the address bar when you click on the Payment Type in vend (https://yoursite.vendhq.com/setup/payment_types/) https://yoursite.vendhq.com/setup/payment_types/edit/Payment Code is Here
It can be anything you choose, it just closes the order once the payment is fully complete.
I use PxPay on the site this code comes from below. The CMS is SilverStripe so the $config and $prod variable are from that. The register codes are made up, you just need to find your matching ones in Vend. Hopefully you find theis useful.
public function processPayment(){
/* PAXPAY CODE */
if ($rsp->getSuccess() == "1"){
if (!$this->isProcessed($rsp->getTxnId())){
# You cannot use any form of database queries here unless the PxPay passes it over!
//Write Success
$PxPayTransaction->write();
//Empty Cart!
$cart = DataObject::get_one("Cart", "MemberID = '" . $rsp->getTxnData2() . "'");
$cart->Delete();
$config = SiteConfig::current_site_config();
//Create vend transaction
$vend = new VendAPI\VendAPI('https://yoursite.vendhq.com', 'Bearer', $config->VendToken);
$sale = new \VendAPI\VendSale(null, $vend);
$sale->register_id = '116164-123gdg-6513sdf-34ss-6345sfdsf3s'; //Main Register
$sale->customer_id = $rsp->getTxnData1();
$sale->status = 'CLOSED';
//Actually pull from order not cart as that can be changed via site
$order = DataObject::get_one("Order", "ID = '" . $rsp->getMerchantReference() . "'");
$products = array();
foreach ($order->OrderItem() as $item) {
$prod = DataObject::get_one("VendProduct", "Product_ID = '" . $item->Product_ID . "'");
//If product exists otherwise remove from order (Overpayment Made)
if (empty($prod)) {
$item->delete();
} else {
if (!empty($prod)) {
if ($prod->PricebookPrice > 0) {
$price = $prod->PricebookPrice;
} else {
$price = $prod->Price;
}
$tax = $price * 0.15;
$taxlessprice = $price - $tax;
$products[] = array(
'product_id' => $prod->Product_ID,
'quantity' => $item->Quantity,
'price' => $taxlessprice,
'tax' => $tax,
"discount" => 0,
"loyalty_value" => 0,
"tax_id" => "3s4fsf1-efs23-sdfsf-3r5g-dg24drg2dg"
);
}
}
}
//Shipping Cost
$shipping = $order->ShippingPrice;
$stax = $shipping * 0.15;
$staxlessprice = $shipping - $stax;
array_push($products, array(
'product_id' => 'fghfhfj-fghfh-f3ab-fghfh-fjhjffghfh', //ID for Shipping Product
'quantity' => 1,
'price' => $staxlessprice,
'tax' => $stax,
"discount" => 0,
"loyalty_value" => 0,
"tax_id" => "b8ca3a65-011c-11e4-fbb5-558afc6334d0"
));
$payments = array();
$payments[] = array(
'retailer_payment_type_id' => '45tvddgd-dfgdg-dgdg-dgdg-dgdgertg', //Payment Express (closes order)
'amount' => $order->Total
);
//Vend Related
$sale->register_sale_products = $products;
$sale->register_sale_payments = $payments;
$sale->save();
//SilverStripe
$order->Code = $sale->id;
$order->SendOrderEmail = 1; //Send Email!
$order->Write();
}
$this->redirect('https://website.com/payment-successful');
} else {
if (!$this->isProcessed($rsp->getTxnId())){
# Send emails, generate invoices, update order status etc.
//Write Success
$PxPayTransaction->write();
}
//DECLINED or CANCELLED
$this->redirect('https://website.com/payment-cancelled');
}
}
Thank you so much. minutes before before I got you email, I figured/found :
(https://yoursite.vendhq.com/setup/payment_types/)
and got a payment through using the credit card type. They should have hid it a little better, thanks again - Lou
On 5/21/20 1:31 PM, Kayne Middleton wrote:
The retailer_payment_type_id is in the address bar when you click on the Payment Type in vend (https://yoursite.vendhq.com/setup/payment_types/) https://yoursite.vendhq.com/setup/payment_types/edit/Payment Code is Here
It can be anything you choose, it just closes the order once the payment is fully complete.
I use PxPay on the site this code comes from below. The CMS is SilverStripe so the $config and $prod variable are from that. The register codes are made up, you just need to find your matching ones in Vend. Hopefully you find theis useful.
|public function processPayment(){ /* PAXPAY CODE */ if ($rsp->getSuccess() == "1"){ if (!$this->isProcessed($rsp->getTxnId())){ # You cannot use any form of database queries here unless the PxPay passes it over! //Write Success $PxPayTransaction->write(); //Empty Cart! $cart = DataObject::get_one("Cart", "MemberID = '" . $rsp->getTxnData2() . "'"); $cart->Delete(); $config = SiteConfig::current_site_config(); //Create vend transaction $vend = new VendAPI\VendAPI('https://yoursite.vendhq.com', 'Bearer', $config->VendToken); $sale = new \VendAPI\VendSale(null, $vend); $sale->register_id = '116164-123gdg-6513sdf-34ss-6345sfdsf3s'; //Main Register $sale->customer_id = $rsp->getTxnData1(); $sale->status = 'CLOSED'; //Actually pull from order not cart as that can be changed via site $order = DataObject::get_one("Order", "ID = '" . $rsp->getMerchantReference() . "'"); $products = array(); foreach ($order->OrderItem() as $item) { $prod = DataObject::get_one("VendProduct", "Product_ID = '" . $item->Product_ID . "'"); //If product exists otherwise remove from order (Overpayment Made) if (empty($prod)) { $item->delete(); } else { if (!empty($prod)) { if ($prod->PricebookPrice > 0) { $price = $prod->PricebookPrice; } else { $price = $prod->Price; } $tax = $price * 0.15; $taxlessprice = $price - $tax; $products[] = array( 'product_id' => $prod->Product_ID, 'quantity' => $item->Quantity, 'price' => $taxlessprice, 'tax' => $tax, "discount" => 0, "loyalty_value" => 0, "tax_id" => "3s4fsf1-efs23-sdfsf-3r5g-dg24drg2dg" ); } } } //Shipping Cost $shipping = $order->ShippingPrice; $stax = $shipping * 0.15; $staxlessprice = $shipping - $stax; array_push($products, array( 'product_id' => 'fghfhfj-fghfh-f3ab-fghfh-fjhjffghfh', //ID for Shipping Product 'quantity' => 1, 'price' => $staxlessprice, 'tax' => $stax, "discount" => 0, "loyalty_value" => 0, "tax_id" => "b8ca3a65-011c-11e4-fbb5-558afc6334d0" )); $payments = array(); $payments[] = array( 'retailer_payment_type_id' => '45tvddgd-dfgdg-dgdg-dgdg-dgdgertg', //Payment Express (closes order) 'amount' => $order->Total ); //Vend Related $sale->register_sale_products = $products; $sale->register_sale_payments = $payments; $sale->save(); //SilverStripe $order->Code = $sale->id; $order->SendOrderEmail = 1; //Send Email! $order->Write(); } $this->redirect('https://website.com/payment-successful'); } else { if (!$this->isProcessed($rsp->getTxnId())){ # Send emails, generate invoices, update order status etc. //Write Success $PxPayTransaction->write(); } //DECLINED or CANCELLED $this->redirect('https://website.com/payment-cancelled'); } } |
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brucealdridge/VendAPI/issues/34#issuecomment-632241316, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZUOCRO67IKN42KEVBBGR3RSVQPNANCNFSM4KNL6F4A.